Skip to content

Commit 8398aed

Browse files
committed
Support the app directives used in file-based programs
1 parent 6db5edb commit 8398aed

File tree

5 files changed

+389
-2
lines changed

5 files changed

+389
-2
lines changed

grammars/csharp.tmLanguage

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8620,6 +8620,10 @@
86208620
<key>include</key>
86218621
<string>#preprocessor-pragma-checksum</string>
86228622
</dict>
8623+
<dict>
8624+
<key>include</key>
8625+
<string>#preprocessor-app-directive</string>
8626+
</dict>
86238627
</array>
86248628
</dict>
86258629
<key>preprocessor-define-or-undef</key>
@@ -8950,6 +8954,142 @@
89508954
</dict>
89518955
</dict>
89528956
</dict>
8957+
<key>preprocessor-app-directive</key>
8958+
<dict>
8959+
<key>begin</key>
8960+
<string>\s*(:)\s*</string>
8961+
<key>beginCaptures</key>
8962+
<dict>
8963+
<key>1</key>
8964+
<dict>
8965+
<key>name</key>
8966+
<string>punctuation.separator.colon.cs</string>
8967+
</dict>
8968+
</dict>
8969+
<key>end</key>
8970+
<string>(?=$)</string>
8971+
<key>patterns</key>
8972+
<array>
8973+
<dict>
8974+
<key>include</key>
8975+
<string>#preprocessor-app-directive-package</string>
8976+
</dict>
8977+
<dict>
8978+
<key>include</key>
8979+
<string>#preprocessor-app-directive-property</string>
8980+
</dict>
8981+
<dict>
8982+
<key>include</key>
8983+
<string>#preprocessor-app-directive-project</string>
8984+
</dict>
8985+
<dict>
8986+
<key>include</key>
8987+
<string>#preprocessor-app-directive-sdk</string>
8988+
</dict>
8989+
</array>
8990+
</dict>
8991+
<key>preprocessor-app-directive-package</key>
8992+
<dict>
8993+
<key>match</key>
8994+
<string>\b(package)\b\s*([_[:alpha:]][_.[:alnum:]]*)?(@)?(.*)?\s*</string>
8995+
<key>captures</key>
8996+
<dict>
8997+
<key>1</key>
8998+
<dict>
8999+
<key>name</key>
9000+
<string>keyword.preprocessor.package.cs</string>
9001+
</dict>
9002+
<key>2</key>
9003+
<dict>
9004+
<key>name</key>
9005+
<string>entity.name.variable.preprocessor.symbol.cs</string>
9006+
</dict>
9007+
<key>3</key>
9008+
<dict>
9009+
<key>name</key>
9010+
<string>punctuation.separator.at.cs</string>
9011+
</dict>
9012+
<key>4</key>
9013+
<dict>
9014+
<key>name</key>
9015+
<string>string.unquoted.preprocessor.message.cs</string>
9016+
</dict>
9017+
</dict>
9018+
</dict>
9019+
<key>preprocessor-app-directive-property</key>
9020+
<dict>
9021+
<key>match</key>
9022+
<string>\b(property)\b\s*([_[:alpha:]][_[:alnum:]]*)?(=)?(.*)?\s*</string>
9023+
<key>captures</key>
9024+
<dict>
9025+
<key>1</key>
9026+
<dict>
9027+
<key>name</key>
9028+
<string>keyword.preprocessor.property.cs</string>
9029+
</dict>
9030+
<key>2</key>
9031+
<dict>
9032+
<key>name</key>
9033+
<string>entity.name.variable.preprocessor.symbol.cs</string>
9034+
</dict>
9035+
<key>3</key>
9036+
<dict>
9037+
<key>name</key>
9038+
<string>punctuation.separator.equals.cs</string>
9039+
</dict>
9040+
<key>4</key>
9041+
<dict>
9042+
<key>name</key>
9043+
<string>string.unquoted.preprocessor.message.cs</string>
9044+
</dict>
9045+
</dict>
9046+
</dict>
9047+
<key>preprocessor-app-directive-project</key>
9048+
<dict>
9049+
<key>match</key>
9050+
<string>\b(project)\b\s*(.*)?\s*</string>
9051+
<key>captures</key>
9052+
<dict>
9053+
<key>1</key>
9054+
<dict>
9055+
<key>name</key>
9056+
<string>keyword.preprocessor.project.cs</string>
9057+
</dict>
9058+
<key>2</key>
9059+
<dict>
9060+
<key>name</key>
9061+
<string>string.unquoted.preprocessor.message.cs</string>
9062+
</dict>
9063+
</dict>
9064+
</dict>
9065+
<key>preprocessor-app-directive-sdk</key>
9066+
<dict>
9067+
<key>match</key>
9068+
<string>\b(sdk)\b\s*([_[:alpha:]][_.[:alnum:]]*)?(@)?(.*)?\s*</string>
9069+
<key>captures</key>
9070+
<dict>
9071+
<key>1</key>
9072+
<dict>
9073+
<key>name</key>
9074+
<string>keyword.preprocessor.sdk.cs</string>
9075+
</dict>
9076+
<key>2</key>
9077+
<dict>
9078+
<key>name</key>
9079+
<string>entity.name.variable.preprocessor.symbol.cs</string>
9080+
</dict>
9081+
<key>3</key>
9082+
<dict>
9083+
<key>name</key>
9084+
<string>punctuation.separator.at.cs</string>
9085+
</dict>
9086+
<key>4</key>
9087+
<dict>
9088+
<key>name</key>
9089+
<string>string.unquoted.preprocessor.message.cs</string>
9090+
</dict>
9091+
</dict>
9092+
</dict>
89539093
<key>preprocessor-expression</key>
89549094
<dict>
89559095
<key>patterns</key>

grammars/csharp.tmLanguage.cson

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5201,6 +5201,9 @@ repository:
52015201
{
52025202
include: "#preprocessor-pragma-checksum"
52035203
}
5204+
{
5205+
include: "#preprocessor-app-directive"
5206+
}
52045207
]
52055208
"preprocessor-define-or-undef":
52065209
match: "\\b(?:(define)|(undef))\\b\\s*\\b([_[:alpha:]][_[:alnum:]]*)\\b"
@@ -5347,6 +5350,66 @@ repository:
53475350
name: "string.quoted.double.cs"
53485351
"5":
53495352
name: "string.quoted.double.cs"
5353+
"preprocessor-app-directive":
5354+
begin: "\\s*(:)\\s*"
5355+
beginCaptures:
5356+
"1":
5357+
name: "punctuation.separator.colon.cs"
5358+
end: "(?=$)"
5359+
patterns: [
5360+
{
5361+
include: "#preprocessor-app-directive-package"
5362+
}
5363+
{
5364+
include: "#preprocessor-app-directive-property"
5365+
}
5366+
{
5367+
include: "#preprocessor-app-directive-project"
5368+
}
5369+
{
5370+
include: "#preprocessor-app-directive-sdk"
5371+
}
5372+
]
5373+
"preprocessor-app-directive-package":
5374+
match: "\\b(package)\\b\\s*([_[:alpha:]][_.[:alnum:]]*)?(@)?(.*)?\\s*"
5375+
captures:
5376+
"1":
5377+
name: "keyword.preprocessor.package.cs"
5378+
"2":
5379+
name: "entity.name.variable.preprocessor.symbol.cs"
5380+
"3":
5381+
name: "punctuation.separator.at.cs"
5382+
"4":
5383+
name: "string.unquoted.preprocessor.message.cs"
5384+
"preprocessor-app-directive-property":
5385+
match: "\\b(property)\\b\\s*([_[:alpha:]][_[:alnum:]]*)?(=)?(.*)?\\s*"
5386+
captures:
5387+
"1":
5388+
name: "keyword.preprocessor.property.cs"
5389+
"2":
5390+
name: "entity.name.variable.preprocessor.symbol.cs"
5391+
"3":
5392+
name: "punctuation.separator.equals.cs"
5393+
"4":
5394+
name: "string.unquoted.preprocessor.message.cs"
5395+
"preprocessor-app-directive-project":
5396+
match: "\\b(project)\\b\\s*(.*)?\\s*"
5397+
captures:
5398+
"1":
5399+
name: "keyword.preprocessor.project.cs"
5400+
"2":
5401+
name: "string.unquoted.preprocessor.message.cs"
5402+
"preprocessor-app-directive-sdk":
5403+
match: "\\b(sdk)\\b\\s*([_[:alpha:]][_.[:alnum:]]*)?(@)?(.*)?\\s*"
5404+
captures:
5405+
"1":
5406+
name: "keyword.preprocessor.sdk.cs"
5407+
"2":
5408+
name: "entity.name.variable.preprocessor.symbol.cs"
5409+
"3":
5410+
name: "punctuation.separator.at.cs"
5411+
"4":
5412+
name: "string.unquoted.preprocessor.message.cs"
53505413
"preprocessor-expression":
53515414
patterns: [
53525415
{

src/csharp.tmLanguage.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,6 +3388,7 @@ repository:
33883388
- include: '#preprocessor-line'
33893389
- include: '#preprocessor-pragma-warning'
33903390
- include: '#preprocessor-pragma-checksum'
3391+
- include: '#preprocessor-app-directive'
33913392

33923393
preprocessor-define-or-undef:
33933394
match: \b(?:(define)|(undef))\b\s*\b([_[:alpha:]][_[:alnum:]]*)\b
@@ -3490,6 +3491,47 @@ repository:
34903491
'4': { name: string.quoted.double.cs }
34913492
'5': { name: string.quoted.double.cs }
34923493

3494+
preprocessor-app-directive:
3495+
begin: \s*(:)\s*
3496+
beginCaptures:
3497+
'1': { name: punctuation.separator.colon.cs }
3498+
end: (?=$)
3499+
patterns:
3500+
- include: '#preprocessor-app-directive-package'
3501+
- include: '#preprocessor-app-directive-property'
3502+
- include: '#preprocessor-app-directive-project'
3503+
- include: '#preprocessor-app-directive-sdk'
3504+
3505+
preprocessor-app-directive-package:
3506+
match: \b(package)\b\s*([_[:alpha:]][_.[:alnum:]]*)?(@)?(.*)?\s*
3507+
captures:
3508+
'1': { name: keyword.preprocessor.package.cs }
3509+
'2': { name: entity.name.variable.preprocessor.symbol.cs }
3510+
'3': { name: punctuation.separator.at.cs }
3511+
'4': { name: string.unquoted.preprocessor.message.cs }
3512+
3513+
preprocessor-app-directive-property:
3514+
match: \b(property)\b\s*([_[:alpha:]][_[:alnum:]]*)?(=)?(.*)?\s*
3515+
captures:
3516+
'1': { name: keyword.preprocessor.property.cs }
3517+
'2': { name: entity.name.variable.preprocessor.symbol.cs }
3518+
'3': { name: punctuation.separator.equals.cs }
3519+
'4': { name: string.unquoted.preprocessor.message.cs }
3520+
3521+
preprocessor-app-directive-project:
3522+
match: \b(project)\b\s*(.*)?\s*
3523+
captures:
3524+
'1': { name: keyword.preprocessor.project.cs }
3525+
'2': { name: string.unquoted.preprocessor.message.cs }
3526+
3527+
preprocessor-app-directive-sdk:
3528+
match: \b(sdk)\b\s*([_[:alpha:]][_.[:alnum:]]*)?(@)?(.*)?\s*
3529+
captures:
3530+
'1': { name: keyword.preprocessor.sdk.cs }
3531+
'2': { name: entity.name.variable.preprocessor.symbol.cs }
3532+
'3': { name: punctuation.separator.at.cs }
3533+
'4': { name: string.unquoted.preprocessor.message.cs }
3534+
34933535
preprocessor-expression:
34943536
patterns:
34953537
- begin: \(

0 commit comments

Comments
 (0)