MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / tokenizeCodeEditorLine

Function tokenizeCodeEditorLine

packages/core/src/widgets/codeEditorSyntax.ts:1022–1034  ·  view source on GitHub ↗
(
  line: string,
  context: Readonly<{ language?: CodeEditorSyntaxLanguage }> = {},
)

Source from the content-addressed store, hash-verified

1020}
1021
1022export function tokenizeCodeEditorLine(
1023 line: string,
1024 context: Readonly<{ language?: CodeEditorSyntaxLanguage }> = {},
1025): readonly CodeEditorSyntaxToken[] {
1026 const source = typeof line === "string" ? line : "";
1027 if (source.length === 0) return Object.freeze([]);
1028
1029 const language = normalizeLanguage(context.language);
1030 if (language === "plain") return plainLine(source);
1031
1032 const grammar = GRAMMARS[language] ?? GRAMMARS.plain;
1033 return tokenizeLineWithGrammar(source, grammar, language);
1034}
1035
1036/**
1037 * Sanitizes custom tokenizer output and guarantees full line coverage.

Callers 3

renderCodeBlockFunction · 0.85

Calls 3

normalizeLanguageFunction · 0.85
plainLineFunction · 0.85
tokenizeLineWithGrammarFunction · 0.85

Tested by

no test coverage detected