Variable scope can end with block end

Fixes #252
This commit is contained in:
Sheetal Nandi 2016-08-31 13:06:52 -07:00
Родитель 0425a20ae9
Коммит 21d57cbeab
6 изменённых файлов: 137 добавлений и 32 удалений

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

@ -32,7 +32,7 @@ repository:
beginCaptures:
'1': { name: keyword.control.export.ts }
'2': { name: storage.type.ts }
end: (?=$|;)
end: (?=$|;|})
patterns:
- include: '#destructuring-variable'
- include: '#var-single-variable'
@ -43,11 +43,11 @@ repository:
begin: \b([_$[:alpha:]][_$[:alnum:]]*)\b
beginCaptures:
'1': { name: variable.other.readwrite.ts }
end: (?=$|[;,])
end: (?=$|[;,}])
patterns:
- include: '#variable-initializer'
- begin: \G
end: (?!\G)(?=$|[;,=])
end: (?!\G)(?=$|[;,=}])
patterns:
- include: '#type-annotation'
- include: '#string'
@ -59,11 +59,11 @@ repository:
begin: (?<!=|:)\s*(\{)
beginCaptures:
'1': { name: punctuation.definition.binding-pattern.object.ts }
end: (?=$|[;,])
end: (?=$|[;,}])
patterns:
- include: '#variable-initializer'
- begin: \G
end: (?!\G)(?=$|[;,=])
end: (?!\G)(?=$|[;,=}])
patterns:
- begin: \G
end: \}
@ -77,11 +77,11 @@ repository:
begin: (?<!=|:)\s*(\[)
beginCaptures:
'1': { name: punctuation.definition.binding-pattern.array.ts }
end: (?=$|[;,])
end: (?=$|[;,}])
patterns:
- include: '#variable-initializer'
- begin: \G
end: (?!\G)(?=$|[;,=])
end: (?!\G)(?=$|[;,=}])
patterns:
- begin: \G
end: \]
@ -819,7 +819,7 @@ repository:
begin: (?<!=|!)(=)(?!=)
beginCaptures:
'1': { name: keyword.operator.assignment.ts }
end: (?=$|[,);])
end: (?=$|[,);}])
patterns:
- include: '#expression'

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

@ -864,7 +864,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|[;,])</string>
<string>(?=$|[;,}])</string>
<key>name</key>
<string>meta.object-binding-pattern-variable.ts</string>
<key>patterns</key>
@ -877,7 +877,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?!\G)(?=$|[;,=])</string>
<string>(?!\G)(?=$|[;,=}])</string>
<key>patterns</key>
<array>
<dict>
@ -925,7 +925,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|[;,])</string>
<string>(?=$|[;,}])</string>
<key>name</key>
<string>meta.array-binding-pattern-variable.ts</string>
<key>patterns</key>
@ -938,7 +938,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?!\G)(?=$|[;,=])</string>
<string>(?!\G)(?=$|[;,=}])</string>
<key>patterns</key>
<array>
<dict>
@ -3815,7 +3815,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|;)</string>
<string>(?=$|;|})</string>
<key>name</key>
<string>meta.var.expr.ts</string>
<key>patterns</key>
@ -3847,7 +3847,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|[;,])</string>
<string>(?=$|[;,}])</string>
<key>name</key>
<string>meta.var-single-variable.expr.ts</string>
<key>patterns</key>
@ -3860,7 +3860,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?!\G)(?=$|[;,=])</string>
<string>(?!\G)(?=$|[;,=}])</string>
<key>patterns</key>
<array>
<dict>
@ -3892,7 +3892,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|[,);])</string>
<string>(?=$|[,);}])</string>
<key>patterns</key>
<array>
<dict>

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

@ -36,7 +36,7 @@ repository:
beginCaptures:
'1': { name: keyword.control.export.tsx }
'2': { name: storage.type.tsx }
end: (?=$|;)
end: (?=$|;|})
patterns:
- include: '#destructuring-variable'
- include: '#var-single-variable'
@ -47,11 +47,11 @@ repository:
begin: \b([_$[:alpha:]][_$[:alnum:]]*)\b
beginCaptures:
'1': { name: variable.other.readwrite.tsx }
end: (?=$|[;,])
end: (?=$|[;,}])
patterns:
- include: '#variable-initializer'
- begin: \G
end: (?!\G)(?=$|[;,=])
end: (?!\G)(?=$|[;,=}])
patterns:
- include: '#type-annotation'
- include: '#string'
@ -63,11 +63,11 @@ repository:
begin: (?<!=|:)\s*(\{)
beginCaptures:
'1': { name: punctuation.definition.binding-pattern.object.tsx }
end: (?=$|[;,])
end: (?=$|[;,}])
patterns:
- include: '#variable-initializer'
- begin: \G
end: (?!\G)(?=$|[;,=])
end: (?!\G)(?=$|[;,=}])
patterns:
- begin: \G
end: \}
@ -81,11 +81,11 @@ repository:
begin: (?<!=|:)\s*(\[)
beginCaptures:
'1': { name: punctuation.definition.binding-pattern.array.tsx }
end: (?=$|[;,])
end: (?=$|[;,}])
patterns:
- include: '#variable-initializer'
- begin: \G
end: (?!\G)(?=$|[;,=])
end: (?!\G)(?=$|[;,=}])
patterns:
- begin: \G
end: \]
@ -823,7 +823,7 @@ repository:
begin: (?<!=|!)(=)(?!=)
beginCaptures:
'1': { name: keyword.operator.assignment.tsx }
end: (?=$|[,);])
end: (?=$|[,);}])
patterns:
- include: '#expression'

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

@ -832,7 +832,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|[;,])</string>
<string>(?=$|[;,}])</string>
<key>name</key>
<string>meta.object-binding-pattern-variable.tsx</string>
<key>patterns</key>
@ -845,7 +845,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?!\G)(?=$|[;,=])</string>
<string>(?!\G)(?=$|[;,=}])</string>
<key>patterns</key>
<array>
<dict>
@ -893,7 +893,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|[;,])</string>
<string>(?=$|[;,}])</string>
<key>name</key>
<string>meta.array-binding-pattern-variable.tsx</string>
<key>patterns</key>
@ -906,7 +906,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?!\G)(?=$|[;,=])</string>
<string>(?!\G)(?=$|[;,=}])</string>
<key>patterns</key>
<array>
<dict>
@ -4205,7 +4205,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|;)</string>
<string>(?=$|;|})</string>
<key>name</key>
<string>meta.var.expr.tsx</string>
<key>patterns</key>
@ -4237,7 +4237,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|[;,])</string>
<string>(?=$|[;,}])</string>
<key>name</key>
<string>meta.var-single-variable.expr.tsx</string>
<key>patterns</key>
@ -4250,7 +4250,7 @@
<key>begin</key>
<string>\G</string>
<key>end</key>
<string>(?!\G)(?=$|[;,=])</string>
<string>(?!\G)(?=$|[;,=}])</string>
<key>patterns</key>
<array>
<dict>
@ -4282,7 +4282,7 @@
</dict>
</dict>
<key>end</key>
<string>(?=$|[,);])</string>
<string>(?=$|[,);}])</string>
<key>patterns</key>
<array>
<dict>

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

@ -0,0 +1,102 @@
original file
-----------------------------------
function getPage(p, base) {
if (filename == base + "index") { var route = "/" + base }
}
-----------------------------------
>function getPage(p, base) {
^^^^^^^^
source.ts meta.function.ts storage.type.function.ts
^
source.ts meta.function.ts
^^^^^^^
source.ts meta.function.ts entity.name.function.ts
^
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.function.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.function.ts meta.parameters.ts
^
source.ts meta.function.ts meta.parameters.ts
^^^^
source.ts meta.function.ts meta.parameters.ts variable.parameter.ts
^
source.ts meta.function.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.function.ts
^
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.function.ts meta.block.ts
> if (filename == base + "index") { var route = "/" + base }
^^^^
source.ts meta.function.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts keyword.control.conditional.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^^^^^^^^^
source.ts meta.function.ts meta.block.ts
^^
source.ts meta.function.ts meta.block.ts keyword.operator.comparison.ts
^^^^^^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts keyword.operator.arithmetic.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^^^^^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts
^
source.ts meta.function.ts meta.block.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.function.ts meta.block.ts meta.brace.round.ts
^
source.ts meta.function.ts meta.block.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts
^^^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts
^^^^^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts variable.other.readwrite.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts keyword.operator.assignment.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.double.ts punctuation.definition.string.begin.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.double.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts string.quoted.double.ts punctuation.definition.string.end.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts keyword.operator.arithmetic.ts
^^^^^^
source.ts meta.function.ts meta.block.ts meta.block.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.function.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts meta.function.ts meta.block.ts
>}
^
source.ts meta.function.ts meta.block.ts punctuation.definition.block.ts
^^
source.ts
>
^
source.ts

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

@ -0,0 +1,3 @@
function getPage(p, base) {
if (filename == base + "index") { var route = "/" + base }
}