Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix out argument declaration #274

Merged
merged 1 commit into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions grammars/csharp.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -6872,11 +6872,32 @@
<key>name</key>
<string>storage.modifier.cs</string>
<key>match</key>
<string>\b(ref|out|in)\b</string>
<string>\b(ref|in)\b</string>
</dict>
<dict>
<key>include</key>
<string>#declaration-expression-local</string>
<key>begin</key>
<string>\b(out)\b</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.modifier.cs</string>
</dict>
</dict>
<key>end</key>
<string>(?=,|\)|\])</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#declaration-expression-local</string>
</dict>
<dict>
<key>include</key>
<string>#expression</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
Expand Down
16 changes: 14 additions & 2 deletions grammars/csharp.tmLanguage.cson
Original file line number Diff line number Diff line change
Expand Up @@ -4141,10 +4141,22 @@ repository:
patterns: [
{
name: "storage.modifier.cs"
match: "\\b(ref|out|in)\\b"
match: "\\b(ref|in)\\b"
}
{
include: "#declaration-expression-local"
begin: "\\b(out)\\b"
beginCaptures:
"1":
name: "storage.modifier.cs"
end: "(?=,|\\)|\\])"
patterns: [
{
include: "#declaration-expression-local"
}
{
include: "#expression"
}
]
}
{
include: "#expression"
Expand Down
10 changes: 8 additions & 2 deletions src/csharp.tmLanguage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2753,8 +2753,14 @@ repository:
argument:
patterns:
- name: storage.modifier.cs
match: \b(ref|out|in)\b
- include: '#declaration-expression-local'
match: \b(ref|in)\b
- begin: \b(out)\b
beginCaptures:
'1': { name: storage.modifier.cs }
end: (?=,|\)|\])
patterns:
- include: '#declaration-expression-local'
- include: '#expression'
- include: '#expression'

query-expression:
Expand Down
41 changes: 0 additions & 41 deletions test/expressions.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2112,28 +2112,6 @@ var result = list.Select(l => new {
]);
});

it("in argument declaration", async () => {
const input = Input.InMethod(`var o = P[in int x, in var y];`);
const tokens = await tokenize(input);

tokens.should.deep.equal([
Token.Keywords.Var,
Token.Identifiers.LocalName("o"),
Token.Operators.Assignment,
Token.Variables.Property("P"),
Token.Punctuation.OpenBracket,
Token.Keywords.Modifiers.In,
Token.PrimitiveType.Int,
Token.Identifiers.LocalName("x"),
Token.Punctuation.Comma,
Token.Keywords.Modifiers.In,
Token.Keywords.Var,
Token.Identifiers.LocalName("y"),
Token.Punctuation.CloseBracket,
Token.Punctuation.Semicolon
]);
});

it("member of generic with no arguments", async () => {
const input = Input.InMethod(`var o = C<int>.P[];`);
const tokens = await tokenize(input);
Expand Down Expand Up @@ -2644,25 +2622,6 @@ long total = (data["bonusGame"]["win"].AsLong) * data["bonusGame"]["betMult"].As
]);
});

it("in argument declaration", async () => {
const input = Input.InMethod(`M(in int x, in var y);`);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't do this... Also it doesn't make sense to pass a reference to nothing.

const tokens = await tokenize(input);

tokens.should.deep.equal([
Token.Identifiers.MethodName("M"),
Token.Punctuation.OpenParen,
Token.Keywords.Modifiers.In,
Token.PrimitiveType.Int,
Token.Identifiers.LocalName("x"),
Token.Punctuation.Comma,
Token.Keywords.Modifiers.In,
Token.Keywords.Var,
Token.Identifiers.LocalName("y"),
Token.Punctuation.CloseParen,
Token.Punctuation.Semicolon
]);
});

it("generic with no arguments", async () => {
const input = Input.InMethod(`M<int>();`);
const tokens = await tokenize(input);
Expand Down
Loading