Skip to content

Commit cb1394a

Browse files
committed
Re-used the "#type" template for types in field declarations and added test for generic fields.
1 parent f47698f commit cb1394a

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

syntaxes/csharp.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"end": "(?=;)",
7979
"patterns": [
8080
{
81-
"match": "^\\s*((?:(?:private|public|volatile|internal|protected|static|readonly|const)\\s*)*)\\s*([\\w\\s,<>\\[\\]]+?)\\s*([\\w]+)\\s*(?=;|=)",
81+
"match": "^\\s*((?:(?:private|public|volatile|internal|protected|static|readonly|const)\\s*)*)\\s*(.+?)\\s*([\\w]+)\\s*(?=;|=)",
8282
"captures": {
8383
"1" : {
8484
"patterns": [
@@ -88,7 +88,11 @@
8888
]
8989
},
9090
"2" : {
91-
"name": "storage.type.cs"
91+
"patterns": [
92+
{
93+
"include": "#type"
94+
}
95+
]
9296
},
9397
"3": {
9498
"name": "entity.name.variable.cs"

test/syntaxes/field.tests.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,21 @@ public class Tester
2828
tokens.should.contain(Tokens.FieldIdentifier("field123", 6, 18));
2929
});
3030

31+
it("generic", function () {
32+
33+
const input = `
34+
public class Tester
35+
{
36+
private Dictionary< List<T>, Dictionary<T, D>> _field;
37+
}`;
38+
39+
let tokens: Token[] = TokenizerUtil.tokenize(input);
40+
41+
tokens.should.contain(Tokens.StorageModifierKeyword("private", 4, 5));
42+
tokens.should.contain(Tokens.Type("Dictionary< List<T>, Dictionary<T, D>>", 4, 13));
43+
tokens.should.contain(Tokens.FieldIdentifier("_field", 4, 52));
44+
});
45+
3146

3247
it("modifiers", function() {
3348

0 commit comments

Comments
 (0)