Skip to content

Commit 33e8236

Browse files
Merge pull request dotnet#81 from filipw/feature/load-r
added support for #load and #r
2 parents 2bc6ca9 + 2f21526 commit 33e8236

File tree

5 files changed

+168
-0
lines changed

5 files changed

+168
-0
lines changed

grammars/csharp.tmLanguage

+68
Original file line numberDiff line numberDiff line change
@@ -6272,6 +6272,14 @@
62726272
<key>include</key>
62736273
<string>#preprocessor-endregion</string>
62746274
</dict>
6275+
<dict>
6276+
<key>include</key>
6277+
<string>#preprocessor-load</string>
6278+
</dict>
6279+
<dict>
6280+
<key>include</key>
6281+
<string>#preprocessor-r</string>
6282+
</dict>
62756283
<dict>
62766284
<key>include</key>
62776285
<string>#preprocessor-line</string>
@@ -6381,6 +6389,66 @@
63816389
</dict>
63826390
</dict>
63836391
</dict>
6392+
<key>preprocessor-load</key>
6393+
<dict>
6394+
<key>begin</key>
6395+
<string>\b(load)\b</string>
6396+
<key>beginCaptures</key>
6397+
<dict>
6398+
<key>1</key>
6399+
<dict>
6400+
<key>name</key>
6401+
<string>keyword.preprocessor.load.cs</string>
6402+
</dict>
6403+
</dict>
6404+
<key>end</key>
6405+
<string>(?=$)</string>
6406+
<key>patterns</key>
6407+
<array>
6408+
<dict>
6409+
<key>match</key>
6410+
<string>\"[^"]*\"</string>
6411+
<key>captures</key>
6412+
<dict>
6413+
<key>0</key>
6414+
<dict>
6415+
<key>name</key>
6416+
<string>string.quoted.double.cs</string>
6417+
</dict>
6418+
</dict>
6419+
</dict>
6420+
</array>
6421+
</dict>
6422+
<key>preprocessor-r</key>
6423+
<dict>
6424+
<key>begin</key>
6425+
<string>\b(r)\b</string>
6426+
<key>beginCaptures</key>
6427+
<dict>
6428+
<key>1</key>
6429+
<dict>
6430+
<key>name</key>
6431+
<string>keyword.preprocessor.r.cs</string>
6432+
</dict>
6433+
</dict>
6434+
<key>end</key>
6435+
<string>(?=$)</string>
6436+
<key>patterns</key>
6437+
<array>
6438+
<dict>
6439+
<key>match</key>
6440+
<string>\"[^"]*\"</string>
6441+
<key>captures</key>
6442+
<dict>
6443+
<key>0</key>
6444+
<dict>
6445+
<key>name</key>
6446+
<string>string.quoted.double.cs</string>
6447+
</dict>
6448+
</dict>
6449+
</dict>
6450+
</array>
6451+
</dict>
63846452
<key>preprocessor-region</key>
63856453
<dict>
63866454
<key>match</key>

grammars/csharp.tmLanguage.cson

+34
Original file line numberDiff line numberDiff line change
@@ -3781,6 +3781,12 @@ repository:
37813781
{
37823782
include: "#preprocessor-endregion"
37833783
}
3784+
{
3785+
include: "#preprocessor-load"
3786+
}
3787+
{
3788+
include: "#preprocessor-r"
3789+
}
37843790
{
37853791
include: "#preprocessor-line"
37863792
}
@@ -3832,6 +3838,34 @@ repository:
38323838
name: "keyword.preprocessor.error.cs"
38333839
"3":
38343840
name: "string.unquoted.preprocessor.message.cs"
3841+
"preprocessor-load":
3842+
begin: "\\b(load)\\b"
3843+
beginCaptures:
3844+
"1":
3845+
name: "keyword.preprocessor.load.cs"
3846+
end: "(?=$)"
3847+
patterns: [
3848+
{
3849+
match: "\\\"[^\"]*\\\""
3850+
captures:
3851+
"0":
3852+
name: "string.quoted.double.cs"
3853+
}
3854+
]
3855+
"preprocessor-r":
3856+
begin: "\\b(r)\\b"
3857+
beginCaptures:
3858+
"1":
3859+
name: "keyword.preprocessor.r.cs"
3860+
end: "(?=$)"
3861+
patterns: [
3862+
{
3863+
match: "\\\"[^\"]*\\\""
3864+
captures:
3865+
"0":
3866+
name: "string.quoted.double.cs"
3867+
}
3868+
]
38353869
"preprocessor-region":
38363870
match: "\\b(region)\\b\\s*(.*)(?=$)"
38373871
captures:

src/csharp.tmLanguage.yml

+22
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,8 @@ repository:
24752475
- include: '#preprocessor-warning-or-error'
24762476
- include: '#preprocessor-region'
24772477
- include: '#preprocessor-endregion'
2478+
- include: '#preprocessor-load'
2479+
- include: '#preprocessor-r'
24782480
- include: '#preprocessor-line'
24792481
- include: '#preprocessor-pragma-warning'
24802482
- include: '#preprocessor-pragma-checksum'
@@ -2509,6 +2511,26 @@ repository:
25092511
'2': { name: keyword.preprocessor.error.cs }
25102512
'3': { name: string.unquoted.preprocessor.message.cs }
25112513

2514+
preprocessor-load:
2515+
begin: \b(load)\b
2516+
beginCaptures:
2517+
'1': { name: keyword.preprocessor.load.cs }
2518+
end: (?=$)
2519+
patterns:
2520+
- match: \"[^"]*\"
2521+
captures:
2522+
'0': { name: string.quoted.double.cs }
2523+
2524+
preprocessor-r:
2525+
begin: \b(r)\b
2526+
beginCaptures:
2527+
'1': { name: keyword.preprocessor.r.cs }
2528+
end: (?=$)
2529+
patterns:
2530+
- match: \"[^"]*\"
2531+
captures:
2532+
'0': { name: string.quoted.double.cs }
2533+
25122534
preprocessor-region:
25132535
match: \b(region)\b\s*(.*)(?=$)
25142536
captures:

test/preprocessor.tests.ts

+42
Original file line numberDiff line numberDiff line change
@@ -672,5 +672,47 @@ public ActionResult Register()
672672
Token.Keywords.Preprocessor.EndIf,
673673
]);
674674
});
675+
676+
it("#load", () => {
677+
const input = "#load";
678+
const tokens = tokenize(input);
679+
680+
tokens.should.deep.equal([
681+
Token.Punctuation.Hash,
682+
Token.Keywords.Preprocessor.Load
683+
]);
684+
});
685+
686+
it(`#load "foo.csx"`, () => {
687+
const input = `#load "foo.csx"`;
688+
const tokens = tokenize(input);
689+
690+
tokens.should.deep.equal([
691+
Token.Punctuation.Hash,
692+
Token.Keywords.Preprocessor.Load,
693+
Token.Literals.String(`"foo.csx"`)
694+
]);
695+
});
696+
697+
it("#r", () => {
698+
const input = "#r";
699+
const tokens = tokenize(input);
700+
701+
tokens.should.deep.equal([
702+
Token.Punctuation.Hash,
703+
Token.Keywords.Preprocessor.R
704+
]);
705+
});
706+
707+
it(`#r "System.Net.dll"`, () => {
708+
const input = `#r "System.Net.dll"`;
709+
const tokens = tokenize(input);
710+
711+
tokens.should.deep.equal([
712+
Token.Punctuation.Hash,
713+
Token.Keywords.Preprocessor.R,
714+
Token.Literals.String(`"System.Net.dll"`)
715+
]);
716+
});
675717
});
676718
});

test/utils/tokenize.ts

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ export namespace Token {
260260
export const Restore = createToken('restore', 'keyword.preprocessor.restore.cs');
261261
export const Undef = createToken('undef', 'keyword.preprocessor.undef.cs');
262262
export const Warning = createToken('warning', 'keyword.preprocessor.warning.cs');
263+
export const R = createToken('r', 'keyword.preprocessor.r.cs');
264+
export const Load = createToken('load', 'keyword.preprocessor.load.cs');
263265
}
264266

265267
export namespace Queries {

0 commit comments

Comments
 (0)