Skip to content

Commit a7d9782

Browse files
committed
Merge branch 'master' into multiLineArrowParameters
2 parents a184e39 + a7080b7 commit a7d9782

File tree

8 files changed

+167
-3
lines changed

8 files changed

+167
-3
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ repository:
164164
- include: '#cast'
165165
- include: '#ternary-expression'
166166
- include: '#new-expr'
167+
- include: '#instanceof-expr'
167168
- include: '#object-literal'
168169
- include: '#expression-operators'
169170
- include: '#paren-expression-possibly-arrow'
@@ -1141,6 +1142,14 @@ repository:
11411142
- include: '#class-declaration'
11421143
- include: '#type'
11431144

1145+
instanceof-expr:
1146+
begin: '{{startOfIdentifier}}(instanceof){{endOfIdentifier}}'
1147+
beginCaptures:
1148+
'1': { name: keyword.operator.expression.instanceof.ts }
1149+
end: (?<=\))|(?=[;),}\]:]|$|({{startOfIdentifier}}function((\s+{{identifier}})|(\s*[\(]))))
1150+
patterns:
1151+
- include: '#type'
1152+
11441153
# when ( is followed by end of line, it could be arrow parameter decarations, so inside this match as if parameter falling back to expression
11451154
# but do this only from expression and as last resort
11461155
paren-expression-possibly-arrow:

TypeScript.tmLanguage

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@
255255
<key>include</key>
256256
<string>#new-expr</string>
257257
</dict>
258+
<dict>
259+
<key>include</key>
260+
<string>#instanceof-expr</string>
261+
</dict>
258262
<dict>
259263
<key>include</key>
260264
<string>#object-literal</string>
@@ -3570,6 +3574,28 @@
35703574
</dict>
35713575
</array>
35723576
</dict>
3577+
<key>instanceof-expr</key>
3578+
<dict>
3579+
<key>begin</key>
3580+
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(instanceof)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))</string>
3581+
<key>beginCaptures</key>
3582+
<dict>
3583+
<key>1</key>
3584+
<dict>
3585+
<key>name</key>
3586+
<string>keyword.operator.expression.instanceof.ts</string>
3587+
</dict>
3588+
</dict>
3589+
<key>end</key>
3590+
<string>(?&lt;=\))|(?=[;),}\]:]|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
3591+
<key>patterns</key>
3592+
<array>
3593+
<dict>
3594+
<key>include</key>
3595+
<string>#type</string>
3596+
</dict>
3597+
</array>
3598+
</dict>
35733599
<key>paren-expression-possibly-arrow</key>
35743600
<dict>
35753601
<key>patterns</key>

TypeScriptReact.tmLanguage

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@
259259
<key>include</key>
260260
<string>#new-expr</string>
261261
</dict>
262+
<dict>
263+
<key>include</key>
264+
<string>#instanceof-expr</string>
265+
</dict>
262266
<dict>
263267
<key>include</key>
264268
<string>#object-literal</string>
@@ -3574,6 +3578,28 @@
35743578
</dict>
35753579
</array>
35763580
</dict>
3581+
<key>instanceof-expr</key>
3582+
<dict>
3583+
<key>begin</key>
3584+
<string>(?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))(instanceof)(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.))</string>
3585+
<key>beginCaptures</key>
3586+
<dict>
3587+
<key>1</key>
3588+
<dict>
3589+
<key>name</key>
3590+
<string>keyword.operator.expression.instanceof.tsx</string>
3591+
</dict>
3592+
</dict>
3593+
<key>end</key>
3594+
<string>(?&lt;=\))|(?=[;),}\]:]|$|((?&lt;![_$[:alnum:]])(?:(?&lt;=\.\.\.)|(?&lt;!\.))function((\s+[_$[:alpha:]][_$[:alnum:]]*)|(\s*[\(]))))</string>
3595+
<key>patterns</key>
3596+
<array>
3597+
<dict>
3598+
<key>include</key>
3599+
<string>#type</string>
3600+
</dict>
3601+
</array>
3602+
</dict>
35773603
<key>paren-expression-possibly-arrow</key>
35783604
<dict>
35793605
<key>patterns</key>

tests/baselines/Issue37.baseline.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ Grammar: TypeScript.tmLanguage
728728
^
729729
source.ts meta.namespace.declaration.ts meta.block.ts meta.class.ts meta.method.declaration.ts meta.block.ts
730730
^^^^^
731-
source.ts meta.namespace.declaration.ts meta.block.ts meta.class.ts meta.method.declaration.ts meta.block.ts support.class.error.ts
731+
source.ts meta.namespace.declaration.ts meta.block.ts meta.class.ts meta.method.declaration.ts meta.block.ts entity.name.type.ts
732732
^
733733
source.ts meta.namespace.declaration.ts meta.block.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.brace.round.ts
734734
^

tests/baselines/Issue37.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ Grammar: TypeScript.tmLanguage
222222
^^^^^^^^^^
223223
[57, 54]: source.ts meta.namespace.declaration.ts meta.block.ts meta.class.ts meta.method.declaration.ts meta.block.ts keyword.operator.expression.instanceof.ts
224224
^^^^^
225-
[57, 65]: source.ts meta.namespace.declaration.ts meta.block.ts meta.class.ts meta.method.declaration.ts meta.block.ts support.class.error.ts
225+
[57, 65]: source.ts meta.namespace.declaration.ts meta.block.ts meta.class.ts meta.method.declaration.ts meta.block.ts entity.name.type.ts
226226
>
227227
^^^^^^^^^^^^^^
228228
[58, 14]: source.ts meta.namespace.declaration.ts meta.block.ts meta.class.ts meta.method.declaration.ts meta.block.ts meta.block.ts

tests/baselines/Issue578.baseline.txt

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
original file
2+
-----------------------------------
3+
if (targetAttribute) {
4+
if (!(targetAttribute instanceof Attribute)) {
5+
targetAttribute = new Attribute(targetAttribute);
6+
}
7+
}
8+
-----------------------------------
9+
10+
Grammar: TypeScript.tmLanguage
11+
-----------------------------------
12+
>if (targetAttribute) {
13+
^^
14+
source.ts keyword.control.conditional.ts
15+
^
16+
source.ts
17+
^
18+
source.ts meta.brace.round.ts
19+
^^^^^^^^^^^^^^^
20+
source.ts variable.other.readwrite.ts
21+
^
22+
source.ts meta.brace.round.ts
23+
^
24+
source.ts
25+
^
26+
source.ts meta.block.ts punctuation.definition.block.ts
27+
^^
28+
source.ts meta.block.ts
29+
> if (!(targetAttribute instanceof Attribute)) {
30+
^^^^
31+
source.ts meta.block.ts
32+
^^
33+
source.ts meta.block.ts keyword.control.conditional.ts
34+
^
35+
source.ts meta.block.ts
36+
^
37+
source.ts meta.block.ts meta.brace.round.ts
38+
^
39+
source.ts meta.block.ts keyword.operator.logical.ts
40+
^
41+
source.ts meta.block.ts meta.brace.round.ts
42+
^^^^^^^^^^^^^^^
43+
source.ts meta.block.ts variable.other.readwrite.ts
44+
^
45+
source.ts meta.block.ts
46+
^^^^^^^^^^
47+
source.ts meta.block.ts keyword.operator.expression.instanceof.ts
48+
^
49+
source.ts meta.block.ts
50+
^^^^^^^^^
51+
source.ts meta.block.ts entity.name.type.ts
52+
^
53+
source.ts meta.block.ts meta.brace.round.ts
54+
^
55+
source.ts meta.block.ts meta.brace.round.ts
56+
^
57+
source.ts meta.block.ts
58+
^
59+
source.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
60+
^^
61+
source.ts meta.block.ts meta.block.ts
62+
> targetAttribute = new Attribute(targetAttribute);
63+
^^^^^^^^
64+
source.ts meta.block.ts meta.block.ts
65+
^^^^^^^^^^^^^^^
66+
source.ts meta.block.ts meta.block.ts variable.other.readwrite.ts
67+
^
68+
source.ts meta.block.ts meta.block.ts
69+
^
70+
source.ts meta.block.ts meta.block.ts keyword.operator.assignment.ts
71+
^
72+
source.ts meta.block.ts meta.block.ts
73+
^^^
74+
source.ts meta.block.ts meta.block.ts new.expr.ts keyword.operator.new.ts
75+
^
76+
source.ts meta.block.ts meta.block.ts new.expr.ts
77+
^^^^^^^^^
78+
source.ts meta.block.ts meta.block.ts new.expr.ts entity.name.type.ts
79+
^
80+
source.ts meta.block.ts meta.block.ts new.expr.ts meta.brace.round.ts
81+
^^^^^^^^^^^^^^^
82+
source.ts meta.block.ts meta.block.ts new.expr.ts variable.other.readwrite.ts
83+
^
84+
source.ts meta.block.ts meta.block.ts new.expr.ts meta.brace.round.ts
85+
^
86+
source.ts meta.block.ts meta.block.ts punctuation.terminator.statement.ts
87+
^^
88+
source.ts meta.block.ts meta.block.ts
89+
> }
90+
^^^^
91+
source.ts meta.block.ts meta.block.ts
92+
^
93+
source.ts meta.block.ts meta.block.ts punctuation.definition.block.ts
94+
^^
95+
source.ts meta.block.ts
96+
>}
97+
^
98+
source.ts meta.block.ts punctuation.definition.block.ts

tests/baselines/javascript.baseline.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ Grammar: TypeScript.tmLanguage
103103
^
104104
source.ts
105105
^
106-
source.ts variable.other.readwrite.ts
106+
source.ts entity.name.type.ts
107107
^
108108
source.ts punctuation.terminator.statement.ts

tests/cases/Issue578.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if (targetAttribute) {
2+
if (!(targetAttribute instanceof Attribute)) {
3+
targetAttribute = new Attribute(targetAttribute);
4+
}
5+
}

0 commit comments

Comments
 (0)