Dont identify x ? as optional parameter in possible multiline arrow unless its followed by type annotation or assigment
Fixes #689
This commit is contained in:
Родитель
f0edf8329e
Коммит
4284108f50
|
@ -498,6 +498,8 @@ repository:
|
|||
- include: '#binding-element-const'
|
||||
- include: '#punctuation-comma'
|
||||
|
||||
# When doing modication to parameter name, also modify expression-inside-possibly-arrow-parens where this is inlined so as to make
|
||||
# as optional operator only if it is not followed by assignment or type annotation
|
||||
parameter-name:
|
||||
patterns:
|
||||
- match: '{{startOfIdentifier}}(public|protected|private|readonly)\s+(?=(public|protected|private|readonly)\s+)'
|
||||
|
@ -837,6 +839,7 @@ repository:
|
|||
patterns:
|
||||
- include: '#function-parameters-body'
|
||||
|
||||
# When updating this, also update the expression-inside-possibly-arrow-parens where this is inlined so that parameter-name can also be inlined
|
||||
function-parameters-body:
|
||||
patterns:
|
||||
- include: '#comment'
|
||||
|
@ -1431,7 +1434,33 @@ repository:
|
|||
expression-inside-possibly-arrow-parens:
|
||||
patterns:
|
||||
- include: '#expressionWithoutIdentifiers'
|
||||
- include: '#function-parameters-body'
|
||||
- include: '#comment'
|
||||
- include: '#string'
|
||||
- include: '#decorator'
|
||||
- include: '#destructuring-parameter'
|
||||
- match: '{{startOfIdentifier}}(public|protected|private|readonly)\s+(?=(public|protected|private|readonly)\s+)'
|
||||
captures:
|
||||
'1': { name: storage.modifier.ts }
|
||||
- match: |-
|
||||
(?x)(?:{{startOfIdentifier}}(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:){{startOfIdentifier}}(?:(this)|({{identifier}})){{endOfIdentifier}}\s*(\??)(?={{functionLikeAssignmentOrType}})
|
||||
captures:
|
||||
'1': { name: storage.modifier.ts }
|
||||
'2': { name: keyword.operator.rest.ts }
|
||||
'3': { name: entity.name.function.ts variable.language.this.ts }
|
||||
'4': { name: entity.name.function.ts }
|
||||
'5': { name: keyword.operator.optional.ts }
|
||||
- match: |-
|
||||
(?x)(?:{{startOfIdentifier}}(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:){{startOfIdentifier}}(?:(this)|({{identifier}})){{endOfIdentifier}}\s*(\??)(?=\s*:)
|
||||
captures:
|
||||
'1': { name: storage.modifier.ts }
|
||||
'2': { name: keyword.operator.rest.ts }
|
||||
'3': { name: variable.parameter.ts variable.language.this.ts }
|
||||
'4': { name: variable.parameter.ts }
|
||||
'5': { name: keyword.operator.optional.ts }
|
||||
- include: '#type-annotation'
|
||||
- include: '#variable-initializer'
|
||||
- name: punctuation.separator.parameter.ts
|
||||
match: ','
|
||||
- include: '#identifiers'
|
||||
- include: '#expressionPunctuations'
|
||||
|
||||
|
|
|
@ -4620,7 +4620,181 @@
|
|||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#function-parameters-body</string>
|
||||
<string>#comment</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#string</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#decorator</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#destructuring-parameter</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|protected|private|readonly)\s+(?=(public|protected|private|readonly)\s+)</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
|
||||
# function assignment |
|
||||
(=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?[\(]\s*([\{\[]\s*)?$)) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
|
||||
)
|
||||
) |
|
||||
(
|
||||
[<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
|
||||
) |
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<[^<>]+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
)) |
|
||||
# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>
|
||||
(:\s*(
|
||||
(<) |
|
||||
([(]\s*(
|
||||
([)]) |
|
||||
(\.\.\.) |
|
||||
([_$[:alnum:]]+\s*(
|
||||
([:,?=])|
|
||||
([)]\s*=>)
|
||||
))
|
||||
))
|
||||
)) |
|
||||
(:\s*((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?[\(]\s*([\{\[]\s*)?$))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|((<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?[\(]\s*([\{\[]\s*)?$)) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
|
||||
)
|
||||
) |
|
||||
(
|
||||
[<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
|
||||
) |
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<[^<>]+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
)))</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.ts</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.rest.ts</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.function.ts variable.language.this.ts</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.function.ts</string>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.optional.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*:)</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.ts</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.rest.ts</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>variable.parameter.ts variable.language.this.ts</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>variable.parameter.ts</string>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.optional.ts</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#type-annotation</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#variable-initializer</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.separator.parameter.ts</string>
|
||||
<key>match</key>
|
||||
<string>,</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
|
|
|
@ -4624,7 +4624,181 @@
|
|||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#function-parameters-body</string>
|
||||
<string>#comment</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#string</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#decorator</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#destructuring-parameter</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|protected|private|readonly)\s+(?=(public|protected|private|readonly)\s+)</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
|
||||
# function assignment |
|
||||
(=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|([\(]\s*([\{\[]\s*)?$)) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
|
||||
)
|
||||
) |
|
||||
(
|
||||
[<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
|
||||
) |
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<[^<>]+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
)) |
|
||||
# typeannotation is fn type: < | () | (... | (param: | (param, | (param? | (param= | (param) =>
|
||||
(:\s*(
|
||||
(<) |
|
||||
([(]\s*(
|
||||
([)]) |
|
||||
(\.\.\.) |
|
||||
([_$[:alnum:]]+\s*(
|
||||
([:,?=])|
|
||||
([)]\s*=>)
|
||||
))
|
||||
))
|
||||
)) |
|
||||
(:\s*((<\s*$)|([\(]\s*([\{\[]\s*)?$))) |
|
||||
(:\s*(=>|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(<[^<>]*>)|[^<>(),=])+=\s*(
|
||||
((async\s+)?(
|
||||
(function\s*[(<*]) |
|
||||
(function\s+) |
|
||||
([_$[:alpha:]][_$[:alnum:]]*\s*=>)
|
||||
)) |
|
||||
((async\s*)?(
|
||||
((<\s*$)|([\(]\s*([\{\[]\s*)?$)) |
|
||||
# sure shot arrow functions even if => is on new line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)?
|
||||
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
|
||||
(
|
||||
([)]\s*:) | # ():
|
||||
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
|
||||
)
|
||||
) |
|
||||
(
|
||||
[<]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=>] # < typeparam extends
|
||||
) |
|
||||
# arrow function possible to detect only with => on same line
|
||||
(
|
||||
(<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<]|\<\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=<>]|=[^<])*\>)*>\s*)? # typeparameters
|
||||
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
|
||||
(\s*:\s*([^<>\(\)\{\}]|\<[^<>]+\>|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
|
||||
\s*=> # arrow operator
|
||||
)
|
||||
))
|
||||
)))</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.tsx</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.rest.tsx</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.function.tsx variable.language.this.tsx</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>entity.name.function.tsx</string>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.optional.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>match</key>
|
||||
<string>(?x)(?:(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?<!=|:)(?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*:)</string>
|
||||
<key>captures</key>
|
||||
<dict>
|
||||
<key>1</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>storage.modifier.tsx</string>
|
||||
</dict>
|
||||
<key>2</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.rest.tsx</string>
|
||||
</dict>
|
||||
<key>3</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>variable.parameter.tsx variable.language.this.tsx</string>
|
||||
</dict>
|
||||
<key>4</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>variable.parameter.tsx</string>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>keyword.operator.optional.tsx</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#type-annotation</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
<string>#variable-initializer</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>name</key>
|
||||
<string>punctuation.separator.parameter.tsx</string>
|
||||
<key>match</key>
|
||||
<string>,</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>include</key>
|
||||
|
|
|
@ -0,0 +1,156 @@
|
|||
original file
|
||||
-----------------------------------
|
||||
const x = 1;
|
||||
const y = (
|
||||
x > x ? 2 :
|
||||
x < x ? 3 :
|
||||
4
|
||||
);
|
||||
const foo = y;
|
||||
const bar = `${x} ${y}`;
|
||||
-----------------------------------
|
||||
|
||||
Grammar: TypeScript.tmLanguage
|
||||
-----------------------------------
|
||||
>const x = 1;
|
||||
^^^^^
|
||||
source.ts meta.var.expr.ts storage.type.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.assignment.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts constant.numeric.decimal.ts
|
||||
^
|
||||
source.ts punctuation.terminator.statement.ts
|
||||
>const y = (
|
||||
^^^^^
|
||||
source.ts meta.var.expr.ts storage.type.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts entity.name.function.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.assignment.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.brace.round.ts
|
||||
> x > x ? 2 :
|
||||
^^^^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.relational.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.ternary.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts constant.numeric.decimal.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.ternary.ts
|
||||
> x < x ? 3 :
|
||||
^^^^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.relational.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.ternary.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts constant.numeric.decimal.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.ternary.ts
|
||||
> 4
|
||||
^^^^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts constant.numeric.decimal.ts
|
||||
>);
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.brace.round.ts
|
||||
^
|
||||
source.ts punctuation.terminator.statement.ts
|
||||
>const foo = y;
|
||||
^^^^^
|
||||
source.ts meta.var.expr.ts storage.type.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^^^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.assignment.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts punctuation.terminator.statement.ts
|
||||
>const bar = `${x} ${y}`;
|
||||
^^^^^
|
||||
source.ts meta.var.expr.ts storage.type.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^^^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts keyword.operator.assignment.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts string.template.ts punctuation.definition.string.template.begin.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.begin.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts meta.embedded.line.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.end.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts string.template.ts
|
||||
^^
|
||||
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.begin.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts meta.embedded.line.ts variable.other.readwrite.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts string.template.ts meta.template.expression.ts punctuation.definition.template-expression.end.ts
|
||||
^
|
||||
source.ts meta.var.expr.ts string.template.ts punctuation.definition.string.template.end.ts
|
||||
^
|
||||
source.ts punctuation.terminator.statement.ts
|
|
@ -0,0 +1,8 @@
|
|||
const x = 1;
|
||||
const y = (
|
||||
x > x ? 2 :
|
||||
x < x ? 3 :
|
||||
4
|
||||
);
|
||||
const foo = y;
|
||||
const bar = `${x} ${y}`;
|
Загрузка…
Ссылка в новой задаче