diff --git a/grammars/csharp.tmLanguage b/grammars/csharp.tmLanguage index e1933b87..adfb25d5 100644 --- a/grammars/csharp.tmLanguage +++ b/grammars/csharp.tmLanguage @@ -5094,7 +5094,7 @@ <array> <dict> <key>include</key> - <string>#expression</string> + <string>#argument</string> </dict> </array> </dict> diff --git a/grammars/csharp.tmLanguage.cson b/grammars/csharp.tmLanguage.cson index 5af2ae67..2e8769f9 100644 --- a/grammars/csharp.tmLanguage.cson +++ b/grammars/csharp.tmLanguage.cson @@ -3053,7 +3053,7 @@ repository: end: "(?=(,|\\)|\\]))" patterns: [ { - include: "#expression" + include: "#argument" } ] argument: diff --git a/src/csharp.tmLanguage.yml b/src/csharp.tmLanguage.yml index c9eb94f5..6b9247cb 100644 --- a/src/csharp.tmLanguage.yml +++ b/src/csharp.tmLanguage.yml @@ -1958,7 +1958,7 @@ repository: '2': { name: punctuation.separator.colon.cs } end: (?=(,|\)|\])) patterns: - - include: '#expression' + - include: '#argument' argument: patterns: diff --git a/test/expressions.tests.ts b/test/expressions.tests.ts index c115b611..373f6860 100644 --- a/test/expressions.tests.ts +++ b/test/expressions.tests.ts @@ -1354,6 +1354,44 @@ class C ]); }); + it("named ref argument", () => { + const input = Input.InMethod(`var o = P[x: ref y];`); + const tokens = tokenize(input); + + tokens.should.deep.equal([ + Token.Keywords.Var, + Token.Identifiers.LocalName("o"), + Token.Operators.Assignment, + Token.Variables.Property("P"), + Token.Punctuation.OpenBracket, + Token.Identifiers.ParameterName("x"), + Token.Punctuation.Colon, + Token.Keywords.Modifiers.Ref, + Token.Variables.ReadWrite("y"), + Token.Punctuation.CloseBracket, + Token.Punctuation.Semicolon + ]); + }); + + it("named out argument", () => { + const input = Input.InMethod(`var o = P[x: out y];`); + const tokens = tokenize(input); + + tokens.should.deep.equal([ + Token.Keywords.Var, + Token.Identifiers.LocalName("o"), + Token.Operators.Assignment, + Token.Variables.Property("P"), + Token.Punctuation.OpenBracket, + Token.Identifiers.ParameterName("x"), + Token.Punctuation.Colon, + Token.Keywords.Modifiers.Out, + Token.Variables.ReadWrite("y"), + Token.Punctuation.CloseBracket, + Token.Punctuation.Semicolon + ]); + }); + it("member of generic with no arguments", () => { const input = Input.InMethod(`var o = C<int>.P[];`); const tokens = tokenize(input); @@ -1758,6 +1796,38 @@ long total = (data["bonusGame"]["win"].AsLong) * data["bonusGame"]["betMult"].As ]); }); + it("named ref argument", () => { + const input = Input.InMethod(`M(x: ref y);`); + const tokens = tokenize(input); + + tokens.should.deep.equal([ + Token.Identifiers.MethodName("M"), + Token.Punctuation.OpenParen, + Token.Identifiers.ParameterName("x"), + Token.Punctuation.Colon, + Token.Keywords.Modifiers.Ref, + Token.Variables.ReadWrite("y"), + Token.Punctuation.CloseParen, + Token.Punctuation.Semicolon + ]); + }); + + it("named out argument", () => { + const input = Input.InMethod(`M(x: out y);`); + const tokens = tokenize(input); + + tokens.should.deep.equal([ + Token.Identifiers.MethodName("M"), + Token.Punctuation.OpenParen, + Token.Identifiers.ParameterName("x"), + Token.Punctuation.Colon, + Token.Keywords.Modifiers.Out, + Token.Variables.ReadWrite("y"), + Token.Punctuation.CloseParen, + Token.Punctuation.Semicolon + ]); + }); + it("generic with no arguments", () => { const input = Input.InMethod(`M<int>();`); const tokens = tokenize(input);