Skip to content

Commit

Permalink
Merge pull request #295 from Microsoft/restAndSpreadOperator
Browse files Browse the repository at this point in the history
Rest and spread operator support
  • Loading branch information
sheetalkamat authored Oct 10, 2016
2 parents 3376784 + 7ce774f commit 56e921e
Show file tree
Hide file tree
Showing 14 changed files with 1,157 additions and 231 deletions.
105 changes: 63 additions & 42 deletions TypeScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,40 @@ repository:
- include: '#array-binding-pattern'
- name: variable.other.readwrite.ts
match: ([_$[:alpha:]][_$[:alnum:]]*)
- name: variable.other.readwrite.ts
match: ([_$[:alpha:]][_$[:alnum:]]*)
- name: meta.delimiter.object.comma.ts
match: ','
- include: '#object-binding-pattern'
- include: '#destructuring-variable-rest'
- include: '#punctuation-comma'

array-binding-element:
patterns:
- include: '#comment'
- include: '#object-binding-pattern'
- include: '#array-binding-pattern'
- name: variable.other.readwrite.ts
match: ([_$[:alpha:]][_$[:alnum:]]*)
- name: meta.delimiter.object.comma.ts
match: ','
- include: '#destructuring-variable-rest'
- include: '#punctuation-comma'

destructuring-variable-rest:
match: (?:(\.\.\.)\s*)?([_$[:alpha:]][_$[:alnum:]]*)
captures:
'1': { name: keyword.operator.rest.ts }
'2': { name: variable.other.readwrite.ts }

object-binding-pattern:
begin: \{
begin: (?:(\.\.\.)\s*)?(\{)
beginCaptures:
'0': { name: punctuation.definition.binding-pattern.object.ts }
'1': { name: keyword.operator.rest.ts }
'2': { name: punctuation.definition.binding-pattern.object.ts }
end: \}
endCaptures:
'0': { name: punctuation.definition.binding-pattern.object.ts }
patterns:
- include: '#object-binding-element'

array-binding-pattern:
begin: \[
begin: (?:(\.\.\.)\s*)?(\[)
beginCaptures:
'0': { name: punctuation.definition.binding-pattern.array.ts }
'1': { name: keyword.operator.rest.ts }
'2': { name: punctuation.definition.binding-pattern.array.ts }
end: \]
endCaptures:
'0': { name: punctuation.definition.binding-pattern.array.ts }
Expand Down Expand Up @@ -173,8 +178,7 @@ repository:
- include: '#ternary-expression'
- include: '#new-expr'
- include: '#object-literal'
- include: '#expression-operator'
- include: '#operators'
- include: '#expression-operators'
- include: '#support-objects'
- include: '#function-call'
- include: '#identifiers'
Expand Down Expand Up @@ -371,8 +375,7 @@ repository:
'4': { name: keyword.control.as.ts }
'5': { name: invalid.illegal.ts }
'6': { name: variable.other.readwrite.alias.ts }
- name: meta.delimiter.object.comma.ts
match: ','
- include: '#punctuation-comma'
- name: constant.language.import-export-all.ts
match: \*
- name: keyword.control.default.ts
Expand Down Expand Up @@ -460,6 +463,12 @@ repository:
- include: '#method-declaration'
- include: '#indexer-declaration'
- include: '#type-annotation'
- begin: \.\.\.
beginCaptures:
'0': { name: keyword.operator.spread.ts }
end: '(?=\}|;|,|$)|(?<=\})'
patterns:
- include: '#type'
- include: '#punctuation-comma'
- include: '#punctuation-semicolon'

Expand Down Expand Up @@ -612,7 +621,7 @@ repository:
match: '(?:\s*\b(public|private|protected)\b\s+)?(\.\.\.)?\s*(?<!=|:)([_$[:alpha:]][_$[:alnum:]]*)\s*(\??)'
captures:
'1': { name: storage.modifier.ts }
'2': { name: keyword.operator.spread.ts }
'2': { name: keyword.operator.rest.ts }
'3': { name: variable.parameter.ts }
'4': { name: keyword.operator.optional.ts }

Expand Down Expand Up @@ -650,35 +659,40 @@ repository:
- include: '#parameter-array-binding-pattern'
- name: variable.parameter.ts
match: ([_$[:alpha:]][_$[:alnum:]]*)
- name: variable.parameter.ts
match: ([_$[:alpha:]][_$[:alnum:]]*)
- name: meta.delimiter.object.comma.ts
match: ','
- include: '#parameter-object-binding-pattern'
- include: '#destructuring-parameter-rest'
- include: '#punctuation-comma'

parameter-array-binding-element:
patterns:
- include: '#comment'
- include: '#parameter-object-binding-pattern'
- include: '#parameter-array-binding-pattern'
- name: variable.parameter.ts
match: ([_$[:alpha:]][_$[:alnum:]]*)
- name: meta.delimiter.object.comma.ts
match: ','
- include: '#destructuring-parameter-rest'
- include: '#punctuation-comma'

destructuring-parameter-rest:
match: (?:(\.\.\.)\s*)?([_$[:alpha:]][_$[:alnum:]]*)
captures:
'1': { name: keyword.operator.rest.ts }
'2': { name: variable.parameter.ts }

parameter-object-binding-pattern:
begin: \{
begin: (?:(\.\.\.)\s*)?(\{)
beginCaptures:
'0': { name: punctuation.definition.binding-pattern.object.ts }
'1': { name: keyword.operator.rest.ts }
'2': { name: punctuation.definition.binding-pattern.object.ts }
end: \}
endCaptures:
'0': { name: punctuation.definition.binding-pattern.object.ts }
patterns:
- include: '#parameter-object-binding-element'

parameter-array-binding-pattern:
begin: \[
begin: (?:(\.\.\.)\s*)?(\[)
beginCaptures:
'0': { name: punctuation.definition.binding-pattern.array.ts }
'1': { name: keyword.operator.rest.ts }
'2': { name: punctuation.definition.binding-pattern.array.ts }
end: \]
endCaptures:
'0': { name: punctuation.definition.binding-pattern.array.ts }
Expand Down Expand Up @@ -728,11 +742,10 @@ repository:
- include: '#numeric-literal'
- include: '#type-primitive'
- include: '#type-builtin-literals'
- include: '#typeof-operator'
- include: '#type-parameters'
- include: '#type-tuple'
- include: '#type-object'
- include: '#type-operator'
- include: '#type-operators'
- include: '#type-fn-type-parameters'
- include: '#type-paren-or-function-parameters'
- include: '#type-function-return-type'
Expand Down Expand Up @@ -819,9 +832,11 @@ repository:
patterns:
- include: '#function-parameters'

type-operator:
name: keyword.operator.type.ts
match: '[&|]'
type-operators:
patterns:
- include: '#typeof-operator'
- name: keyword.operator.type.ts
match: '[&|]'

type-function-return-type:
name: meta.type.function.return.ts
Expand Down Expand Up @@ -1342,13 +1357,20 @@ repository:
end: (?=,|\})
patterns:
- include: '#expression'
- name: meta.object.member.ts
begin: \.\.\.
beginCaptures:
'0': { name: keyword.operator.spread.ts }
end: (?=,|\})
patterns:
- include: '#expression'
- name: meta.object.member.ts
match: ([_$[:alpha:]][_$[:alnum:]]*)\s*(?=,|\}|$)
captures:
'1': { name: variable.other.readwrite.ts }
- include: '#punctuation-comma'

expression-operator:
expression-operators:
patterns:
- name: keyword.control.flow.ts
match: (?<!\.|\$)\b(await)\b(?!\$)
Expand All @@ -1371,13 +1393,8 @@ repository:
end: (?=$|[;,})\]])
patterns:
- include: '#type'

typeof-operator:
name: keyword.operator.typeof.ts
match: (?<!\.|\$)\btypeof\b(?!\$)

operators:
patterns:
- name: keyword.operator.spread.ts
match: \.\.\.
- name: keyword.operator.assignment.compound.ts
match: \*=|(?<!\()/=|%=|\+=|\-=
- name: keyword.operator.assignment.compound.bitwise.ts
Expand All @@ -1399,6 +1416,10 @@ repository:
- name: keyword.operator.arithmetic.ts
match: '%|\*|/|-|\+'

typeof-operator:
name: keyword.operator.typeof.ts
match: (?<!\.|\$)\btypeof\b(?!\$)

arrow-function:
patterns:
- name: meta.arrow.ts
Expand Down
Loading

0 comments on commit 56e921e

Please sign in to comment.