Skip to content

Commit a120c59

Browse files
committed
Handle Lable
1 parent 768c9ed commit a120c59

File tree

6 files changed

+27
-25
lines changed

6 files changed

+27
-25
lines changed

src/services/findAllReferences.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ namespace ts.FindAllReferences {
5555
if (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) {
5656
return node.parent.parent;
5757
}
58-
else if (isJsxSelfClosingElement(node.parent)) {
58+
else if (isJsxSelfClosingElement(node.parent) ||
59+
isLabeledStatement(node.parent) ||
60+
isBreakOrContinueStatement(node.parent)) {
5961
return node.parent;
6062
}
6163

tests/cases/fourslash/referencesForLabel.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
// Valid References for a label
44

5-
////[|label|]: while (true) {
6-
//// if (false) break [|label|];
7-
//// if (true) continue [|label|];
8-
////}
5+
////[|[|{| "declarationRangeIndex": 0 |}label|]: while (true) {
6+
//// if (false) [|break [|{| "declarationRangeIndex": 2 |}label|];|]
7+
//// if (true) [|continue [|{| "declarationRangeIndex": 4 |}label|];|]
8+
////}|]
99
////
10-
////[|label|]: while (false) { }
10+
////[|[|{| "declarationRangeIndex": 6 |}label|]: while (false) { }|]
1111
////var label = "label";
1212

13-
const [r0, r1, r2, r3] = test.ranges();
13+
const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = test.ranges();
1414
verify.singleReferenceGroup("label", [r0, r1, r2]);
1515
verify.singleReferenceGroup("label", [r3]);

tests/cases/fourslash/referencesForLabel3.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
// References to unused label
44

5-
////[|label|]: while (true) {
5+
////[|[|{| "declarationRangeIndex": 0 |}label|]: while (true) {
66
//// var label = "label";
7-
////}
7+
////}|]
88

9-
verify.singleReferenceGroup("label");
9+
verify.singleReferenceGroup("label", "label");

tests/cases/fourslash/referencesForLabel4.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
// References to a label outside function bounderies
44

5-
////[|label|]: function foo(label) {
5+
////[|[|{| "declarationRangeIndex": 0 |}label|]: function foo(label) {
66
//// while (true) {
7-
//// break [|label|];
7+
//// [|break [|{| "declarationRangeIndex": 2 |}label|];|]
88
//// }
9-
////}
9+
////}|]
1010

11-
verify.singleReferenceGroup("label");
11+
verify.singleReferenceGroup("label", "label");

tests/cases/fourslash/referencesForLabel5.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
// References to shadowed label
44

5-
////[|label|]: while (true) {
6-
//// if (false) break [|label|];
5+
////[|[|{| "declarationRangeIndex": 0 |}label|]: while (true) {
6+
//// if (false) [|break [|{| "declarationRangeIndex": 2 |}label|];|]
77
//// function blah() {
8-
////[|label|]: while (true) {
9-
//// if (false) break [|label|];
10-
//// }
8+
////[|[|{| "declarationRangeIndex": 4 |}label|]: while (true) {
9+
//// if (false) [|break [|{| "declarationRangeIndex": 6 |}label|];|]
10+
//// }|]
1111
//// }
12-
//// if (false) break [|label|];
13-
//// }
12+
//// if (false) [|break [|{| "declarationRangeIndex": 8 |}label|];|]
13+
//// }|]
1414

15-
const [outer1, outer2, inner1, inner2, outer3] = test.ranges();
15+
const [ourter1Def, outer1, outer2Def, outer2, inner1Def, inner1, inner2Def, inner2, outer3Def, outer3] = test.ranges();
1616
verify.singleReferenceGroup("label", [outer1, outer2, outer3]);
1717
verify.singleReferenceGroup("label", [inner1, inner2]);

tests/cases/fourslash/referencesForLabel6.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
// References to labels with close names
44

5-
////[|labela|]: while (true) {
6-
////[|labelb|]: while (false) { break [|labelb|]; }
5+
////[|[|{| "declarationRangeIndex": 0 |}labela|]: while (true) {
6+
////[|[|{| "declarationRangeIndex": 2 |}labelb|]: while (false) { [|break [|{| "declarationRangeIndex": 4 |}labelb|];|] }|]
77
//// break labelc;
8-
////}
8+
////}|]
99

1010
verify.singleReferenceGroup("labela", "labela");
1111
verify.singleReferenceGroup("labelb", "labelb");

0 commit comments

Comments
 (0)