Skip to content

Commit 344be70

Browse files
author
Raul E Rangel
committed
Merge remote-tracking branch 'upstream/master' into fix-1830
2 parents 4e533b9 + 4b85d3f commit 344be70

File tree

74 files changed

+17952
-4870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+17952
-4870
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
run_syntax_tests:
3030
name: Test on Build ${{ matrix.sublime-build }} (${{ matrix.sublime-channel }})
3131
runs-on: ubuntu-latest
32+
timeout-minutes: 15 # default is 6 hours!
3233
continue-on-error: ${{ matrix.optional }}
3334
strategy:
3435
max-parallel: 2
@@ -39,7 +40,7 @@ jobs:
3940
sublime-build: 4121
4041
optional: true
4142
- sublime-channel: dev
42-
sublime-build: 4120
43+
sublime-build: 4122
4344
optional: false
4445
steps:
4546

C#/C#.sublime-syntax

Lines changed: 49 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ contexts:
174174
- include: comments
175175
- match: $
176176
pop: true
177+
- match: '\b(nullable)\s+(enable|disable|restore)(?:\s+(annotations|warnings))?\b'
178+
captures:
179+
1: keyword.other.preprocessor.cs
180+
2: keyword.other.preprocessor.cs
181+
3: keyword.other.preprocessor.cs
177182
- match: .*
178183
scope: invalid.illegal.cs
179184
- match: $
@@ -216,6 +221,8 @@ contexts:
216221
scope: invalid.illegal.stray.brace.cs
217222

218223
using:
224+
- match: \bglobal\b
225+
scope: storage.modifier.cs
219226
- match: '\b(using)\s+(?={{name}}\s*=\s*)'
220227
captures:
221228
1: keyword.control.import.cs
@@ -243,7 +250,7 @@ contexts:
243250
- match: '='
244251
scope: keyword.operator.assignment.cs
245252
- match: \.
246-
scope: punctuation.separator.namespace.cs
253+
scope: meta.path.cs punctuation.separator.namespace.cs
247254
- match: '<'
248255
scope: meta.generic.cs punctuation.definition.generic.begin.cs
249256
push: type_argument
@@ -290,10 +297,12 @@ contexts:
290297
1: storage.type.class.cs
291298
2: entity.name.class.cs
292299
push: [class_signature, data_type_signature]
293-
- match: \b(record)\s+({{name}})
300+
- match: (?:\b(readonly)\s+)?\b(record)\s+(?:(struct)\s+)?({{name}})
294301
captures:
295-
1: storage.type.class.record.cs
296-
2: entity.name.class.cs
302+
1: storage.modifier.cs
303+
2: storage.type.class.record.cs
304+
3: storage.type.struct.record.cs
305+
4: entity.name.class.cs
297306
push: [record_signature, data_type_signature]
298307
- match: '(?:\b(readonly)\s+)?(?:\b(ref)\s+)?\b(struct)\s+({{name}})'
299308
captures:
@@ -514,7 +523,7 @@ contexts:
514523
- match: '({{name}})?(\.)'
515524
captures:
516525
1: meta.path.cs
517-
2: punctuation.accessor.dot.namespace.cs
526+
2: meta.path.cs punctuation.accessor.dot.namespace.cs
518527
- match: ','
519528
scope: punctuation.separator.inherited-class.cs
520529

@@ -564,12 +573,12 @@ contexts:
564573
scope: storage.modifier.access.cs
565574
- match: '\boperator\b'
566575
scope: storage.modifier.cs
567-
push: method_name
576+
push: method_name_or_member_variable
568577
- match: '({{name}})\s*(<)'
569578
captures:
570579
1: support.type.cs
571580
2: meta.generic.cs punctuation.definition.generic.begin.cs
572-
push: [method_name, type_argument]
581+
push: [method_name_or_member_variable, type_argument]
573582
- match: '(~{{name}})(\s*)(\()'
574583
captures:
575584
1: meta.method.cs entity.name.function.destructor.cs
@@ -599,11 +608,11 @@ contexts:
599608
5: punctuation.section.brackets.end.cs
600609
6: keyword.operator.pointer.cs
601610
- match: ''
602-
set: method_name
611+
set: method_name_or_member_variable
603612
- match: (?=\()
604-
push: [method_name, type_tuple]
613+
push: [method_name_or_member_variable, type_tuple]
605614

606-
method_name: # also matches member variables
615+
method_name_or_member_variable:
607616
- match: '\.'
608617
scope: punctuation.accessor.dot.cs
609618
- match: '(operator)\s*({{unary_op}}|{{bin_op}})\s*(\()'
@@ -612,31 +621,45 @@ contexts:
612621
2: meta.method.cs entity.name.function.cs
613622
3: meta.method.parameters.cs punctuation.section.parameters.begin.cs
614623
set: [method_body_transition, method_params]
615-
- match: '({{name}}\s*)?((=>)\s*)'
624+
- match: (?={{name}})
625+
branch_point: method_or_member_variable_name
626+
branch:
627+
- member_lambda_or_plain
628+
- method_name
629+
pop: true
630+
631+
member_lambda_or_plain:
632+
- match: ({{name}})\s*(=>)
633+
scope: meta.method.cs
616634
captures:
617635
1: variable.other.member.cs
618-
2: meta.method.cs
619-
3: keyword.declaration.function.accessor.get.cs
636+
2: keyword.declaration.function.accessor.get.cs
620637
set:
621638
- meta_scope: meta.property.cs
622639
- meta_content_scope: meta.method.cs
623640
- include: line_of_code_in
624-
- match: '({{name}})\s*(?==[^>])'
625-
captures:
626-
1: variable.other.member.cs
641+
- match: (?={{namespaced_name}}\s+{{name}}\s+=>)
642+
pop: true
643+
- match: '{{name}}'
644+
scope: variable.other.member.cs
645+
- match: (?==[^>])
627646
set: member_variables_declaration
647+
- match: ';'
648+
scope: punctuation.terminator.statement.cs
649+
pop: true
650+
- match: (?=\})
651+
pop: true
652+
- match: (?=\S)
653+
fail: method_or_member_variable_name
654+
655+
method_name:
628656
- match: '({{name}})?\s*(\()'
629-
# here the name is optionnal since it may already have been match by
657+
# here the name is optional since it may already have been matched by
630658
# '{{name}}\s*(<)' (see rule below)
631659
captures:
632660
1: meta.method.cs entity.name.function.cs
633661
2: meta.method.parameters.cs punctuation.section.parameters.begin.cs
634662
set: [method_body_transition, method_params]
635-
- match: '({{name}})\s*(;)'
636-
captures:
637-
1: variable.other.member.cs
638-
2: punctuation.terminator.statement.cs
639-
pop: true
640663
- match: '({{name}})\s*(<)(?=[^(]*>\.)'
641664
scope: meta.method.cs
642665
captures:
@@ -682,6 +705,9 @@ contexts:
682705
pop: true
683706
- match: '(?=\s*\{)'
684707
set: method_accessor
708+
- match: ';'
709+
scope: punctuation.terminator.statement.cs
710+
pop: true
685711

686712
method_body_transition:
687713
- match: ''
@@ -838,7 +864,7 @@ contexts:
838864

839865
attribute_in:
840866
- meta_scope: meta.annotation.cs
841-
- match: '({{name}})(\()'
867+
- match: '({{name}})\s*(\()'
842868
captures:
843869
1: variable.annotation.cs
844870
2: meta.group.cs punctuation.section.group.begin.cs

C#/tests/syntax_test_C#10.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/// SYNTAX TEST "Packages/C#/C#.sublime-syntax"
2+
3+
global using Newtonsoft.Json;
4+
/// ^^ storage.modifier
5+
/// ^^^^^ keyword.control.import
6+
/// ^^^^^^^^^^^^^^^ meta.path
7+
/// ^ punctuation.separator.namespace
8+
/// ^ punctuation.terminator - meta.path
9+
global using static Console.WriteLine;
10+
/// ^^ storage.modifier
11+
/// ^^^^^ keyword.control.import
12+
/// ^^^^^^ keyword.control.import
13+
/// ^^^^^^^^^^^^^^^^^ meta.path
14+
/// ^ punctuation.separator.namespace
15+
/// ^ punctuation.terminator
16+
17+
namespace Example;
18+
///^^^^^^ meta.namespace storage.type.namespace
19+
/// ^^^^^^^ meta.namespace entity.name.namespace
20+
/// ^ punctuation.terminator.statement
21+
22+
public record struct Person(string Name);
23+
/// ^^ storage.modifier.access
24+
/// ^^^^^^^^^^^^^^^^^^^^ meta.class.record
25+
/// ^^^^^^ storage.type.class.record
26+
/// ^^^^^^ storage.type.struct.record
27+
/// ^^^^^^ entity.name.class
28+
/// ^ punctuation.section.group.begin
29+
/// ^^^^^^^^^^^^ meta.class.body meta.method.parameters
30+
/// ^^^^^^ storage.type
31+
/// ^^^^ variable.parameter
32+
/// ^ punctuation.section.parameters.end
33+
/// ^ punctuation.terminator.statement
34+
35+
public readonly record struct Person(string Name);
36+
///^^^ storage.modifier.access
37+
/// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.record
38+
/// ^^^^^^^^ storage.modifier
39+
/// ^^^^^^ storage.type.class.record
40+
/// ^^^^^^ storage.type.struct.record
41+
/// ^^^^^^ entity.name.class
42+
/// ^ punctuation.section.group.begin
43+
/// ^^^^^^ storage.type
44+
/// ^^^^ variable.parameter
45+
/// ^ punctuation.section.parameters.end
46+
/// ^ punctuation.terminator.statement

C#/tests/syntax_test_C#8.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public struct Point3D
8686
/// ^^^ storage.modifier
8787
/// ^^^^^^^^ storage.modifier
8888
/// ^^^^^^^ support.type
89-
/// ^^^^^^^ variable.other.member
89+
/// ^^^^^^ variable.other.member
9090
/// ^^ keyword.declaration.function.accessor.get
9191
/// ^^^ keyword.other
9292
/// ^^^^^^ variable.other

C#/tests/syntax_test_GeneralStructure.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,21 @@ public virtual ActionResult Process([ModelBinder(typeof(MyModelBinder))]
788788
{
789789
}
790790

791+
[SomeAttribute (Url="//")]
792+
/// ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation - comment
793+
/// ^ punctuation.definition.annotation.begin
794+
/// ^^^^^^^^^^^^^ variable.annotation
795+
/// ^ punctuation.section.group.begin
796+
/// ^^^ variable.parameter
797+
/// ^ keyword.operator.assignment
798+
/// ^^^^ string.quoted.double
799+
/// ^ punctuation.section.group.end
800+
/// ^ punctuation.definition.annotation.end
801+
/// ^ - meta.annotation
802+
void Test() {
803+
}
804+
805+
791806
int Method4 => 5;
792807
/// ^^^ storage.type
793808
/// ^^^^^^^ variable.other.member
@@ -1372,3 +1387,53 @@ public int Counter
13721387
set => counter = value;
13731388
}
13741389
}
1390+
1391+
public class MyClass
1392+
{
1393+
Dictionary<MyEnum, List<uint>> myDict
1394+
/// ^^^^^^^^^^ support.type
1395+
/// ^ punctuation.definition.generic.begin
1396+
/// ^^^^^^ support.type
1397+
/// ^ punctuation.separator.type
1398+
/// ^^^^ support.type
1399+
/// ^ punctuation.definition.generic.begin
1400+
/// ^^^^ storage.type
1401+
/// ^^ punctuation.definition.generic.end
1402+
/// ^^^^^^ variable.other.member
1403+
= new Dictionary<MyEnum, List<uint>>
1404+
/// ^ keyword.operator.assignment.variable
1405+
/// ^^^ keyword.operator.new
1406+
{
1407+
[One] = new List<uint>
1408+
{
1409+
1, 2, 3
1410+
},
1411+
[Two] = new List<uint>
1412+
{
1413+
4, 5, 6
1414+
}
1415+
};
1416+
/// ^ punctuation.section.braces.end - invalid
1417+
/// ^ punctuation.terminator.statement - invalid
1418+
}
1419+
1420+
public class MyClass
1421+
{
1422+
bool var // missing semi-colon
1423+
/// ^^^^ storage.type
1424+
/// ^^^ variable.other.member
1425+
1426+
bool var => return 0;
1427+
/// ^^^^ storage.type
1428+
/// ^^^ variable.other.member
1429+
/// ^^ keyword.declaration.function.accessor.get
1430+
/// ^^^^^^ keyword.other
1431+
/// ^ meta.number.integer.decimal constant.numeric.value
1432+
/// ^ punctuation.terminator.statement
1433+
1434+
bool var // missing semi-colon
1435+
/// ^^^^ storage.type
1436+
/// ^^^ variable.other.member
1437+
}
1438+
/// <- meta.class.body meta.block punctuation.section.block.end
1439+
/// ^ - meta

C#/tests/syntax_test_PreprocessorDirectives.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,25 @@ static void Main()
6868
// ^^^^^ variable.other.section
6969
#endregion
7070
// ^^ storage.type.section
71+
72+
#nullable enable
73+
/// ^^ meta.preprocessor keyword.other.preprocessor
74+
/// ^^ meta.preprocessor keyword.other.preprocessor
75+
76+
#nullable disable
77+
/// ^^ meta.preprocessor keyword.other.preprocessor
78+
/// ^^ meta.preprocessor keyword.other.preprocessor
79+
80+
#nullable restore
81+
/// ^^ meta.preprocessor keyword.other.preprocessor
82+
/// ^^ meta.preprocessor keyword.other.preprocessor
83+
84+
#nullable enable annotations
85+
/// ^^ meta.preprocessor keyword.other.preprocessor
86+
/// ^^ meta.preprocessor keyword.other.preprocessor
87+
/// ^^ meta.preprocessor keyword.other.preprocessor
88+
89+
#nullable disable warnings
90+
/// ^^ meta.preprocessor keyword.other.preprocessor
91+
/// ^^ meta.preprocessor keyword.other.preprocessor
92+
// / ^^ meta.preprocessor keyword.other.preprocessor
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
%YAML 1.2
2+
---
3+
# Syntax based on documentation here:
4+
# https://git-scm.com/docs/gitignore
5+
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
6+
7+
name: Git Code Owners
8+
scope: text.git.codeowners
9+
version: 2
10+
11+
file_extensions:
12+
- CODEOWNERS
13+
14+
contexts:
15+
16+
main:
17+
- include: Git Common.sublime-syntax#comments
18+
# note:
19+
# - ignore whitespace at the beginning of a line
20+
# - patterns may not start with operators: - !
21+
# - escaped hash tags are not supported
22+
- match: '[-!]|\\#|(?=\S)'
23+
scope: invalid.illegal.operator.git.codeowners
24+
push:
25+
- pattern-content
26+
- Git Common.sublime-syntax#fnmatch-start
27+
28+
pattern-content:
29+
- meta_content_scope: meta.path.pattern.git.codeowners entity.name.pattern.git.codeowners
30+
- match: \s+(?=([^\@\s]+)?\@)
31+
set: owners
32+
# note: character classes are not supported
33+
- include: Git Common.sublime-syntax#fnmatch-common
34+
- include: eol-pop
35+
36+
owners:
37+
- meta_content_scope: meta.owners.git.codeowners
38+
- include: Git Common.sublime-syntax#username
39+
- include: emails
40+
- include: eol-pop
41+
42+
emails:
43+
- match: (?=\S)
44+
push:
45+
- Git Common.sublime-syntax#email-meta
46+
- Git Common.sublime-syntax#email-name
47+
48+
eol-pop:
49+
- match: $
50+
pop: 1

0 commit comments

Comments
 (0)