diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ae46fa..993d465 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix issue [#328](https://github.com/intersystems/language-server/issues/328): Fix namespace detection for Diagnostic computation - Fix issue [#331](https://github.com/intersystems/language-server/issues/331): Fix display of method arguments with a colon in the default value - Fix issue [#333](https://github.com/intersystems/language-server/issues/333): Fix folding ranges when routine labels that don't appear in the first column +- Fix issue [#335](https://github.com/intersystems/language-server/issues/335): Support U2 syntax when ROUTINE LanguageMode = 10 - Parser changes: - DP-430950: Support new `Requires` Query keyword diff --git a/server/src/parse/parse.ts b/server/src/parse/parse.ts index 8251443..2761aaa 100644 --- a/server/src/parse/parse.ts +++ b/server/src/parse/parse.ts @@ -9,8 +9,9 @@ const acceptroutineheaderline = true; // flags to pass to Tokenize const IPARSE_UDL_EXPLICIT = 0x0001; // require variable declaration (#dim) -const IPARSE_UDL_EXPERT = 0x4000; // this stops the SYSTEM class-keyword from being colored as a syntax-error -const IPARSE_UDL_TRACK = 0x20000; // enable variable-tracking +const IPARSE_UDL_EXPERT = 0x4000; // this stops the SYSTEM class keyword from being colored as a syntax error +const IPARSE_COS_U2 = 0x10000; // accept U2 syntax +const IPARSE_UDL_TRACK = 0x20000; // enable variable tracking // these flags are only passed for HTML documents const IPARSE_ALL_CSPEXTENSIONS = 0x0400; // all parsers: recognize CSP extensions like #(..)# const IPARSE_HTML_CSPMODE = 0x0800; // HTML parser: is in CSP mode @@ -38,6 +39,11 @@ export function parseDocument(languageId: string, fileExt: string, text: string) // color the routine header line const routinelinecoloring: routineheadertype = colorRoutineLine(firstline); + if (routinelinecoloring?.routineheaderinfo?.languagemode == 10) { + // LanguageMode 10 is U2, so allow U2 syntax + flags += IPARSE_COS_U2; + } + // effectively replace the routine line (before the line-ending) with spaces so that the offsets are still correct const doctoparse = ' '.repeat(firstline.length) + text.slice(firstline.length); diff --git a/server/src/utils/types.ts b/server/src/utils/types.ts index b7bd4b4..7d63eb5 100644 --- a/server/src/utils/types.ts +++ b/server/src/utils/types.ts @@ -167,10 +167,10 @@ export type compresseditem = { export type compressedline = compresseditem[]; -export type compressedresult = {'compressedlinearray': compressedline[], 'routineheaderinfo'?: routineheaderinfotype}; +export type compressedresult = { compressedlinearray: compressedline[], routineheaderinfo?: routineheaderinfotype }; -export type compressedcolors = {'compressedcolors': compressedline[]}; +export type compressedcolors = { compressedcolors: compressedline[] }; // routine header (if present 'generated' is just set to '') -export type routineheaderinfotype = {'routinename': string, 'routinetype'?: string, 'languagemode'?: number, 'generated'?: string}; +export type routineheaderinfotype = { routinename: string, routinetype?: string, languagemode?: number, generated?: string };