Skip to content

Commit

Permalink
Fixes #335
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-bsaviano committed Jun 27, 2024
1 parent af6f537 commit 31e4738
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions server/src/parse/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions server/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };

0 comments on commit 31e4738

Please sign in to comment.