Skip to content

Commit 46a048d

Browse files
authored
Merge pull request #267 from Microsoft/robustTests
Verify files against both grammars unless specified otherwise
2 parents 9c7430d + 71d0430 commit 46a048d

File tree

166 files changed

+1100
-556
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

166 files changed

+1100
-556
lines changed

TypeScriptReact.YAML-tmLanguage

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ uuid: 805375ec-d614-41f5-8993-5843fe63ea82
1010

1111
repository:
1212
# Additions:
13-
# statements and expression repository need to include jsx first followed by whaterver ts grammar says
14-
statements:
15-
patterns:
16-
- include: '#jsx'
17-
13+
# expression repository need to include jsx first followed by whaterver ts grammar says
1814
expression:
1915
patterns:
2016
- include: '#jsx'
@@ -109,8 +105,8 @@ repository:
109105

110106
jsx-tag-without-attributes:
111107
name: meta.tag.without-attributes.tsx
112-
begin: (<)([_$a-zA-Z][-$\w.]*(?<!\.|-))(>)
113-
end: (</)([_$a-zA-Z][-$\w.]*(?<!\.|-))(>)
108+
begin: (<)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)
109+
end: (</)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)
114110
beginCaptures:
115111
'1': {name: punctuation.definition.tag.begin.tsx}
116112
'2': {name: entity.name.tag.tsx}
@@ -124,35 +120,47 @@ repository:
124120
- include: '#jsx-children'
125121

126122
jsx-tag:
127-
name: meta.tag.tsx
123+
# We need to differentiate between the relational '<' operator and the beginning of a tag using the surrounding context.
128124
begin: >-
129125
(?x)
130-
(<)
126+
(?<=[({\[,?=>]|&&|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
127+
(?!(<)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)) #look ahead is not start of tag without attributes
128+
(?!<\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=>])|,)) # look ahead is not type parameter of arrow
129+
(?=(<)\s*
131130
([_$a-zA-Z][-$\w.]*(?<!\.|-))
132-
(?=\s+(?!\?)|/?>)
133-
beginCaptures:
134-
'1': { name: punctuation.definition.tag.begin.tsx }
135-
'2': { name: entity.name.tag.tsx }
136-
end: (/>)|(?:(</)([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>))
131+
(?=\s+(?!\?)|/?>))
132+
end: (/>)|(?:(</)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>))
137133
endCaptures:
134+
'0': { name: meta.tag.tsx }
138135
'1': { name: punctuation.definition.tag.end.tsx }
139136
'2': { name: punctuation.definition.tag.begin.tsx }
140137
'3': { name: entity.name.tag.tsx }
141138
'4': { name: punctuation.definition.tag.end.tsx }
142139
patterns:
143-
- begin: \G(?![/]?>)
144-
end: (?=[/]?>)
145-
patterns:
146-
- include: '#comment'
147-
- include: '#jsx-tag-attributes'
148-
- include: '#jsx-tag-attributes-illegal'
149-
- begin: (>)
140+
- name: meta.tag.tsx
141+
begin: >-
142+
(?x)
143+
(<)\s*
144+
([_$a-zA-Z][-$\w.]*(?<!\.|-))
145+
(?=\s+(?!\?)|/?>)
150146
beginCaptures:
151-
'1': { name: punctuation.definition.tag.end.tsx }
152-
end: (?=</)
153-
contentName: meta.jsx.children.tsx
147+
'1': { name: punctuation.definition.tag.begin.tsx }
148+
'2': { name: entity.name.tag.tsx }
149+
end: (?=(/>)|(?:(</)\s*([_$a-zA-Z][-$\w.]*(?<!\.|-))\s*(>)))
154150
patterns:
155-
- include: '#jsx-children'
151+
- begin: \G(?![/]?>)
152+
end: (?=[/]?>)
153+
patterns:
154+
- include: '#comment'
155+
- include: '#jsx-tag-attributes'
156+
- include: '#jsx-tag-attributes-illegal'
157+
- begin: (>)
158+
beginCaptures:
159+
'1': { name: punctuation.definition.tag.end.tsx }
160+
end: (?=</)
161+
contentName: meta.jsx.children.tsx
162+
patterns:
163+
- include: '#jsx-children'
156164

157165
jsx-tag-invalid:
158166
name: invalid.illegal.tag.incomplete.tsx

TypeScriptReact.tmLanguage

Lines changed: 67 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525
<dict>
2626
<key>patterns</key>
2727
<array>
28-
<dict>
29-
<key>include</key>
30-
<string>#jsx</string>
31-
</dict>
3228
<dict>
3329
<key>include</key>
3430
<string>#string</string>
@@ -4480,9 +4476,9 @@
44804476
<key>name</key>
44814477
<string>meta.tag.without-attributes.tsx</string>
44824478
<key>begin</key>
4483-
<string>(&lt;)([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))(&gt;)</string>
4479+
<string>(&lt;)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)</string>
44844480
<key>end</key>
4485-
<string>(&lt;/)([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))(&gt;)</string>
4481+
<string>(&lt;/)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)</string>
44864482
<key>beginCaptures</key>
44874483
<dict>
44884484
<key>1</key>
@@ -4531,30 +4527,23 @@
45314527
</dict>
45324528
<key>jsx-tag</key>
45334529
<dict>
4534-
<key>name</key>
4535-
<string>meta.tag.tsx</string>
45364530
<key>begin</key>
45374531
<string>(?x)
4538-
(&lt;)
4532+
(?&lt;=[({\[,?=&gt;]|&amp;&amp;|\|\||\?|\Wreturn|^return|\Wdefault|^)\s*
4533+
(?!(&lt;)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)) #look ahead is not start of tag without attributes
4534+
(?!&lt;\s*[_$[:alpha:]][_$[:alnum:]]*((\s+extends\s+[^=&gt;])|,)) # look ahead is not type parameter of arrow
4535+
(?=(&lt;)\s*
45394536
([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))
4540-
(?=\s+(?!\?)|/?&gt;)</string>
4541-
<key>beginCaptures</key>
4537+
(?=\s+(?!\?)|/?&gt;))</string>
4538+
<key>end</key>
4539+
<string>(/&gt;)|(?:(&lt;/)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;))</string>
4540+
<key>endCaptures</key>
45424541
<dict>
4543-
<key>1</key>
4544-
<dict>
4545-
<key>name</key>
4546-
<string>punctuation.definition.tag.begin.tsx</string>
4547-
</dict>
4548-
<key>2</key>
4542+
<key>0</key>
45494543
<dict>
45504544
<key>name</key>
4551-
<string>entity.name.tag.tsx</string>
4545+
<string>meta.tag.tsx</string>
45524546
</dict>
4553-
</dict>
4554-
<key>end</key>
4555-
<string>(/&gt;)|(?:(&lt;/)([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;))</string>
4556-
<key>endCaptures</key>
4557-
<dict>
45584547
<key>1</key>
45594548
<dict>
45604549
<key>name</key>
@@ -4579,46 +4568,73 @@
45794568
<key>patterns</key>
45804569
<array>
45814570
<dict>
4571+
<key>name</key>
4572+
<string>meta.tag.tsx</string>
45824573
<key>begin</key>
4583-
<string>\G(?![/]?&gt;)</string>
4584-
<key>end</key>
4585-
<string>(?=[/]?&gt;)</string>
4586-
<key>patterns</key>
4587-
<array>
4588-
<dict>
4589-
<key>include</key>
4590-
<string>#comment</string>
4591-
</dict>
4592-
<dict>
4593-
<key>include</key>
4594-
<string>#jsx-tag-attributes</string>
4595-
</dict>
4596-
<dict>
4597-
<key>include</key>
4598-
<string>#jsx-tag-attributes-illegal</string>
4599-
</dict>
4600-
</array>
4601-
</dict>
4602-
<dict>
4603-
<key>begin</key>
4604-
<string>(&gt;)</string>
4574+
<string>(?x)
4575+
(&lt;)\s*
4576+
([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))
4577+
(?=\s+(?!\?)|/?&gt;)</string>
46054578
<key>beginCaptures</key>
46064579
<dict>
46074580
<key>1</key>
46084581
<dict>
46094582
<key>name</key>
4610-
<string>punctuation.definition.tag.end.tsx</string>
4583+
<string>punctuation.definition.tag.begin.tsx</string>
4584+
</dict>
4585+
<key>2</key>
4586+
<dict>
4587+
<key>name</key>
4588+
<string>entity.name.tag.tsx</string>
46114589
</dict>
46124590
</dict>
46134591
<key>end</key>
4614-
<string>(?=&lt;/)</string>
4615-
<key>contentName</key>
4616-
<string>meta.jsx.children.tsx</string>
4592+
<string>(?=(/&gt;)|(?:(&lt;/)\s*([_$a-zA-Z][-$\w.]*(?&lt;!\.|-))\s*(&gt;)))</string>
46174593
<key>patterns</key>
46184594
<array>
46194595
<dict>
4620-
<key>include</key>
4621-
<string>#jsx-children</string>
4596+
<key>begin</key>
4597+
<string>\G(?![/]?&gt;)</string>
4598+
<key>end</key>
4599+
<string>(?=[/]?&gt;)</string>
4600+
<key>patterns</key>
4601+
<array>
4602+
<dict>
4603+
<key>include</key>
4604+
<string>#comment</string>
4605+
</dict>
4606+
<dict>
4607+
<key>include</key>
4608+
<string>#jsx-tag-attributes</string>
4609+
</dict>
4610+
<dict>
4611+
<key>include</key>
4612+
<string>#jsx-tag-attributes-illegal</string>
4613+
</dict>
4614+
</array>
4615+
</dict>
4616+
<dict>
4617+
<key>begin</key>
4618+
<string>(&gt;)</string>
4619+
<key>beginCaptures</key>
4620+
<dict>
4621+
<key>1</key>
4622+
<dict>
4623+
<key>name</key>
4624+
<string>punctuation.definition.tag.end.tsx</string>
4625+
</dict>
4626+
</dict>
4627+
<key>end</key>
4628+
<string>(?=&lt;/)</string>
4629+
<key>contentName</key>
4630+
<string>meta.jsx.children.tsx</string>
4631+
<key>patterns</key>
4632+
<array>
4633+
<dict>
4634+
<key>include</key>
4635+
<string>#jsx-children</string>
4636+
</dict>
4637+
</array>
46224638
</dict>
46234639
</array>
46244640
</dict>

build/build.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ function changeTsToTsxGrammar(grammar: any) {
4949
const updatesRepository = tsxUpdates.repository;
5050
for (let key in updatesRepository) {
5151
switch(key) {
52-
case "statements":
5352
case "expression":
54-
// Update statements/expression
53+
// Update expression
5554
repository[key].patterns.unshift(updatesRepository[key].patterns[0]);
5655
break;
5756
default:

tests/baselines/Abstracts.baseline.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
original file
22
-----------------------------------
3-
^^abstract class Animal {
3+
abstract class Animal {
44
public age: number;
55
public yearsLeft() { return 20 - this.age; }
6-
^^abstract makeSound(): string;
6+
abstract makeSound(): string;
77
}
88

99
class Cow extends Animal {
@@ -18,6 +18,8 @@ let cow = new Cow();
1818
cow.makeSound();
1919
-----------------------------------
2020

21+
Grammar: TypeScript.tmLanguage
22+
-----------------------------------
2123
>abstract class Animal {
2224
^^^^^^^^
2325
source.ts meta.class.ts storage.modifier.ts

tests/baselines/Abstracts.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ let cow = new Cow();
1818
cow.makeSound();
1919
-----------------------------------
2020

21+
Grammar: TypeScript.tmLanguage
22+
-----------------------------------
2123
>abstract class Animal {
2224
^^^^^^^^
2325
[1, 1]: source.ts meta.class.ts storage.modifier.ts

tests/baselines/ArrowFunctionInsideTypeAssertion.baseline.txt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
original file
22
-----------------------------------
3+
// @onlyOwnGrammar - As this has type assertion
34
// Issue: https://github.com/Microsoft/TypeScript-Sublime-Plugin/issues/292
45

56
var object = {
6-
setTransform: ^^<^^(^^domNode: ^^HTMLElement, ^^desiredValue: ^^string) ^^=> ^^void>^^null,
7+
setTransform: <(domNode: HTMLElement, desiredValue: string) => void>null,
78
setDisplay: (domNode: HTMLElement, desiredValue: string) => {
89
if (domNode.style.display !== desiredValue) {
910
domNode.style.display = desiredValue;
@@ -16,14 +17,21 @@ function f(x: string | ((value: string) => number)) {
1617
return +x
1718
}
1819
else {
19-
let f = ^^<^^(^^v: ^^string) ^^=> ^^number^^> ^^x
20+
let f = <(v: string) => number> x
2021
return f("hello world")
2122
}
2223
}
2324

2425

2526
-----------------------------------
2627

28+
Grammar: TypeScript.tmLanguage
29+
-----------------------------------
30+
>// @onlyOwnGrammar - As this has type assertion
31+
^^
32+
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts
33+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34+
source.ts comment.line.double-slash.ts
2735
>// Issue: https://github.com/Microsoft/TypeScript-Sublime-Plugin/issues/292
2836
^^
2937
source.ts comment.line.double-slash.ts punctuation.definition.comment.ts

0 commit comments

Comments
 (0)