Handle Lable
This commit is contained in:
parent
768c9ed8d7
commit
a120c59015
|
@ -55,7 +55,9 @@ namespace ts.FindAllReferences {
|
|||
if (isJsxOpeningElement(node.parent) || isJsxClosingElement(node.parent)) {
|
||||
return node.parent.parent;
|
||||
}
|
||||
else if (isJsxSelfClosingElement(node.parent)) {
|
||||
else if (isJsxSelfClosingElement(node.parent) ||
|
||||
isLabeledStatement(node.parent) ||
|
||||
isBreakOrContinueStatement(node.parent)) {
|
||||
return node.parent;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
// Valid References for a label
|
||||
|
||||
////[|label|]: while (true) {
|
||||
//// if (false) break [|label|];
|
||||
//// if (true) continue [|label|];
|
||||
////}
|
||||
////[|[|{| "declarationRangeIndex": 0 |}label|]: while (true) {
|
||||
//// if (false) [|break [|{| "declarationRangeIndex": 2 |}label|];|]
|
||||
//// if (true) [|continue [|{| "declarationRangeIndex": 4 |}label|];|]
|
||||
////}|]
|
||||
////
|
||||
////[|label|]: while (false) { }
|
||||
////[|[|{| "declarationRangeIndex": 6 |}label|]: while (false) { }|]
|
||||
////var label = "label";
|
||||
|
||||
const [r0, r1, r2, r3] = test.ranges();
|
||||
const [r0Def, r0, r1Def, r1, r2Def, r2, r3Def, r3] = test.ranges();
|
||||
verify.singleReferenceGroup("label", [r0, r1, r2]);
|
||||
verify.singleReferenceGroup("label", [r3]);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
// References to unused label
|
||||
|
||||
////[|label|]: while (true) {
|
||||
////[|[|{| "declarationRangeIndex": 0 |}label|]: while (true) {
|
||||
//// var label = "label";
|
||||
////}
|
||||
////}|]
|
||||
|
||||
verify.singleReferenceGroup("label");
|
||||
verify.singleReferenceGroup("label", "label");
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
// References to a label outside function bounderies
|
||||
|
||||
////[|label|]: function foo(label) {
|
||||
////[|[|{| "declarationRangeIndex": 0 |}label|]: function foo(label) {
|
||||
//// while (true) {
|
||||
//// break [|label|];
|
||||
//// [|break [|{| "declarationRangeIndex": 2 |}label|];|]
|
||||
//// }
|
||||
////}
|
||||
////}|]
|
||||
|
||||
verify.singleReferenceGroup("label");
|
||||
verify.singleReferenceGroup("label", "label");
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
// References to shadowed label
|
||||
|
||||
////[|label|]: while (true) {
|
||||
//// if (false) break [|label|];
|
||||
////[|[|{| "declarationRangeIndex": 0 |}label|]: while (true) {
|
||||
//// if (false) [|break [|{| "declarationRangeIndex": 2 |}label|];|]
|
||||
//// function blah() {
|
||||
////[|label|]: while (true) {
|
||||
//// if (false) break [|label|];
|
||||
//// }
|
||||
////[|[|{| "declarationRangeIndex": 4 |}label|]: while (true) {
|
||||
//// if (false) [|break [|{| "declarationRangeIndex": 6 |}label|];|]
|
||||
//// }|]
|
||||
//// }
|
||||
//// if (false) break [|label|];
|
||||
//// }
|
||||
//// if (false) [|break [|{| "declarationRangeIndex": 8 |}label|];|]
|
||||
//// }|]
|
||||
|
||||
const [outer1, outer2, inner1, inner2, outer3] = test.ranges();
|
||||
const [ourter1Def, outer1, outer2Def, outer2, inner1Def, inner1, inner2Def, inner2, outer3Def, outer3] = test.ranges();
|
||||
verify.singleReferenceGroup("label", [outer1, outer2, outer3]);
|
||||
verify.singleReferenceGroup("label", [inner1, inner2]);
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
// References to labels with close names
|
||||
|
||||
////[|labela|]: while (true) {
|
||||
////[|labelb|]: while (false) { break [|labelb|]; }
|
||||
////[|[|{| "declarationRangeIndex": 0 |}labela|]: while (true) {
|
||||
////[|[|{| "declarationRangeIndex": 2 |}labelb|]: while (false) { [|break [|{| "declarationRangeIndex": 4 |}labelb|];|] }|]
|
||||
//// break labelc;
|
||||
////}
|
||||
////}|]
|
||||
|
||||
verify.singleReferenceGroup("labela", "labela");
|
||||
verify.singleReferenceGroup("labelb", "labelb");
|
||||
|
|
Loading…
Reference in a new issue