Skip to content

Commit b7467eb

Browse files
committed
fix #337 handle Unicode chars in identifiers
1 parent 3e51adc commit b7467eb

File tree

4 files changed

+42
-41
lines changed

4 files changed

+42
-41
lines changed

src/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile {
8686
if (csp) {
8787
name = uri.path;
8888
} else if (fileExt === "cls") {
89-
const match = content.match(/^Class (%?\w+(?:\.\w+)+)/im);
89+
// Allow Unicode letters
90+
const match = content.match(/^Class (%?[\p{L}\d]+(?:\.[\p{L}\d]+)+)/imu);
9091
if (match) {
9192
[, name, ext = "cls"] = match;
9293
}

syntaxes/objectscript-class.tmLanguage.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"include": "#comments"
1818
},
1919
{
20-
"match": "(?i)^(\\Include\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*(?:\\.[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)*)",
20+
"match": "(?i)^(\\Include\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*(?:\\.[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)*)",
2121
"captures": {
2222
"1": {
2323
"name": "keyword.objectscript_class"
@@ -31,7 +31,7 @@
3131
}
3232
},
3333
{
34-
"match": "(?i)^(\\bClass\\b)(\\s)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*(?:\\.[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)*)",
34+
"match": "(?i)^(\\bClass\\b)(\\s)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*(?:\\.[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)*)",
3535
"captures": {
3636
"1": {
3737
"name": "keyword.objectscript_class"
@@ -45,7 +45,7 @@
4545
}
4646
},
4747
{
48-
"match": "(?i)(\\bExtends\\b)(\\s)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*(?:\\.[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)*)",
48+
"match": "(?i)(\\bExtends\\b)(\\s)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*(?:\\.[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)*)",
4949
"captures": {
5050
"1": {
5151
"name": "keyword.objectscript_class"
@@ -73,7 +73,7 @@
7373
},
7474
"patterns": [
7575
{
76-
"match": "(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*(?:\\.[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)*)",
76+
"match": "(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*(?:\\.[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)*)",
7777
"captures": {
7878
"1": {
7979
"name": "entity.name.class.objectscript_class"
@@ -112,7 +112,7 @@
112112
"as": {
113113
"patterns": [
114114
{
115-
"match": "(?i)(\\bAs\\b(?:\\slist of)?)(\\s+)(%?[a-z][0-9a-z]*(?:_[0-9a-z]+)*(?:\\.[a-z][0-9a-z]*(?:_[0-9a-z]+)*)*)",
115+
"match": "(?i)(\\bAs\\b(?:\\slist of)?)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*(?:\\.[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)*)",
116116
"captures": {
117117
"1": {
118118
"name": "keyword.objectscript_class"
@@ -155,7 +155,7 @@
155155
"include": "#comments"
156156
},
157157
{
158-
"begin": "(?i)(^\\bIndex\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)",
158+
"begin": "(?i)(^\\bIndex\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)",
159159
"beginCaptures": {
160160
"1": {
161161
"name": "keyword.objectscript_class"
@@ -180,7 +180,7 @@
180180
}
181181
},
182182
{
183-
"match": "(?i)^(\\bForeignKey\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)",
183+
"match": "(?i)^(\\bForeignKey\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)",
184184
"captures": {
185185
"1": {
186186
"name": "keyword.objectscript_class"
@@ -194,7 +194,7 @@
194194
}
195195
},
196196
{
197-
"begin": "(?i)^(\\bParameter\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)",
197+
"begin": "(?i)^(\\bParameter\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)",
198198
"beginCaptures": {
199199
"1": {
200200
"name": "keyword.objectscript_class"
@@ -219,7 +219,7 @@
219219
}
220220
},
221221
{
222-
"match": "(?i)^(\\Projection\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)",
222+
"match": "(?i)^(\\Projection\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)",
223223
"captures": {
224224
"1": {
225225
"name": "keyword.objectscript_class"
@@ -233,7 +233,7 @@
233233
}
234234
},
235235
{
236-
"begin": "(?i)^(\\bProperty\\b)(\\s+)((?:%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)|(?:\"[^\".]+\"))",
236+
"begin": "(?i)^(\\bProperty\\b)(\\s+)((?:%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)|(?:\"[^\".]+\"))",
237237
"beginCaptures": {
238238
"1": {
239239
"name": "keyword.objectscript_class"
@@ -258,7 +258,7 @@
258258
}
259259
},
260260
{
261-
"begin": "(?i)^(\\bRelationship\\b)(\\s+)((?:%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)|(?:\"[^\".]+\"))",
261+
"begin": "(?i)^(\\bRelationship\\b)(\\s+)((?:%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)|(?:\"[^\".]+\"))",
262262
"beginCaptures": {
263263
"1": {
264264
"name": "keyword.objectscript_class"
@@ -283,7 +283,7 @@
283283
}
284284
},
285285
{
286-
"begin": "(?i)^(\\bClient(?:Class)?Method\\b)(\\s+)((?:%|%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)|(?:\"[^\".]+\"))",
286+
"begin": "(?i)^(\\bClient(?:Class)?Method\\b)(\\s+)((?:%|%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)|(?:\"[^\".]+\"))",
287287
"beginCaptures": {
288288
"1": {
289289
"name": "keyword.objectscript_class"
@@ -308,7 +308,7 @@
308308
}
309309
},
310310
{
311-
"begin": "(?i)^(\\b(?:Class)?Method\\b)(\\s+)((?:%|%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)|(?:\"[^\".]+\"))",
311+
"begin": "(?i)^(\\b(?:Class)?Method\\b)(\\s+)((?:%|%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)|(?:\"[^\".]+\"))",
312312
"beginCaptures": {
313313
"1": {
314314
"name": "keyword.objectscript_class"
@@ -333,7 +333,7 @@
333333
}
334334
},
335335
{
336-
"begin": "(?i)^(\\Query\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)",
336+
"begin": "(?i)^(\\Query\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)",
337337
"beginCaptures": {
338338
"1": {
339339
"name": "keyword.objectscript_class"
@@ -358,7 +358,7 @@
358358
}
359359
},
360360
{
361-
"begin": "(?i)^(\\bTrigger\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)",
361+
"begin": "(?i)^(\\bTrigger\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)",
362362
"beginCaptures": {
363363
"1": {
364364
"name": "keyword.objectscript_class"
@@ -411,7 +411,7 @@
411411
}
412412
},
413413
{
414-
"begin": "(?i)^(\\XData\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)",
414+
"begin": "(?i)^(\\XData\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)",
415415
"beginCaptures": {
416416
"1": {
417417
"name": "keyword.objectscript_class"
@@ -439,7 +439,7 @@
439439
}
440440
},
441441
{
442-
"begin": "(?i)^(\\Storage\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)",
442+
"begin": "(?i)^(\\Storage\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)",
443443
"beginCaptures": {
444444
"1": {
445445
"name": "keyword.objectscript_class"
@@ -572,7 +572,7 @@
572572
"include": "#as"
573573
},
574574
{
575-
"match": "[a-zA-Z][a-zA-Z0-9]*",
575+
"match": "[\\p{Alpha}][\\p{Alnum}]*",
576576
"name": "variable.name.objectscript"
577577
},
578578
{
@@ -585,7 +585,7 @@
585585
"index": {
586586
"patterns": [
587587
{
588-
"match": "(\\bOn\\b)(\\s+)(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*(?:\\.[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)*)",
588+
"match": "(\\bOn\\b)(\\s+)(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*(?:\\.[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)*)",
589589
"captures": {
590590
"1": {
591591
"name": "keyword.objectscript_class"
@@ -613,7 +613,7 @@
613613
},
614614
"patterns": [
615615
{
616-
"match": "(%?[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*(?:\\.[a-zA-Z][0-9a-zA-Z]*(?:_[0-9a-zA-Z]+)*)*)",
616+
"match": "(%?[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*(?:\\.[\\p{Alpha}][\\p{Alnum}]*(?:_[\\p{Alnum}]+)*)*)",
617617
"captures": {
618618
"1": {
619619
"name": "entity.other.attribute-name.objectscript_class"

syntaxes/objectscript-macros.tmLanguage.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scopeName": "source.objectscript_macros",
55
"patterns": [
66
{
7-
"match": "^(ROUTINE)\\s(\\b[a-zA-Z0-9.]+\\b)",
7+
"match": "^(ROUTINE)\\s(\\b[\\p{Alnum}.]+\\b)",
88
"captures": {
99
"1": { "name": "keyword.control" },
1010
"2": { "name": "entity.name.class" }
@@ -23,7 +23,7 @@
2323
"include": {
2424
"patterns": [
2525
{
26-
"begin": "^\\s*(\\#\\s*(?:(?i)include))\\s+([a-zA-Z%][a-zA-Z0-9]*)",
26+
"begin": "^\\s*(\\#\\s*(?:(?i)include))\\s+([\\p{Alpha}%][\\p{Alnum}]*)",
2727
"end": "(?=$)",
2828
"beginCaptures": {
2929
"1": { "name": "keyword.other.objectscript" },
@@ -36,7 +36,7 @@
3636
"patterns": [
3737
{
3838
"name": "meta.preprocessor.objectscript",
39-
"match": "^\\s*(\\#\\s*(?:(?i)dim))\\s+((?<id>[a-zA-Z%][a-zA-Z0-9]*))(?:\\s*(,)\\s*((\\g<id>)*))*(?:\\s+((?i)As)(?:\\s(\\g<id>(?:\\.\\g<id>)*)))?",
39+
"match": "^\\s*(\\#\\s*(?:(?i)dim))\\s+((?<id>[\\p{Alpha}%][\\p{Alnum}]*))(?:\\s*(,)\\s*((\\g<id>)*))*(?:\\s+((?i)As)(?:\\s(\\g<id>(?:\\.\\g<id>)*)))?",
4040
"captures": {
4141
"1": { "name": "keyword.control.objectscript" },
4242
"2": { "name": "variable.name" },
@@ -52,7 +52,7 @@
5252
"patterns": [
5353
{
5454
"name": "meta.preprocessor.objectscript",
55-
"begin": "^\\s*(\\#\\s*(?:(?i)define))\\s+((?<id>[%a-zA-Z0-9]*))(?:(\\()(\\s*\\g<id>\\s*((,)\\s*\\g<id>\\s*)*)(\\)))?",
55+
"begin": "^\\s*(\\#\\s*(?:(?i)define))\\s+((?<id>[%\\p{Alnum}]*))(?:(\\()(\\s*\\g<id>\\s*((,)\\s*\\g<id>\\s*)*)(\\)))?",
5656
"beginCaptures": {
5757
"1": { "name": "keyword.control.objectscript" },
5858
"2": { "name": "entity.name.objectscript" },
@@ -76,7 +76,7 @@
7676
"patterns": [
7777
{
7878
"name": "meta.preprocessor.objectscript",
79-
"begin": "^\\s*(\\#\\s*(?:(?i)def1arg))\\s+((?<id>[a-zA-Z%][a-zA-Z0-9]*))(?:(\\()(\\s*\\g<id>\\s*)(\\)))",
79+
"begin": "^\\s*(\\#\\s*(?:(?i)def1arg))\\s+((?<id>[\\p{Alpha}%][\\p{Alnum}]*))(?:(\\()(\\s*\\g<id>\\s*)(\\)))",
8080
"beginCaptures": {
8181
"1": { "name": "keyword.control.objectscript" },
8282
"2": { "name": "entity.name.objectscript" },
@@ -114,7 +114,7 @@
114114
},
115115

116116
"macros": {
117-
"patterns": [{ "match": "\\$\\$\\$[a-zA-Z]([a-zA-Z0-9])*", "name": "support.constant" }]
117+
"patterns": [{ "match": "\\$\\$\\$[\\p{Alpha}]([\\p{Alnum}])*", "name": "support.constant" }]
118118
},
119119

120120
"comment-line": {

syntaxes/objectscript.tmLanguage.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"scopeName": "source.objectscript",
55
"patterns": [
66
{
7-
"match": "^(ROUTINE)\\s(\\b[a-zA-Z0-9.]+\\b)",
7+
"match": "^(ROUTINE)\\s(\\b[\\p{Alnum}.]+\\b)",
88
"captures": {
99
"1": { "name": "keyword.control" },
1010
"2": { "name": "entity.name.class" }
@@ -141,7 +141,7 @@
141141
"macros": {
142142
"patterns": [
143143
{
144-
"match": "(?i)(#dim)(\\s)(%?[a-zA-Z0-9]+)(\\s)(?:(As)(\\s)(%?[a-zA-Z0-9.]+))?",
144+
"match": "(?i)(#dim)(\\s)(%?[\\p{Alnum}]+)(\\s)(?:(As)(\\s)(%?[\\p{Alnum}.]+))?",
145145
"captures": {
146146
"1": { "name": "meta.preprocessor.dim.objectscript" },
147147
"2": { "name": "whitespace.objectscript" },
@@ -160,7 +160,7 @@
160160
"elements": {
161161
"patterns": [
162162
{
163-
"match": "^([a-zA-Z0-9]+)(\\([^)]*\\))(?:\\s+(public|private))?",
163+
"match": "^([\\p{Alnum}]+)(\\([^)]*\\))(?:\\s+(public|private))?",
164164
"captures": {
165165
"1": { "name": "entity.name.function" },
166166
"2": { "name": "other" },
@@ -177,60 +177,60 @@
177177
}
178178
},
179179
{
180-
"match": "%[a-zA-Z0-9]+",
180+
"match": "%[\\p{Alnum}]+",
181181
"name": "entity.other.attribute-name"
182182
},
183183
{
184-
"match": "[i|r]%[a-zA-Z0-9]+",
184+
"match": "[i|r]%[\\p{Alnum}]+",
185185
"name": "entity.other.attribute-name"
186186
},
187187
{
188188
"match": "[i|r]%\"[^\".]\"",
189189
"name": "entity.other.attribute-name"
190190
},
191191
{
192-
"match": "(\\.{1,2})(%?[a-zA-Z0-9]+)(?=\\()",
192+
"match": "(\\.{1,2})(%?[\\p{Alnum}]+)(?=\\()",
193193
"captures": {
194194
"1": { "name": "punctuation.objectscript" },
195195
"2": { "name": "entity.other.attribute-name" }
196196
}
197197
},
198198
{
199-
"match": "(\\.{1,2})(%?[a-zA-Z0-9]+)(?!\\()",
199+
"match": "(\\.{1,2})(%?[\\p{Alnum}]+)(?!\\()",
200200
"captures": {
201201
"1": { "name": "punctuation.objectscript" },
202202
"2": { "name": "entity.other.attribute-name" }
203203
}
204204
},
205205
{
206-
"match": "(\\.{1,2}#)([a-zA-Z0-9]+)",
206+
"match": "(\\.{1,2}#)([\\p{Alnum}]+)",
207207
"captures": {
208208
"1": { "name": "punctuation.objectscript" },
209209
"2": { "name": "meta.parameter.type.variable" }
210210
}
211211
},
212212
{
213-
"match": "%?[a-zA-Z0-9]+",
213+
"match": "%?[\\p{Alnum}]+",
214214
"name": "variable.name.objectscrip"
215215
},
216216
{
217-
"match": "\\^%?[a-zA-Z0-9]+(\\.[a-zA-Z0-9]+)*",
217+
"match": "\\^%?[\\p{Alnum}]+(\\.[\\p{Alnum}]+)*",
218218
"name": "variable.name.global.objectscrip"
219219
},
220220
{
221-
"match": "(?i)\\$system(.[a-zA-Z0-9]+)*",
221+
"match": "(?i)\\$system(.[\\p{Alnum}]+)*",
222222
"name": "entity.name.function.system.objectscript"
223223
},
224224
{
225-
"match": "\\$[a-zA-Z0-9]+",
225+
"match": "\\$[\\p{Alnum}]+",
226226
"name": "entity.name.function.system.objectscript"
227227
},
228228
{
229-
"match": "\\${2}[a-zA-Z0-9]+",
229+
"match": "\\${2}[\\p{Alnum}]+",
230230
"name": "entity.name.function.local.objectscript"
231231
},
232232
{
233-
"match": "\\${3}[a-zA-Z0-9]+",
233+
"match": "\\${3}[\\p{Alnum}]+",
234234
"name": "meta.preprocessor.objectscript"
235235
}
236236
]

0 commit comments

Comments
 (0)