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:
Sheetal Nandi 2018-11-29 10:32:25 -08:00
Родитель f0edf8329e
Коммит 4284108f50
5 изменённых файлов: 544 добавлений и 3 удалений

Просмотреть файл

@ -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>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(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)(?:(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?&lt;!=|:)(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
# function assignment |
(=\s*(
((async\s+)?(
(function\s*[(&lt;*]) |
(function\s+) |
([_$[:alpha:]][_$[:alnum:]]*\s*=&gt;)
)) |
((async\s*)?(
((&lt;\s*$)|((&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)?[\(]\s*([\{\[]\s*)?$)) |
# sure shot arrow functions even if =&gt; is on new line
(
(&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)?
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
(
([)]\s*:) | # ():
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
)
) |
(
[&lt;]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=&gt;] # &lt; typeparam extends
) |
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)? # typeparameters
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
(\s*:\s*([^&lt;&gt;\(\)\{\}]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
\s*=&gt; # arrow operator
)
))
)) |
# typeannotation is fn type: &lt; | () | (... | (param: | (param, | (param? | (param= | (param) =&gt;
(:\s*(
(&lt;) |
([(]\s*(
([)]) |
(\.\.\.) |
([_$[:alnum:]]+\s*(
([:,?=])|
([)]\s*=&gt;)
))
))
)) |
(:\s*((&lt;\s*$)|((&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)?[\(]\s*([\{\[]\s*)?$))) |
(:\s*(=&gt;|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(&lt;[^&lt;&gt;]*&gt;)|[^&lt;&gt;(),=])+=\s*(
((async\s+)?(
(function\s*[(&lt;*]) |
(function\s+) |
([_$[:alpha:]][_$[:alnum:]]*\s*=&gt;)
)) |
((async\s*)?(
((&lt;\s*$)|((&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)?[\(]\s*([\{\[]\s*)?$)) |
# sure shot arrow functions even if =&gt; is on new line
(
(&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)?
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
(
([)]\s*:) | # ():
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
)
) |
(
[&lt;]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=&gt;] # &lt; typeparam extends
) |
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)? # typeparameters
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
(\s*:\s*([^&lt;&gt;\(\)\{\}]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
\s*=&gt; # 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)(?:(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?&lt;!=|:)(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(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>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(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)(?:(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?&lt;!=|:)(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(this)|([_$[:alpha:]][_$[:alnum:]]*))(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))\s*(\??)(?=\s*
# function assignment |
(=\s*(
((async\s+)?(
(function\s*[(&lt;*]) |
(function\s+) |
([_$[:alpha:]][_$[:alnum:]]*\s*=&gt;)
)) |
((async\s*)?(
((&lt;\s*$)|([\(]\s*([\{\[]\s*)?$)) |
# sure shot arrow functions even if =&gt; is on new line
(
(&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)?
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
(
([)]\s*:) | # ():
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
)
) |
(
[&lt;]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=&gt;] # &lt; typeparam extends
) |
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)? # typeparameters
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
(\s*:\s*([^&lt;&gt;\(\)\{\}]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
\s*=&gt; # arrow operator
)
))
)) |
# typeannotation is fn type: &lt; | () | (... | (param: | (param, | (param? | (param= | (param) =&gt;
(:\s*(
(&lt;) |
([(]\s*(
([)]) |
(\.\.\.) |
([_$[:alnum:]]+\s*(
([:,?=])|
([)]\s*=&gt;)
))
))
)) |
(:\s*((&lt;\s*$)|([\(]\s*([\{\[]\s*)?$))) |
(:\s*(=&gt;|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(&lt;[^&lt;&gt;]*&gt;)|[^&lt;&gt;(),=])+=\s*(
((async\s+)?(
(function\s*[(&lt;*]) |
(function\s+) |
([_$[:alpha:]][_$[:alnum:]]*\s*=&gt;)
)) |
((async\s*)?(
((&lt;\s*$)|([\(]\s*([\{\[]\s*)?$)) |
# sure shot arrow functions even if =&gt; is on new line
(
(&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)?
[(]\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*
(
([)]\s*:) | # ():
((\.\.\.\s*)?[_$[:alpha:]][_$[:alnum:]]*\s*:) # [(]param: | [(]...param:
)
) |
(
[&lt;]\s*[_$[:alpha:]][_$[:alnum:]]*\s+extends\s*[^=&gt;] # &lt; typeparam extends
) |
# arrow function possible to detect only with =&gt; on same line
(
(&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;]|\&lt;\s*([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\(([^\(\)]|(\([^\(\)]*\)))*\))|(\[([^\[\]]|(\[[^\[\]]*\]))*\]))([^=&lt;&gt;]|=[^&lt;])*\&gt;)*&gt;\s*)? # typeparameters
\(\s*(\/\*([^\*]|(\*[^\/]))*\*\/\s*)*(([_$[:alpha:]]|(\{([^\{\}]|(\{[^\{\}]*\}))*\})|(\[([^\[\]]|(\[[^\[\]]*\]))*\])|(\.\.\.\s*[_$[:alpha:]]))([^()]|(\(([^\(\)]|(\([^\(\)]*\)))*\)))*)?\) # parameters
(\s*:\s*([^&lt;&gt;\(\)\{\}]|\&lt;[^&lt;&gt;]+\&gt;|\([^\(\)]+\)|\{[^\{\}]+\})+)? # return type
\s*=&gt; # 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)(?:(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(public|private|protected|readonly)\s+)?(?:(\.\.\.)\s*)?(?&lt;!=|:)(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(?:(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

8
tests/cases/Issue689.ts Normal file
Просмотреть файл

@ -0,0 +1,8 @@
const x = 1;
const y = (
x > x ? 2 :
x < x ? 3 :
4
);
const foo = y;
const bar = `${x} ${y}`;