From abb9ff07b02293c79937f5e0719fe3d6d240f91a Mon Sep 17 00:00:00 2001 From: Daniel Jeong Date: Fri, 25 Aug 2023 12:04:10 +0000 Subject: [PATCH] Change query expression keyword scope --- grammars/csharp.tmLanguage | 55 +++++------ grammars/csharp.tmLanguage.cson | 52 +++++------ src/csharp.tmLanguage.yml | 51 +++++------ test/expressions.tests.ts | 142 ++++++++++++++--------------- test/utils/tokenize.ts | 46 +++++----- test/verbatim-indentifier.tests.ts | 60 ++++++------ 6 files changed, 199 insertions(+), 207 deletions(-) diff --git a/grammars/csharp.tmLanguage b/grammars/csharp.tmLanguage index 5b9199f..f4c6ef0 100644 --- a/grammars/csharp.tmLanguage +++ b/grammars/csharp.tmLanguage @@ -514,12 +514,12 @@ 1 name - keyword.directive.extern.cs + keyword.other.directive.extern.cs 2 name - keyword.directive.alias.cs + keyword.other.directive.alias.cs 3 @@ -542,17 +542,17 @@ 2 name - keyword.directive.global.cs + keyword.other.directive.global.cs 3 name - keyword.directive.using.cs + keyword.other.directive.using.cs 4 name - keyword.directive.static.cs + keyword.other.directive.static.cs 6 @@ -578,12 +578,12 @@ 2 name - keyword.directive.global.cs + keyword.other.directive.global.cs 3 name - keyword.directive.using.cs + keyword.other.directive.using.cs 5 @@ -622,12 +622,12 @@ 2 name - keyword.directive.global.cs + keyword.other.directive.global.cs 3 name - keyword.directive.using.cs + keyword.other.directive.using.cs end @@ -7298,7 +7298,7 @@ 1 name - keyword.query.from.cs + keyword.operator.expression.query.from.cs 2 @@ -7318,7 +7318,7 @@ 8 name - keyword.query.in.cs + keyword.operator.expression.query.in.cs end @@ -7377,7 +7377,7 @@ 1 name - keyword.query.let.cs + keyword.operator.expression.query.let.cs 2 @@ -7414,7 +7414,7 @@ 1 name - keyword.query.where.cs + keyword.operator.expression.query.where.cs end @@ -7465,7 +7465,7 @@ 1 name - keyword.query.join.cs + keyword.operator.expression.query.join.cs 2 @@ -7485,7 +7485,7 @@ 8 name - keyword.query.in.cs + keyword.operator.expression.query.in.cs end @@ -7523,7 +7523,7 @@ 1 name - keyword.query.on.cs + keyword.operator.expression.query.on.cs @@ -7536,7 +7536,7 @@ 1 name - keyword.query.equals.cs + keyword.operator.expression.query.equals.cs @@ -7551,7 +7551,7 @@ 1 name - keyword.query.into.cs + keyword.operator.expression.query.into.cs 2 @@ -7569,7 +7569,7 @@ 1 name - keyword.query.orderby.cs + keyword.operator.expression.query.orderby.cs end @@ -7597,18 +7597,13 @@ ordering-direction match - \b(?:(ascending)|(descending))\b + \b(ascending|descending)\b captures 1 name - keyword.query.ascending.cs - - 2 - - name - keyword.query.descending.cs + keyword.operator.expression.query.$1.cs @@ -7621,7 +7616,7 @@ 1 name - keyword.query.select.cs + keyword.operator.expression.query.select.cs end @@ -7647,7 +7642,7 @@ 1 name - keyword.query.group.cs + keyword.operator.expression.query.group.cs end @@ -7681,7 +7676,7 @@ 1 name - keyword.query.by.cs + keyword.operator.expression.query.by.cs @@ -7696,7 +7691,7 @@ 1 name - keyword.query.into.cs + keyword.operator.expression.query.into.cs 2 diff --git a/grammars/csharp.tmLanguage.cson b/grammars/csharp.tmLanguage.cson index d66da75..b980ad7 100644 --- a/grammars/csharp.tmLanguage.cson +++ b/grammars/csharp.tmLanguage.cson @@ -365,9 +365,9 @@ repository: begin: "\\s*(extern)\\b\\s*(alias)\\b\\s*(@?[_[:alpha:]][_[:alnum:]]*)" beginCaptures: "1": - name: "keyword.directive.extern.cs" + name: "keyword.other.directive.extern.cs" "2": - name: "keyword.directive.alias.cs" + name: "keyword.other.directive.alias.cs" "3": name: "variable.other.alias.cs" end: "(?=;)" @@ -377,11 +377,11 @@ repository: begin: "(\\b(global)\\b\\s+)?\\b(using)\\b\\s+(static)\\b\\s+(\\b(unsafe)\\b\\s+)?" beginCaptures: "2": - name: "keyword.directive.global.cs" + name: "keyword.other.directive.global.cs" "3": - name: "keyword.directive.using.cs" + name: "keyword.other.directive.using.cs" "4": - name: "keyword.directive.static.cs" + name: "keyword.other.directive.static.cs" "6": name: "storage.modifier.unsafe.cs" end: "(?=;)" @@ -395,9 +395,9 @@ repository: begin: "(\\b(global)\\b\\s+)?\\b(using)\\b\\s+(\\b(unsafe)\\b\\s+)?(?=(@?[_[:alpha:]][_[:alnum:]]*)\\s*=)" beginCaptures: "2": - name: "keyword.directive.global.cs" + name: "keyword.other.directive.global.cs" "3": - name: "keyword.directive.using.cs" + name: "keyword.other.directive.using.cs" "5": name: "storage.modifier.unsafe.cs" "6": @@ -419,9 +419,9 @@ repository: begin: "(\\b(global)\\b\\s+)?\\b(using)\\s*(?!\\(|\\s|var)" beginCaptures: "2": - name: "keyword.directive.global.cs" + name: "keyword.other.directive.global.cs" "3": - name: "keyword.directive.using.cs" + name: "keyword.other.directive.using.cs" end: "(?=;)" patterns: [ { @@ -4404,7 +4404,7 @@ repository: ''' beginCaptures: "1": - name: "keyword.query.from.cs" + name: "keyword.operator.expression.query.from.cs" "2": patterns: [ { @@ -4414,7 +4414,7 @@ repository: "7": name: "entity.name.variable.range-variable.cs" "8": - name: "keyword.query.in.cs" + name: "keyword.operator.expression.query.in.cs" end: "(?=;|\\))" patterns: [ { @@ -4454,7 +4454,7 @@ repository: ''' beginCaptures: "1": - name: "keyword.query.let.cs" + name: "keyword.operator.expression.query.let.cs" "2": name: "entity.name.variable.range-variable.cs" "3": @@ -4475,7 +4475,7 @@ repository: ''' beginCaptures: "1": - name: "keyword.query.where.cs" + name: "keyword.operator.expression.query.where.cs" end: "(?=;|\\))" patterns: [ { @@ -4516,7 +4516,7 @@ repository: ''' beginCaptures: "1": - name: "keyword.query.join.cs" + name: "keyword.operator.expression.query.join.cs" "2": patterns: [ { @@ -4526,7 +4526,7 @@ repository: "7": name: "entity.name.variable.range-variable.cs" "8": - name: "keyword.query.in.cs" + name: "keyword.operator.expression.query.in.cs" end: "(?=;|\\))" patterns: [ { @@ -4549,12 +4549,12 @@ repository: match: "\\b(on)\\b\\s*" captures: "1": - name: "keyword.query.on.cs" + name: "keyword.operator.expression.query.on.cs" "join-equals": match: "\\b(equals)\\b\\s*" captures: "1": - name: "keyword.query.equals.cs" + name: "keyword.operator.expression.query.equals.cs" "join-into": match: ''' (?x) @@ -4563,14 +4563,14 @@ repository: ''' captures: "1": - name: "keyword.query.into.cs" + name: "keyword.operator.expression.query.into.cs" "2": name: "entity.name.variable.range-variable.cs" "orderby-clause": begin: "\\b(orderby)\\b\\s*" beginCaptures: "1": - name: "keyword.query.orderby.cs" + name: "keyword.operator.expression.query.orderby.cs" end: "(?=;|\\))" patterns: [ { @@ -4587,17 +4587,15 @@ repository: } ] "ordering-direction": - match: "\\b(?:(ascending)|(descending))\\b" + match: "\\b(ascending|descending)\\b" captures: "1": - name: "keyword.query.ascending.cs" - "2": - name: "keyword.query.descending.cs" + name: "keyword.operator.expression.query.$1.cs" "select-clause": begin: "\\b(select)\\b\\s*" beginCaptures: "1": - name: "keyword.query.select.cs" + name: "keyword.operator.expression.query.select.cs" end: "(?=;|\\))" patterns: [ { @@ -4611,7 +4609,7 @@ repository: begin: "\\b(group)\\b\\s*" beginCaptures: "1": - name: "keyword.query.group.cs" + name: "keyword.operator.expression.query.group.cs" end: "(?=;|\\))" patterns: [ { @@ -4631,7 +4629,7 @@ repository: match: "\\b(by)\\b\\s*" captures: "1": - name: "keyword.query.by.cs" + name: "keyword.operator.expression.query.by.cs" "group-into": match: ''' (?x) @@ -4640,7 +4638,7 @@ repository: ''' captures: "1": - name: "keyword.query.into.cs" + name: "keyword.operator.expression.query.into.cs" "2": name: "entity.name.variable.range-variable.cs" "anonymous-method-expression": diff --git a/src/csharp.tmLanguage.yml b/src/csharp.tmLanguage.yml index 69c272b..1d2e21d 100644 --- a/src/csharp.tmLanguage.yml +++ b/src/csharp.tmLanguage.yml @@ -146,8 +146,8 @@ repository: extern-alias-directive: begin: \s*(extern)\b\s*(alias)\b\s*(@?[_[:alpha:]][_[:alnum:]]*) beginCaptures: - '1': { name: keyword.directive.extern.cs } - '2': { name: keyword.directive.alias.cs } + '1': { name: keyword.other.directive.extern.cs } + '2': { name: keyword.other.directive.alias.cs } '3': { name: variable.other.alias.cs } end: (?=;) @@ -155,17 +155,17 @@ repository: patterns: - begin: (\b(global)\b\s+)?\b(using)\b\s+(static)\b\s+(\b(unsafe)\b\s+)? beginCaptures: - '2': { name: keyword.directive.global.cs } - '3': { name: keyword.directive.using.cs } - '4': { name: keyword.directive.static.cs } + '2': { name: keyword.other.directive.global.cs } + '3': { name: keyword.other.directive.using.cs } + '4': { name: keyword.other.directive.static.cs } '6': { name: storage.modifier.unsafe.cs } end: (?=;) patterns: - include: '#type' - begin: (\b(global)\b\s+)?\b(using)\b\s+(\b(unsafe)\b\s+)?(?=(@?[_[:alpha:]][_[:alnum:]]*)\s*=) beginCaptures: - '2': { name: keyword.directive.global.cs } - '3': { name: keyword.directive.using.cs } + '2': { name: keyword.other.directive.global.cs } + '3': { name: keyword.other.directive.using.cs } '5': { name: storage.modifier.unsafe.cs } '6': { name: entity.name.type.alias.cs } end: (?=;) @@ -175,8 +175,8 @@ repository: - include: '#operator-assignment' - begin: (\b(global)\b\s+)?\b(using)\s*(?!\(|\s|var) # Use negative lookahead to exclude using statement forms. beginCaptures: - '2': { name: keyword.directive.global.cs } - '3': { name: keyword.directive.using.cs } + '2': { name: keyword.other.directive.global.cs } + '3': { name: keyword.other.directive.using.cs } end: (?=;) patterns: - include: '#comment' @@ -2873,7 +2873,7 @@ repository: \s+(\g)\b\s* \b(in)\b\s* beginCaptures: - '1': { name: keyword.query.from.cs } + '1': { name: keyword.operator.expression.query.from.cs } '2': patterns: - include: '#type' @@ -2882,7 +2882,7 @@ repository: # '5': ? is a sub-expression. It's final value is not considered. # '6': ? is a sub-expression. It's final value is not considered. '7': { name: entity.name.variable.range-variable.cs } - '8': { name: keyword.query.in.cs } + '8': { name: keyword.operator.expression.query.in.cs } end: (?=;|\)) patterns: - include: '#query-body' @@ -2904,7 +2904,7 @@ repository: (@?[_[:alpha:]][_[:alnum:]]*)\b\s* (=)\s* beginCaptures: - '1': { name: keyword.query.let.cs } + '1': { name: keyword.operator.expression.query.let.cs } '2': { name: entity.name.variable.range-variable.cs } '3': { name: keyword.operator.assignment.cs } end: (?=;|\)) @@ -2917,7 +2917,7 @@ repository: (?x) \b(where)\b\s* beginCaptures: - '1': { name: keyword.query.where.cs } + '1': { name: keyword.operator.expression.query.where.cs } end: (?=;|\)) patterns: - include: '#query-body' @@ -2952,7 +2952,7 @@ repository: \s+(\g)\b\s* \b(in)\b\s* beginCaptures: - '1': { name: keyword.query.join.cs } + '1': { name: keyword.operator.expression.query.join.cs } '2': patterns: - include: '#type' @@ -2961,7 +2961,7 @@ repository: # '5': ? is a sub-expression. It's final value is not considered. # '6': ? is a sub-expression. It's final value is not considered. '7': { name: entity.name.variable.range-variable.cs } - '8': { name: keyword.query.in.cs } + '8': { name: keyword.operator.expression.query.in.cs } end: (?=;|\)) patterns: - include: '#join-on' @@ -2973,12 +2973,12 @@ repository: join-on: match: \b(on)\b\s* captures: - '1': { name: keyword.query.on.cs } + '1': { name: keyword.operator.expression.query.on.cs } join-equals: match: \b(equals)\b\s* captures: - '1': { name: keyword.query.equals.cs } + '1': { name: keyword.operator.expression.query.equals.cs } join-into: match: |- @@ -2986,13 +2986,13 @@ repository: \b(into)\b\s* (@?[_[:alpha:]][_[:alnum:]]*)\b\s* captures: - '1': { name: keyword.query.into.cs } + '1': { name: keyword.operator.expression.query.into.cs } '2': { name: entity.name.variable.range-variable.cs } orderby-clause: begin: \b(orderby)\b\s* beginCaptures: - '1': { name: keyword.query.orderby.cs } + '1': { name: keyword.operator.expression.query.orderby.cs } end: (?=;|\)) patterns: - include: '#ordering-direction' @@ -3001,15 +3001,14 @@ repository: - include: '#punctuation-comma' ordering-direction: - match: \b(?:(ascending)|(descending))\b + match: \b(ascending|descending)\b captures: - '1': { name: keyword.query.ascending.cs } - '2': { name: keyword.query.descending.cs } + 1: { name: keyword.operator.expression.query.$1.cs } select-clause: begin: \b(select)\b\s* beginCaptures: - '1': { name: keyword.query.select.cs } + '1': { name: keyword.operator.expression.query.select.cs } end: (?=;|\)) patterns: - include: '#query-body' @@ -3018,7 +3017,7 @@ repository: group-clause: begin: \b(group)\b\s* beginCaptures: - '1': { name: keyword.query.group.cs } + '1': { name: keyword.operator.expression.query.group.cs } end: (?=;|\)) patterns: - include: '#group-by' @@ -3029,7 +3028,7 @@ repository: group-by: match: \b(by)\b\s* captures: - '1': { name: keyword.query.by.cs } + '1': { name: keyword.operator.expression.query.by.cs } group-into: match: |- @@ -3037,7 +3036,7 @@ repository: \b(into)\b\s* (@?[_[:alpha:]][_[:alnum:]]*)\b\s* captures: - '1': { name: keyword.query.into.cs } + '1': { name: keyword.operator.expression.query.into.cs } '2': { name: entity.name.variable.range-variable.cs } anonymous-method-expression: diff --git a/test/expressions.tests.ts b/test/expressions.tests.ts index fa25d0e..907f2df 100644 --- a/test/expressions.tests.ts +++ b/test/expressions.tests.ts @@ -46,7 +46,7 @@ describe("Expressions", () => { Token.Keyword.Definition.Var, Token.Identifier.LocalName("bytes"), Token.Operator.Assignment, - Token.Operator.Expression.Stackalloc, + Token.Operator.Expression.StackAlloc, Token.PrimitiveType.Byte, Token.Punctuation.OpenBracket, Token.Literal.Numeric.Decimal("10"), @@ -63,7 +63,7 @@ describe("Expressions", () => { Token.Keyword.Definition.Var, Token.Identifier.LocalName("ints"), Token.Operator.Assignment, - Token.Operator.Expression.Stackalloc, + Token.Operator.Expression.StackAlloc, Token.PrimitiveType.Int, Token.Punctuation.OpenBracket, Token.Literal.Numeric.Decimal("42"), @@ -79,7 +79,7 @@ describe("Expressions", () => { tokens.should.deep.equal([ Token.Identifier.MethodName("Foo"), Token.Punctuation.OpenParen, - Token.Operator.Expression.Stackalloc, + Token.Operator.Expression.StackAlloc, Token.Punctuation.OpenBracket, Token.Punctuation.CloseBracket, Token.Punctuation.OpenBrace, @@ -3462,9 +3462,9 @@ void CandleLightOffSecond(int index) Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("n"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("numbers") ]); }); @@ -3477,10 +3477,10 @@ void CandleLightOffSecond(int index) Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.PrimitiveType.Int, Token.Identifier.RangeVariableName("n"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("numbers") ]); }); @@ -3496,13 +3496,13 @@ var q = from x in list1 Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("x"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("list1"), - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("y"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("list2") ]); }); @@ -3518,19 +3518,19 @@ var q = from c in customers Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("c"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("customers"), - Token.Keyword.Query.Join, + Token.Operator.Query.Join, Token.Identifier.RangeVariableName("o"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("orders"), - Token.Keyword.Query.On, + Token.Operator.Query.On, Token.Variable.Object("c"), Token.Punctuation.Accessor, Token.Variable.Property("CustomerID"), - Token.Keyword.Query.Equals, + Token.Operator.Query.Equals, Token.Variable.Object("o"), Token.Punctuation.Accessor, Token.Variable.Property("CustomerID") @@ -3548,23 +3548,23 @@ var q = from c in customers Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("c"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("customers"), - Token.Keyword.Query.Join, + Token.Operator.Query.Join, Token.Identifier.RangeVariableName("o"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("orders"), - Token.Keyword.Query.On, + Token.Operator.Query.On, Token.Variable.Object("c"), Token.Punctuation.Accessor, Token.Variable.Property("CustomerID"), - Token.Keyword.Query.Equals, + Token.Operator.Query.Equals, Token.Variable.Object("o"), Token.Punctuation.Accessor, Token.Variable.Property("CustomerID"), - Token.Keyword.Query.Into, + Token.Operator.Query.Into, Token.Identifier.RangeVariableName("co") ]); }); @@ -3580,11 +3580,11 @@ var q = from o in orders Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("o"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("orders"), - Token.Keyword.Query.OrderBy, + Token.Operator.Query.OrderBy, Token.Variable.Object("o"), Token.Punctuation.Accessor, Token.Variable.Property("Customer"), @@ -3608,17 +3608,17 @@ var q = from o in orders Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("o"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("orders"), - Token.Keyword.Query.OrderBy, + Token.Operator.Query.OrderBy, Token.Variable.Object("o"), Token.Punctuation.Accessor, Token.Variable.Property("Customer"), Token.Punctuation.Accessor, Token.Variable.Property("Name"), - Token.Keyword.Query.Ascending, + Token.Operator.Query.Ascending, Token.Punctuation.Comma, Token.Variable.Object("o"), Token.Punctuation.Accessor, @@ -3637,11 +3637,11 @@ var q = from o in orders Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("o"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("orders"), - Token.Keyword.Query.OrderBy, + Token.Operator.Query.OrderBy, Token.Variable.Object("o"), Token.Punctuation.Accessor, Token.Variable.Property("Customer"), @@ -3651,7 +3651,7 @@ var q = from o in orders Token.Variable.Object("o"), Token.Punctuation.Accessor, Token.Variable.Property("Total"), - Token.Keyword.Query.Descending + Token.Operator.Query.Descending ]); }); @@ -3665,11 +3665,11 @@ var q = from n in numbers Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("n"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("numbers"), - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Variable.ReadWrite("n"), Token.Punctuation.Semicolon ]); @@ -3685,9 +3685,9 @@ var q = from n in new[] { 1, 3, 5, 7, 9 } Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("n"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Operator.Expression.New, Token.Punctuation.OpenBracket, Token.Punctuation.CloseBracket, @@ -3702,7 +3702,7 @@ var q = from n in new[] { 1, 3, 5, 7, 9 } Token.Punctuation.Comma, Token.Literal.Numeric.Decimal("9"), Token.Punctuation.CloseBrace, - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Variable.ReadWrite("n"), Token.Operator.Arithmetic.Remainder, Token.Literal.Numeric.Decimal("4"), @@ -3722,17 +3722,17 @@ var q = from c in customers Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("c"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("customers"), - Token.Keyword.Query.Group, + Token.Operator.Query.Group, Token.Variable.ReadWrite("c"), - Token.Keyword.Query.By, + Token.Operator.Query.By, Token.Variable.Object("c"), Token.Punctuation.Accessor, Token.Variable.Property("Country"), - Token.Keyword.Query.Into, + Token.Operator.Query.Into, Token.Identifier.RangeVariableName("g") ]); }); @@ -3748,13 +3748,13 @@ string s;`); Token.Identifier.LocalName("q"), Token.Operator.Assignment, Token.Punctuation.OpenParen, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("x"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Punctuation.String.Begin, Token.Literal.String("abc"), Token.Punctuation.String.End, - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Variable.ReadWrite("x"), Token.Punctuation.CloseParen, Token.Punctuation.Semicolon, @@ -3796,9 +3796,9 @@ private static readonly Parser NodeParser = Token.Operator.Assignment, // from name in NodeName.Token() - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("name"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.Object("NodeName"), Token.Punctuation.Accessor, Token.Identifier.MethodName("Token"), @@ -3806,9 +3806,9 @@ private static readonly Parser NodeParser = Token.Punctuation.CloseParen, // from type in NodeValueType.Token() - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("type"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.Object("NodeValueType"), Token.Punctuation.Accessor, Token.Identifier.MethodName("Token"), @@ -3816,9 +3816,9 @@ private static readonly Parser NodeParser = Token.Punctuation.CloseParen, // from eq in Parse.Char('=') - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("eq"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.Object("Parse"), Token.Punctuation.Accessor, Token.Identifier.MethodName("Char"), @@ -3829,9 +3829,9 @@ private static readonly Parser NodeParser = Token.Punctuation.CloseParen, // from value in QuotedString.Token() - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("value"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.Object("QuotedString"), Token.Punctuation.Accessor, Token.Identifier.MethodName("Token"), @@ -3839,9 +3839,9 @@ private static readonly Parser NodeParser = Token.Punctuation.CloseParen, // from lcurl in Parse.Char('{').Token() - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("lcurl"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.Object("Parse"), Token.Punctuation.Accessor, Token.Identifier.MethodName("Char"), @@ -3856,9 +3856,9 @@ private static readonly Parser NodeParser = Token.Punctuation.CloseParen, // from children in Parse.Ref(() => ChildrenNodesParser) - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("children"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.Object("Parse"), Token.Punctuation.Accessor, Token.Identifier.MethodName("Ref"), @@ -3870,9 +3870,9 @@ private static readonly Parser NodeParser = Token.Punctuation.CloseParen, // from rcurl in Parse.Char('}').Token() - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("rcurl"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.Object("Parse"), Token.Punctuation.Accessor, Token.Identifier.MethodName("Char"), @@ -3893,7 +3893,7 @@ private static readonly Parser NodeParser = // Value = value, // Children = children // }; - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Operator.Expression.New, Token.Type("Node"), Token.Punctuation.OpenBrace, @@ -3938,15 +3938,15 @@ select x.Key1;`); Token.Keyword.Definition.Var, Token.Identifier.LocalName("q"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("x"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("list1"), - Token.Keyword.Query.Join, + Token.Operator.Query.Join, Token.Identifier.RangeVariableName("y"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("list2"), - Token.Keyword.Query.On, + Token.Operator.Query.On, Token.Operator.Expression.New, Token.Punctuation.OpenBrace, Token.Variable.Object("x"), @@ -3957,7 +3957,7 @@ select x.Key1;`); Token.Punctuation.Accessor, Token.Variable.Property("Key2"), Token.Punctuation.CloseBrace, - Token.Keyword.Query.Equals, + Token.Operator.Query.Equals, Token.Operator.Expression.New, Token.Punctuation.OpenBrace, Token.Variable.Object("y"), @@ -3968,7 +3968,7 @@ select x.Key1;`); Token.Punctuation.Accessor, Token.Variable.Property("Key2"), Token.Punctuation.CloseBrace, - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Variable.Object("x"), Token.Punctuation.Accessor, Token.Variable.Property("Key1"), diff --git a/test/utils/tokenize.ts b/test/utils/tokenize.ts index 107ef0a..1a25914 100644 --- a/test/utils/tokenize.ts +++ b/test/utils/tokenize.ts @@ -297,11 +297,11 @@ export namespace Token { } export namespace Directive { - export const Alias = createToken('alias', 'keyword.directive.alias.cs'); - export const Extern = createToken('extern', 'keyword.directive.extern.cs'); - export const Global = createToken('global', 'keyword.directive.global.cs'); - export const Static = createToken('static', 'keyword.directive.static.cs'); - export const Using = createToken('using', 'keyword.directive.using.cs'); + export const Alias = createToken('alias', 'keyword.other.directive.alias.cs'); + export const Extern = createToken('extern', 'keyword.other.directive.extern.cs'); + export const Global = createToken('global', 'keyword.other.directive.global.cs'); + export const Static = createToken('static', 'keyword.other.directive.static.cs'); + export const Using = createToken('using', 'keyword.other.directive.using.cs'); } export namespace Exception { @@ -378,23 +378,6 @@ export namespace Token { export const Load = createToken('load', 'keyword.preprocessor.load.cs'); } - export namespace Query { - export const Ascending = createToken('ascending', 'keyword.query.ascending.cs'); - export const By = createToken('by', 'keyword.query.by.cs'); - export const Descending = createToken('descending', 'keyword.query.descending.cs'); - export const Equals = createToken('equals', 'keyword.query.equals.cs'); - export const From = createToken('from', 'keyword.query.from.cs'); - export const Group = createToken('group', 'keyword.query.group.cs'); - export const In = createToken('in', 'keyword.query.in.cs'); - export const Into = createToken('into', 'keyword.query.into.cs'); - export const Join = createToken('join', 'keyword.query.join.cs'); - export const Let = createToken('let', 'keyword.query.let.cs'); - export const On = createToken('on', 'keyword.query.on.cs'); - export const OrderBy = createToken('orderby', 'keyword.query.orderby.cs'); - export const Select = createToken('select', 'keyword.query.select.cs'); - export const Where = createToken('where', 'keyword.query.where.cs'); - } - export const AttributeSpecifier = (text: string) => createToken(text, 'keyword.other.attribute-specifier.cs'); } @@ -485,7 +468,7 @@ export namespace Token { export const Default = createToken('default', 'keyword.operator.expression.default.cs'); export const NameOf = createToken('nameof', 'keyword.operator.expression.nameof.cs'); export const New = createToken('new', 'keyword.operator.expression.new.cs'); - export const Stackalloc = createToken('stackalloc', 'keyword.operator.expression.stackalloc.cs'); + export const StackAlloc = createToken('stackalloc', 'keyword.operator.expression.stackalloc.cs'); export const TypeOf = createToken('typeof', 'keyword.operator.expression.typeof.cs'); export const Unchecked = createToken('unchecked', 'keyword.operator.expression.unchecked.cs'); export const With = createToken('with', 'keyword.operator.expression.with.cs'); @@ -514,6 +497,23 @@ export namespace Token { export const Or = createToken('or', 'keyword.operator.expression.pattern.combinator.or.cs'); } + export namespace Query { + export const Ascending = createToken('ascending', 'keyword.operator.expression.query.ascending.cs'); + export const By = createToken('by', 'keyword.operator.expression.query.by.cs'); + export const Descending = createToken('descending', 'keyword.operator.expression.query.descending.cs'); + export const Equals = createToken('equals', 'keyword.operator.expression.query.equals.cs'); + export const From = createToken('from', 'keyword.operator.expression.query.from.cs'); + export const Group = createToken('group', 'keyword.operator.expression.query.group.cs'); + export const In = createToken('in', 'keyword.operator.expression.query.in.cs'); + export const Into = createToken('into', 'keyword.operator.expression.query.into.cs'); + export const Join = createToken('join', 'keyword.operator.expression.query.join.cs'); + export const Let = createToken('let', 'keyword.operator.expression.query.let.cs'); + export const On = createToken('on', 'keyword.operator.expression.query.on.cs'); + export const OrderBy = createToken('orderby', 'keyword.operator.expression.query.orderby.cs'); + export const Select = createToken('select', 'keyword.operator.expression.query.select.cs'); + export const Where = createToken('where', 'keyword.operator.expression.query.where.cs'); + } + export const Arrow = createToken('=>', 'keyword.operator.arrow.cs'); export const Assignment = createToken('=', 'keyword.operator.assignment.cs'); export const Decrement = createToken('--', 'keyword.operator.decrement.cs'); diff --git a/test/verbatim-indentifier.tests.ts b/test/verbatim-indentifier.tests.ts index 54690b3..dce2290 100644 --- a/test/verbatim-indentifier.tests.ts +++ b/test/verbatim-indentifier.tests.ts @@ -650,9 +650,9 @@ const string @class = obj.@class;`); Token.Keyword.Definition.Var, Token.Identifier.LocalName("query"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("@class"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("numbers") ]); }); @@ -670,11 +670,11 @@ var earlyBirdQuery = Token.Keyword.Definition.Var, Token.Identifier.LocalName("earlyBirdQuery"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("sentence"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("strings"), - Token.Keyword.Query.Let, + Token.Operator.Query.Let, Token.Identifier.RangeVariableName("@words"), Token.Operator.Assignment, Token.Variable.Object("sentence"), @@ -685,11 +685,11 @@ var earlyBirdQuery = Token.Literal.Char(" "), Token.Punctuation.Char.End, Token.Punctuation.CloseParen, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("word"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("@words"), - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Variable.ReadWrite("word"), Token.Punctuation.Semicolon ]); @@ -707,25 +707,25 @@ var query = Token.Keyword.Definition.Var, Token.Identifier.LocalName("query"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("category"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("categories"), - Token.Keyword.Query.Join, + Token.Operator.Query.Join, Token.Identifier.RangeVariableName("@prod"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("products"), - Token.Keyword.Query.On, + Token.Operator.Query.On, Token.Variable.Object("category"), Token.Punctuation.Accessor, Token.Variable.Property("ID"), - Token.Keyword.Query.Equals, + Token.Operator.Query.Equals, Token.Variable.Object("@prod"), Token.Punctuation.Accessor, Token.Variable.Property("CategoryID"), - Token.Keyword.Query.Into, + Token.Operator.Query.Into, Token.Identifier.RangeVariableName("prodGroup"), - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Operator.Expression.New, Token.Punctuation.OpenBrace, Token.Variable.ReadWrite("CategoryName"), @@ -754,25 +754,25 @@ var query = Token.Keyword.Definition.Var, Token.Identifier.LocalName("query"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("category"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("categories"), - Token.Keyword.Query.Join, + Token.Operator.Query.Join, Token.Identifier.RangeVariableName("prod"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("products"), - Token.Keyword.Query.On, + Token.Operator.Query.On, Token.Variable.Object("category"), Token.Punctuation.Accessor, Token.Variable.Property("ID"), - Token.Keyword.Query.Equals, + Token.Operator.Query.Equals, Token.Variable.Object("prod"), Token.Punctuation.Accessor, Token.Variable.Property("CategoryID"), - Token.Keyword.Query.Into, + Token.Operator.Query.Into, Token.Identifier.RangeVariableName("@prodGroup"), - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Operator.Expression.New, Token.Punctuation.OpenBrace, Token.Variable.ReadWrite("CategoryName"), @@ -801,21 +801,21 @@ var results = Token.Keyword.Definition.Var, Token.Identifier.LocalName("results"), Token.Operator.Assignment, - Token.Keyword.Query.From, + Token.Operator.Query.From, Token.Identifier.RangeVariableName("p"), - Token.Keyword.Query.In, + Token.Operator.Query.In, Token.Variable.ReadWrite("people"), - Token.Keyword.Query.Group, + Token.Operator.Query.Group, Token.Variable.Object("p"), Token.Punctuation.Accessor, Token.Variable.Property("Car"), - Token.Keyword.Query.By, + Token.Operator.Query.By, Token.Variable.Object("p"), Token.Punctuation.Accessor, Token.Variable.Property("PersonId"), - Token.Keyword.Query.Into, + Token.Operator.Query.Into, Token.Identifier.RangeVariableName("@group"), - Token.Keyword.Query.Select, + Token.Operator.Query.Select, Token.Operator.Expression.New, Token.Punctuation.OpenBrace, Token.Variable.ReadWrite("PersonId"),