Skip to content

Commit 1681401

Browse files
authored
Update textmate grammar to latest version (#9920)
* Update textmate grammar to latest version This updates the grammar to the latest version from https://github.com/dart-lang/dart-syntax-highlight and regenerates the goldens. (I have another upcoming change, but to simplify reviewing, I didn't want to mix it in with previous updates here) * Remove old reference to new keyword. We don't treat it as a control keyword anymore. * Update NEXT_RELEASE_NOTES.md
1 parent f33f60d commit 1681401

4 files changed

Lines changed: 63 additions & 11 deletions

File tree

packages/devtools_app/assets/dart_syntax.json

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Dart",
3-
"version": "1.4.1",
3+
"version": "1.5.0",
44
"fileTypes": [
55
"dart"
66
],
@@ -60,6 +60,12 @@
6060
{
6161
"include": "#constants-and-special-vars"
6262
},
63+
{
64+
"include": "#class-identifier-with-optional-factory-method"
65+
},
66+
{
67+
"include": "#function-identifier"
68+
},
6369
{
6470
"include": "#operators"
6571
},
@@ -227,14 +233,50 @@
227233
{
228234
"name": "constant.numeric.dart",
229235
"match": "(?<!\\$)\\b((0(x|X)[0-9a-fA-F][0-9a-fA-F_]*)|(([0-9][0-9_]*\\.?[0-9_]*)|(\\.[0-9][0-9_]*))((e|E)(\\+|-)?[0-9][0-9_]*)?)\\b(?!\\$)"
236+
}
237+
]
238+
},
239+
"class-identifier-with-optional-factory-method": {
240+
"patterns": [
241+
{
242+
"match": "(?<!\\$)\\b(bool|num|int|double|dynamic)\\b(?!\\$)\\s*(factory\\b)?",
243+
"captures": {
244+
"1": {
245+
"name": "support.class.dart"
246+
},
247+
"2": {
248+
"name": "entity.name.function.dart"
249+
}
250+
}
230251
},
231252
{
232-
"include": "#class-identifier"
253+
"match": "(?<!\\$)\\b(void)\\b(?!\\$)\\s*(factory\\b)?",
254+
"captures": {
255+
"1": {
256+
"name": "storage.type.primitive.dart"
257+
},
258+
"2": {
259+
"name": "entity.name.function.dart"
260+
}
261+
}
233262
},
234263
{
235-
"include": "#function-identifier"
264+
"begin": "(?<![a-zA-Z0-9_$])([_$]*[A-Z][a-zA-Z0-9_$]*)\\b\\s*(factory\\b)?",
265+
"end": "(?!<)",
266+
"beginCaptures": {
267+
"1": {
268+
"name": "support.class.dart"
269+
},
270+
"2": {
271+
"name": "entity.name.function.dart"
272+
}
273+
},
274+
"patterns": [
275+
{
276+
"include": "#type-args"
277+
}
278+
]
236279
}
237-
238280
]
239281
},
240282
"class-identifier": {
@@ -279,6 +321,10 @@
279321
]
280322
}
281323
}
324+
},
325+
{
326+
"match": "(?<=\\.)new\\b",
327+
"name": "entity.name.function.dart"
282328
}
283329
]
284330
},
@@ -334,8 +380,8 @@
334380
"match": "(?<!\\$)\\bassert\\b(?!\\$)"
335381
},
336382
{
337-
"name": "keyword.control.new.dart",
338-
"match": "(?<!\\$)\\b(new)\\b(?!\\$)"
383+
"name": "keyword.new.dart",
384+
"match": "(?<![\\$\\.])\\b(new)\\b(?!\\$)"
339385
},
340386
{
341387
"name": "keyword.control.return.dart",
@@ -351,7 +397,7 @@
351397
},
352398
{
353399
"name": "storage.type.primitive.dart",
354-
"match": "(?<!\\$)\\b(?:void|var)\\b(?!\\$)"
400+
"match": "(?<!\\$)\\b(?:var)\\b(?!\\$)"
355401
}
356402
]
357403
},
@@ -408,6 +454,12 @@
408454
{
409455
"include": "#constants-and-special-vars"
410456
},
457+
{
458+
"include": "#class-identifier-with-optional-factory-method"
459+
},
460+
{
461+
"include": "#function-identifier"
462+
},
411463
{
412464
"include": "#strings"
413465
},

packages/devtools_app/lib/src/screens/debugger/syntax_highlighter.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,7 @@ class SyntaxHighlighter {
247247
'keyword.control.catch-exception.dart',
248248
'keyword.control.dart',
249249
'keyword.control.return.dart',
250-
// While 'new' is not a control flow keyword, it uses the control flow
251-
// color scheme so we include it here.
252-
'keyword.control.new.dart',
250+
'keyword.new.dart',
253251
];
254252

255253
const stringScopes = <String>[

packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ TODO: Remove this section if there are not any updates.
3939

4040
* Prevent values from being garbage-collected, while being evaluated.
4141
[#9885](https://github.com/flutter/devtools/pull/9885)
42+
* Update to latest version of the Dart syntax highlighting grammar
43+
[#9920](https://github.com/flutter/devtools/pull/9920).
4244

4345
## Network profiler updates
4446

packages/devtools_app/test/test_infra/goldens/syntax_highlighting/keywords.dart.golden

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410
> var a = new String.fromCharCode(1);
411411
# ^^^ storage.type.primitive.dart
412412
# ^ keyword.operator.assignment.dart
413-
# ^^^ keyword.control.new.dart
413+
# ^^^ keyword.new.dart
414414
# ^^^^^^ support.class.dart
415415
# ^ punctuation.dot.dart
416416
# ^^^^^^^^^^^^ entity.name.function.dart

0 commit comments

Comments
 (0)