Skip to content

Commit 6b2838c

Browse files
committed
Dart port of syntax highlighting
1 parent 03ab3a6 commit 6b2838c

File tree

7 files changed

+121
-0
lines changed

7 files changed

+121
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"scopeName": "inline.graphql.dart",
3+
"injectionSelector": "L:(meta.embedded.block.dart | source.dart -string -comment)",
4+
"patterns": [
5+
{
6+
"begin": "(''')(#graphql)",
7+
"beginCaptures": {
8+
"1": {
9+
"name": "string.interpolated.triple.single.dart"
10+
},
11+
"2": {
12+
"name": "comment.line.graphql.js"
13+
}
14+
},
15+
"end": "(''')",
16+
"endCaptures": {
17+
"1": {
18+
"name": "string.interpolated.triple.single.dart"
19+
}
20+
},
21+
"patterns": [
22+
{
23+
"include": "source.graphql"
24+
}
25+
]
26+
},
27+
{
28+
"begin": "(\"\"\")(#graphql)",
29+
"beginCaptures": {
30+
"1": {
31+
"name": "string.interpolated.triple.double.dart"
32+
},
33+
"2": {
34+
"name": "comment.line.graphql.js"
35+
}
36+
},
37+
"end": "(\"\"\")",
38+
"endCaptures": {
39+
"1": {
40+
"name": "string.interpolated.triple.double.dart"
41+
}
42+
},
43+
"patterns": [
44+
{
45+
"include": "source.graphql"
46+
}
47+
]
48+
}
49+
]
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const test = """#graphql
2+
3+
""";
4+
5+
const tet = '''#graphql
6+
''';

packages/vscode-graphql-syntax/package.json

+11
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@
136136
"embeddedLanguages": {
137137
"meta.embedded.block.graphql": "graphql"
138138
}
139+
},
140+
{
141+
"injectTo": [
142+
"source.dart",
143+
"text.html.markdown"
144+
],
145+
"scopeName": "inline.graphql.dart",
146+
"path": "./grammars/graphql.dart.json",
147+
"embeddedLanguages": {
148+
"meta.embedded.block.graphql": "graphql"
149+
}
139150
}
140151
]
141152
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const query1 = '''#graphql
2+
query {
3+
id
4+
}
5+
''';
6+
7+
const query2 = """#graphql
8+
query {
9+
id
10+
}
11+
""";

packages/vscode-graphql-syntax/tests/__fixtures__/test.py

+1
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@
6161
name
6262
}
6363
}"""
64+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2+
3+
exports[`inline.graphql.dart grammar > should tokenize a simple dart file 1`] = `
4+
const query1 = |
5+
''' | string.interpolated.triple.single.dart
6+
#graphql | comment.line.graphql.js
7+
|
8+
query | keyword.operation.graphql
9+
| meta.selectionset.graphql
10+
{ | meta.selectionset.graphql punctuation.operation.graphql
11+
| meta.selectionset.graphql
12+
id | meta.selectionset.graphql variable.graphql
13+
| meta.selectionset.graphql
14+
} | meta.selectionset.graphql punctuation.operation.graphql
15+
''' | string.interpolated.triple.single.dart
16+
; |
17+
|
18+
const query2 = |
19+
""" | string.interpolated.triple.double.dart
20+
#graphql | comment.line.graphql.js
21+
|
22+
query | keyword.operation.graphql
23+
| meta.selectionset.graphql
24+
{ | meta.selectionset.graphql punctuation.operation.graphql
25+
| meta.selectionset.graphql
26+
id | meta.selectionset.graphql variable.graphql
27+
| meta.selectionset.graphql
28+
} | meta.selectionset.graphql punctuation.operation.graphql
29+
""" | string.interpolated.triple.double.dart
30+
; |
31+
|
32+
`;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { tokenizeFile } from './__utilities__/utilities';
2+
3+
describe('inline.graphql.dart grammar', () => {
4+
const scope = 'inline.graphql.dart';
5+
6+
it('should tokenize a simple dart file', async () => {
7+
const result = await tokenizeFile('__fixtures__/test.dart', scope);
8+
expect(result).toMatchSnapshot();
9+
});
10+
});

0 commit comments

Comments
 (0)