Skip to content

Commit adb1097

Browse files
authored
Update syntax highlighting grammar (flutter#4948)
1 parent a33a747 commit adb1097

File tree

5 files changed

+807
-25
lines changed

5 files changed

+807
-25
lines changed

packages/devtools_app/assets/dart_syntax.json

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Dart",
3-
"version": "1.0.1",
3+
"version": "1.1.1",
44
"fileTypes": [
55
"dart"
66
],
@@ -60,6 +60,9 @@
6060
{
6161
"include": "#constants-and-special-vars"
6262
},
63+
{
64+
"include": "#operators"
65+
},
6366
{
6467
"include": "#strings"
6568
}
@@ -234,27 +237,26 @@
234237
"class-identifier": {
235238
"patterns": [
236239
{
237-
"name": "storage.type.primitive.dart",
238-
"match": "\\bvoid\\b"
240+
"match": "(?<!\\$)\\b(bool|num|int|double|dynamic)\\b(?!\\$)",
241+
"name": "support.class.dart"
239242
},
240243
{
241-
"name": "support.class.dart",
242-
"match": "\\b(bool|num|int|double|dynamic)\\b"
244+
"match": "(?<!\\$)\\bvoid\\b(?!\\$)",
245+
"name": "storage.type.primitive.dart"
243246
},
244247
{
245-
"match": "\\b([_$]*[A-Z][a-zA-Z0-9_$]*)(<(?:[a-zA-Z0-9_$<>?]|,\\s*|\\s+extends\\s+)+>)?",
246-
"captures": {
248+
"begin": "(?<![a-zA-Z0-9_$])([_$]*[A-Z][a-zA-Z0-9_$]*)\\b",
249+
"end": "(?!<)",
250+
"beginCaptures": {
247251
"1": {
248252
"name": "support.class.dart"
249-
},
250-
"2": {
251-
"patterns": [
252-
{
253-
"include": "#type-args"
254-
}
255-
]
256253
}
257-
}
254+
},
255+
"patterns": [
256+
{
257+
"include": "#type-args"
258+
}
259+
]
258260
}
259261
]
260262
},
@@ -295,7 +297,7 @@
295297
"include": "#class-identifier"
296298
},
297299
{
298-
"match": "[\\s,]+"
300+
"match": ","
299301
},
300302
{
301303
"name": "keyword.declaration.dart",
@@ -331,8 +333,20 @@
331333
},
332334
{
333335
"name": "keyword.declaration.dart",
334-
"match": "(?<!\\$)\\b(abstract|class|enum|extends|extension|external|factory|implements|get|mixin|native|operator|set|typedef|with|covariant)\\b(?!\\$)"
336+
"match": "(?<!\\$)\\b(abstract|class|enum|extends|extension|external|factory|implements|get(?!\\()|mixin|native|operator|set(?!\\()|typedef|with|covariant)\\b(?!\\$)"
337+
},
338+
{
339+
"name": "storage.modifier.dart",
340+
"match": "(?<!\\$)\\b(static|final|const|required|late)\\b(?!\\$)"
335341
},
342+
{
343+
"name": "storage.type.primitive.dart",
344+
"match": "(?<!\\$)\\b(?:void|var)\\b(?!\\$)"
345+
}
346+
]
347+
},
348+
"operators": {
349+
"patterns": [
336350
{
337351
"name": "keyword.operator.dart",
338352
"match": "(?<!\\$)\\b(is\\!?)\\b(?!\\$)"
@@ -376,14 +390,6 @@
376390
{
377391
"name": "keyword.operator.logical.dart",
378392
"match": "(!|&&|\\|\\|)"
379-
},
380-
{
381-
"name": "storage.modifier.dart",
382-
"match": "(?<!\\$)\\b(static|final|const|required|late)\\b(?!\\$)"
383-
},
384-
{
385-
"name": "storage.type.primitive.dart",
386-
"match": "(?<!\\$)\\b(?:void|var)\\b(?!\\$)"
387393
}
388394
]
389395
},
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
>// Copyright 2022 The Chromium Authors. All rights reserved.
2+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.dart
3+
>// Use of this source code is governed by a BSD-style license that can be
4+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.dart
5+
>// found in the LICENSE file.
6+
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.double-slash.dart
7+
>
8+
>class A {
9+
#^^^^^ keyword.declaration.dart
10+
# ^ support.class.dart
11+
> String get name => '';
12+
# ^^^^^^ support.class.dart
13+
# ^^^ keyword.declaration.dart
14+
# ^^^^ entity.name.function.dart
15+
# ^^ string.interpolated.single.dart
16+
# ^ punctuation.terminator.dart
17+
> set name(String value) {}
18+
# ^^^ keyword.declaration.dart
19+
# ^^^^ entity.name.function.dart
20+
# ^^^^^^ support.class.dart
21+
>
22+
> void method() {}
23+
# ^^^^ storage.type.primitive.dart
24+
# ^^^^^^ entity.name.function.dart
25+
> void get() {}
26+
# ^^^^ storage.type.primitive.dart
27+
# ^^^ entity.name.function.dart
28+
> void set() {}
29+
# ^^^^ storage.type.primitive.dart
30+
# ^^^ entity.name.function.dart
31+
>}
32+
>
33+
>mixin MyMixin<T> on List<T> {}
34+
#^^^^^ keyword.declaration.dart
35+
# ^^^^^^^ support.class.dart
36+
# ^ other.source.dart
37+
# ^ support.class.dart
38+
# ^ other.source.dart
39+
# ^^ keyword.control.catch-exception.dart
40+
# ^^^^ support.class.dart
41+
# ^ other.source.dart
42+
# ^ support.class.dart
43+
# ^ other.source.dart

0 commit comments

Comments
 (0)