Skip to content

Commit

Permalink
Handle accessors separately so as to correctly tokenize method with n…
Browse files Browse the repository at this point in the history
…ame 'get/set'

Fixes #458
  • Loading branch information
sheetalkamat committed May 24, 2017
1 parent f6cbb70 commit 8c967fe
Show file tree
Hide file tree
Showing 5 changed files with 391 additions and 151 deletions.
54 changes: 35 additions & 19 deletions TypeScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -586,24 +586,40 @@ repository:
match: \?

method-declaration:
name: meta.method.declaration.ts
begin: (?<!\.|\$)(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(?:\b(?:(new)|(constructor))\b(?!\$|\.|:))|(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\<]))
beginCaptures:
'1': { name: storage.modifier.ts } # captures keyword (public or private or protected)
'2': { name: storage.modifier.ts } # captures keyword (abstract)
'3': { name: storage.modifier.async.ts } # captures keyword (async)
'4': { name: storage.type.property.ts } # captures keyword (get|set)
'5': { name: keyword.operator.new.ts } # captures keyword (new)
'6': { name: storage.type.ts } # captures keyword (constructor)
'7': { name: keyword.generator.asterisk.ts } # captures keyword (*)
end: (?=\}|;|,|$)|(?<=\})
patterns:
- include: '#method-declaration-name'
- include: '#comment'
- include: '#type-parameters'
- include: '#function-parameters'
- include: '#return-type'
- include: '#decl-block'
- name: meta.method.declaration.ts
begin: (?<!\.|\$)(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:\b(get|set)\s+)(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\<])
beginCaptures:
'1': { name: storage.modifier.ts } # captures keyword (public or private or protected)
'2': { name: storage.modifier.ts } # captures keyword (abstract)
'3': { name: storage.modifier.async.ts } # captures keyword (async)
'4': { name: storage.type.property.ts } # captures keyword (get|set)
'5': { name: keyword.generator.asterisk.ts } # captures keyword (*)
end: (?=\}|;|,|$)|(?<=\})
patterns:
- include: '#method-declaration-name'
- include: '#comment'
- include: '#type-parameters'
- include: '#function-parameters'
- include: '#return-type'
- include: '#decl-block'
- name: meta.method.declaration.ts
begin: (?<!\.|\$)(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:(?:\b(?:(new)|(constructor))\b(?!\$|\.|:))|(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\<]))
beginCaptures:
'1': { name: storage.modifier.ts } # captures keyword (public or private or protected)
'2': { name: storage.modifier.ts } # captures keyword (abstract)
'3': { name: storage.modifier.async.ts } # captures keyword (async)
'4': { name: keyword.operator.new.ts } # captures keyword (new)
'5': { name: storage.type.ts } # captures keyword (constructor)
'6': { name: keyword.generator.asterisk.ts } # captures keyword (*)
end: (?=\}|;|,|$)|(?<=\})
patterns:
- include: '#method-declaration-name'
- include: '#comment'
- include: '#type-parameters'
- include: '#function-parameters'
- include: '#return-type'
- include: '#decl-block'

method-declaration-name:
begin: (?=(([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??)\s*[\(\<])
Expand All @@ -618,7 +634,7 @@ repository:

object-literal-method-declaration:
name: meta.method.declaration.ts
begin: (?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\<])
begin: (?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\<])
beginCaptures:
'1': { name: storage.modifier.async.ts } # captures keyword (async)
'2': { name: storage.type.property.ts } # captures keyword (get|set)
Expand All @@ -634,7 +650,7 @@ repository:
- include: '#decl-block'

object-literal-method-overload-declaration:
begin: (?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\<])
begin: (?<!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\<])
beginCaptures:
'1': { name: storage.modifier.async.ts } # captures keyword (async)
'2': { name: storage.type.property.ts } # captures keyword (get|set)
Expand Down
195 changes: 129 additions & 66 deletions TypeScript.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1803,75 +1803,138 @@
</dict>
<key>method-declaration</key>
<dict>
<key>name</key>
<string>meta.method.declaration.ts</string>
<key>begin</key>
<string>(?&lt;!\.|\$)(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(?:\b(?:(new)|(constructor))\b(?!\$|\.|:))|(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\&lt;]))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.modifier.ts</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.modifier.ts</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>storage.modifier.async.ts</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>storage.type.property.ts</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>keyword.operator.new.ts</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>storage.type.ts</string>
</dict>
<key>7</key>
<dict>
<key>name</key>
<string>keyword.generator.asterisk.ts</string>
</dict>
</dict>
<key>end</key>
<string>(?=\}|;|,|$)|(?&lt;=\})</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#method-declaration-name</string>
</dict>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#type-parameters</string>
</dict>
<dict>
<key>include</key>
<string>#function-parameters</string>
</dict>
<dict>
<key>include</key>
<string>#return-type</string>
<key>name</key>
<string>meta.method.declaration.ts</string>
<key>begin</key>
<string>(?&lt;!\.|\$)(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:\b(get|set)\s+)(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\&lt;])</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.modifier.ts</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.modifier.ts</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>storage.modifier.async.ts</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>storage.type.property.ts</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>keyword.generator.asterisk.ts</string>
</dict>
</dict>
<key>end</key>
<string>(?=\}|;|,|$)|(?&lt;=\})</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#method-declaration-name</string>
</dict>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#type-parameters</string>
</dict>
<dict>
<key>include</key>
<string>#function-parameters</string>
</dict>
<dict>
<key>include</key>
<string>#return-type</string>
</dict>
<dict>
<key>include</key>
<string>#decl-block</string>
</dict>
</array>
</dict>
<dict>
<key>include</key>
<string>#decl-block</string>
<key>name</key>
<string>meta.method.declaration.ts</string>
<key>begin</key>
<string>(?&lt;!\.|\$)(?:\b(public|private|protected)\s+)?(?:\b(abstract)\s+)?(?:\b(async)\s+)?(?:(?:\b(?:(new)|(constructor))\b(?!\$|\.|:))|(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\&lt;]))</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>storage.modifier.ts</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>storage.modifier.ts</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>storage.modifier.async.ts</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>keyword.operator.new.ts</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>storage.type.ts</string>
</dict>
<key>6</key>
<dict>
<key>name</key>
<string>keyword.generator.asterisk.ts</string>
</dict>
</dict>
<key>end</key>
<string>(?=\}|;|,|$)|(?&lt;=\})</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>#method-declaration-name</string>
</dict>
<dict>
<key>include</key>
<string>#comment</string>
</dict>
<dict>
<key>include</key>
<string>#type-parameters</string>
</dict>
<dict>
<key>include</key>
<string>#function-parameters</string>
</dict>
<dict>
<key>include</key>
<string>#return-type</string>
</dict>
<dict>
<key>include</key>
<string>#decl-block</string>
</dict>
</array>
</dict>
</array>
</dict>
Expand Down Expand Up @@ -1910,7 +1973,7 @@
<key>name</key>
<string>meta.method.declaration.ts</string>
<key>begin</key>
<string>(?&lt;!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\&lt;])</string>
<string>(?&lt;!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\&lt;])</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -1966,7 +2029,7 @@
<key>object-literal-method-overload-declaration</key>
<dict>
<key>begin</key>
<string>(?&lt;!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))?\s*[\(\&lt;])</string>
<string>(?&lt;!\.|\$)(?:\b(async)\s+)?(?:\b(get|set)\s+)?(?:(\*)\s*)?(?=((([_$[:alpha:]][_$[:alnum:]]*)|(\'[^']*\')|(\"[^"]*\")|(\[([^\[\]]|\[[^\[\]]*\])+\]))\s*(\??))\s*[\(\&lt;])</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down
Loading

0 comments on commit 8c967fe

Please sign in to comment.