Skip to content

Commit 9ef19ad

Browse files
Allow invocation expressions to have space before open parenthesis
1 parent d66b773 commit 9ef19ad

File tree

4 files changed

+60
-5
lines changed

4 files changed

+60
-5
lines changed

grammars/csharp.tmLanguage

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,11 @@
425425
</dict>
426426
<dict>
427427
<key>include</key>
428-
<string>#member-access-expression</string>
428+
<string>#invocation-expression</string>
429429
</dict>
430430
<dict>
431431
<key>include</key>
432-
<string>#invocation-expression</string>
432+
<string>#member-access-expression</string>
433433
</dict>
434434
<dict>
435435
<key>include</key>

grammars/csharp.tmLanguage.cson

+2-2
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,10 @@ repository:
301301
include: "#anonymous-object-creation-expression"
302302
}
303303
{
304-
include: "#member-access-expression"
304+
include: "#invocation-expression"
305305
}
306306
{
307-
include: "#invocation-expression"
307+
include: "#member-access-expression"
308308
}
309309
{
310310
include: "#element-access-expression"

src/csharp.tmLanguage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ repository:
121121
- include: '#object-creation-expression'
122122
- include: '#array-creation-expression'
123123
- include: '#anonymous-object-creation-expression'
124-
- include: '#member-access-expression'
125124
- include: '#invocation-expression'
125+
- include: '#member-access-expression'
126126
- include: '#element-access-expression'
127127
- include: '#cast-expression'
128128
- include: '#literal'

test/expressions.tests.ts

+55
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,18 @@ long total = (data["bonusGame"]["win"].AsLong) * data["bonusGame"]["betMult"].As
17431743
]);
17441744
});
17451745

1746+
it("no arguments with space (issue #54)", () => {
1747+
const input = Input.InMethod(`M ();`);
1748+
const tokens = tokenize(input);
1749+
1750+
tokens.should.deep.equal([
1751+
Token.Identifiers.MethodName("M"),
1752+
Token.Punctuation.OpenParen,
1753+
Token.Punctuation.CloseParen,
1754+
Token.Punctuation.Semicolon
1755+
]);
1756+
});
1757+
17461758
it("one argument", () => {
17471759
const input = Input.InMethod(`M(42);`);
17481760
const tokens = tokenize(input);
@@ -1756,6 +1768,19 @@ long total = (data["bonusGame"]["win"].AsLong) * data["bonusGame"]["betMult"].As
17561768
]);
17571769
});
17581770

1771+
it("one argument with space (issue #54)", () => {
1772+
const input = Input.InMethod(`M (42);`);
1773+
const tokens = tokenize(input);
1774+
1775+
tokens.should.deep.equal([
1776+
Token.Identifiers.MethodName("M"),
1777+
Token.Punctuation.OpenParen,
1778+
Token.Literals.Numeric.Decimal("42"),
1779+
Token.Punctuation.CloseParen,
1780+
Token.Punctuation.Semicolon
1781+
]);
1782+
});
1783+
17591784
it("two arguments", () => {
17601785
const input = Input.InMethod(`M(19, 23);`);
17611786
const tokens = tokenize(input);
@@ -2000,6 +2025,36 @@ long total = (data["bonusGame"]["win"].AsLong) * data["bonusGame"]["betMult"].As
20002025
]);
20012026
});
20022027

2028+
it("qualified method with no arguments and space 1 (issue #54)", () => {
2029+
const input = Input.InMethod(`N.C.M ();`);
2030+
const tokens = tokenize(input);
2031+
2032+
tokens.should.deep.equal([
2033+
Token.Variables.Object("N"),
2034+
Token.Punctuation.Accessor,
2035+
Token.Variables.Property("C"),
2036+
Token.Punctuation.Accessor,
2037+
Token.Identifiers.MethodName("M"),
2038+
Token.Punctuation.OpenParen,
2039+
Token.Punctuation.CloseParen,
2040+
Token.Punctuation.Semicolon
2041+
]);
2042+
});
2043+
2044+
it("qualified method with no arguments and space 2 (issue #54)", () => {
2045+
const input = Input.InMethod(`C.M ();`);
2046+
const tokens = tokenize(input);
2047+
2048+
tokens.should.deep.equal([
2049+
Token.Variables.Object("C"),
2050+
Token.Punctuation.Accessor,
2051+
Token.Identifiers.MethodName("M"),
2052+
Token.Punctuation.OpenParen,
2053+
Token.Punctuation.CloseParen,
2054+
Token.Punctuation.Semicolon
2055+
]);
2056+
});
2057+
20032058
it("store result of this.qualified method with no arguments", () => {
20042059
const input = Input.InMethod(`var o = this.C.M();`);
20052060
const tokens = tokenize(input);

0 commit comments

Comments
 (0)