MCPcopy Create free account
hub / github.com/Exafunction/codeium-chrome / language

Function language

src/codemirrorLanguages.ts:85–103  ·  view source on GitHub ↗
(doc: CodeMirror.Doc, path: string | undefined)

Source from the content-addressed store, hash-verified

83}
84
85export function language(doc: CodeMirror.Doc, path: string | undefined): Language {
86 if (path !== undefined) {
87 const basename = path.split('/').pop() ?? '';
88 // Iterate over FILENAME_MAP for a match.
89 for (const [regex, language] of FILENAME_MAP) {
90 if (regex.test(basename)) {
91 return language;
92 }
93 }
94 }
95 const mime = doc.getEditor()?.getOption('mode');
96 if (typeof mime === 'string') {
97 const language = MIME_MAP.get(mime);
98 if (language !== undefined) {
99 return language;
100 }
101 }
102 return MODE_MAP.get(getMode(doc).name) ?? Language.UNSPECIFIED;
103}

Callers 2

triggerCompletionMethod · 0.90

Calls 1

getModeFunction · 0.85

Tested by

no test coverage detected