Skip to content

Commit 31e4738

Browse files
committed
Fixes #335
1 parent af6f537 commit 31e4738

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Fix issue [#328](https://github.com/intersystems/language-server/issues/328): Fix namespace detection for Diagnostic computation
55
- Fix issue [#331](https://github.com/intersystems/language-server/issues/331): Fix display of method arguments with a colon in the default value
66
- 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
7+
- Fix issue [#335](https://github.com/intersystems/language-server/issues/335): Support U2 syntax when ROUTINE LanguageMode = 10
78
- Parser changes:
89
- DP-430950: Support new `Requires` Query keyword
910

server/src/parse/parse.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ const acceptroutineheaderline = true;
99

1010
// flags to pass to Tokenize
1111
const IPARSE_UDL_EXPLICIT = 0x0001; // require variable declaration (#dim)
12-
const IPARSE_UDL_EXPERT = 0x4000; // this stops the SYSTEM class-keyword from being colored as a syntax-error
13-
const IPARSE_UDL_TRACK = 0x20000; // enable variable-tracking
12+
const IPARSE_UDL_EXPERT = 0x4000; // this stops the SYSTEM class keyword from being colored as a syntax error
13+
const IPARSE_COS_U2 = 0x10000; // accept U2 syntax
14+
const IPARSE_UDL_TRACK = 0x20000; // enable variable tracking
1415
// these flags are only passed for HTML documents
1516
const IPARSE_ALL_CSPEXTENSIONS = 0x0400; // all parsers: recognize CSP extensions like #(..)#
1617
const IPARSE_HTML_CSPMODE = 0x0800; // HTML parser: is in CSP mode
@@ -38,6 +39,11 @@ export function parseDocument(languageId: string, fileExt: string, text: string)
3839
// color the routine header line
3940
const routinelinecoloring: routineheadertype = colorRoutineLine(firstline);
4041

42+
if (routinelinecoloring?.routineheaderinfo?.languagemode == 10) {
43+
// LanguageMode 10 is U2, so allow U2 syntax
44+
flags += IPARSE_COS_U2;
45+
}
46+
4147
// effectively replace the routine line (before the line-ending) with spaces so that the offsets are still correct
4248
const doctoparse = ' '.repeat(firstline.length) + text.slice(firstline.length);
4349

server/src/utils/types.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ export type compresseditem = {
167167

168168
export type compressedline = compresseditem[];
169169

170-
export type compressedresult = {'compressedlinearray': compressedline[], 'routineheaderinfo'?: routineheaderinfotype};
170+
export type compressedresult = { compressedlinearray: compressedline[], routineheaderinfo?: routineheaderinfotype };
171171

172-
export type compressedcolors = {'compressedcolors': compressedline[]};
172+
export type compressedcolors = { compressedcolors: compressedline[] };
173173

174174

175175
// routine header (if present 'generated' is just set to '')
176-
export type routineheaderinfotype = {'routinename': string, 'routinetype'?: string, 'languagemode'?: number, 'generated'?: string};
176+
export type routineheaderinfotype = { routinename: string, routinetype?: string, languagemode?: number, generated?: string };

0 commit comments

Comments
 (0)