17 lines
771 B
TypeScript
17 lines
771 B
TypeScript
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()
|
||
}
|