Skip to content

Commit 965478e

Browse files
committed
Add generic app directive catch all
1 parent c77d048 commit 965478e

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed

grammars/csharp.tmLanguage

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8986,6 +8986,10 @@
89868986
<key>include</key>
89878987
<string>#preprocessor-app-directive-sdk</string>
89888988
</dict>
8989+
<dict>
8990+
<key>include</key>
8991+
<string>#preprocessor-app-directive-generic</string>
8992+
</dict>
89898993
</array>
89908994
</dict>
89918995
<key>preprocessor-app-directive-package</key>
@@ -9129,6 +9133,19 @@
91299133
</dict>
91309134
</array>
91319135
</dict>
9136+
<key>preprocessor-app-directive-generic</key>
9137+
<dict>
9138+
<key>match</key>
9139+
<string>\b(.*)?\s*</string>
9140+
<key>captures</key>
9141+
<dict>
9142+
<key>1</key>
9143+
<dict>
9144+
<key>name</key>
9145+
<string>string.unquoted.preprocessor.message.cs</string>
9146+
</dict>
9147+
</dict>
9148+
</dict>
91329149
<key>preprocessor-expression</key>
91339150
<dict>
91349151
<key>patterns</key>

grammars/csharp.tmLanguage.cson

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5369,6 +5369,9 @@ repository:
53695369
{
53705370
include: "#preprocessor-app-directive-sdk"
53715371
}
5372+
{
5373+
include: "#preprocessor-app-directive-generic"
5374+
}
53725375
]
53735376
"preprocessor-app-directive-package":
53745377
match: "\\b(package)\\b\\s*([_[:alpha:]][_.[:alnum:]]*)?(@)?(.*)?\\s*"
@@ -5433,6 +5436,11 @@ repository:
54335436
match: "[_[:alpha:]][_[:alnum:]]*"
54345437
}
54355438
]
5439+
"preprocessor-app-directive-generic":
5440+
match: "\\b(.*)?\\s*"
5441+
captures:
5442+
"1":
5443+
name: "string.unquoted.preprocessor.message.cs"
54365444
"preprocessor-expression":
54375445
patterns: [
54385446
{

src/csharp.tmLanguage.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,6 +3501,7 @@ repository:
35013501
- include: '#preprocessor-app-directive-property'
35023502
- include: '#preprocessor-app-directive-project'
35033503
- include: '#preprocessor-app-directive-sdk'
3504+
- include: '#preprocessor-app-directive-generic'
35043505

35053506
preprocessor-app-directive-package:
35063507
match: \b(package)\b\s*([_[:alpha:]][_.[:alnum:]]*)?(@)?(.*)?\s*
@@ -3545,6 +3546,11 @@ repository:
35453546
- name: entity.name.variable.preprocessor.symbol.cs
35463547
match: '[_[:alpha:]][_[:alnum:]]*'
35473548

3549+
preprocessor-app-directive-generic:
3550+
match: \b(.*)?\s*
3551+
captures:
3552+
'1': { name: string.unquoted.preprocessor.message.cs }
3553+
35483554
preprocessor-expression:
35493555
patterns:
35503556
- begin: \(

test/preprocessor.tests.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,5 +839,26 @@ public ActionResult Register()
839839
Token.PreprocessorMessage("1.0.0"),
840840
]);
841841
});
842+
843+
it("#:", async () => {
844+
const input = `#:`;
845+
const tokens = await tokenize(input);
846+
847+
tokens.should.deep.equal([
848+
Token.Punctuation.Hash,
849+
Token.Punctuation.Colon,
850+
]);
851+
});
852+
853+
it("#: with generic message", async () => {
854+
const input = `#:this is a generic directive`;
855+
const tokens = await tokenize(input);
856+
857+
tokens.should.deep.equal([
858+
Token.Punctuation.Hash,
859+
Token.Punctuation.Colon,
860+
Token.PreprocessorMessage("this is a generic directive"),
861+
]);
862+
});
842863
});
843864
});

0 commit comments

Comments
 (0)