Files
OJ2/apps/web/src/shared/extensions/language.ts
T
xuyue d25b5dbe6d
Deploy / deploy (push) Canceled after 0s
update
2026-09-27 19:36:28 +08:00

17 lines
771 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { cpp } from "@codemirror/lang-cpp"
import { python } from "@codemirror/lang-python"
import { sql, SQLite } from "@codemirror/lang-sql"
import type { Extension } from "@codemirror/state"
import type { LANGUAGE } from "utils/types"
/**
* 语言对应的高亮扩展。学生端和教师端共用同一份(两边都是题目页上的 SyncCodeEditor) ——
* 两边各选各的,就是老师看到的高亮和补全跟学生手里那份对不上。
*
* Java / Golang / JavaScript 没有单独的包,落到 cpp(),是既有行为,不是遗漏。
*/
export function languageExtension(language: LANGUAGE): Extension {
if (language === "SQL") return sql({ dialect: SQLite, upperCaseKeywords: true })
return language === "Python" ? python() : cpp()
}