mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 04:43:37 -05:00
Add outlining spans for case clauses (#37374)
* Add outlining spans for case clauses * Update old test * Update other test * Update yet another of the same test
This commit is contained in:
@@ -200,6 +200,9 @@ namespace ts.OutliningElementsCollector {
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
case SyntaxKind.CaseBlock:
|
||||
return spanForNode(n);
|
||||
case SyntaxKind.CaseClause:
|
||||
case SyntaxKind.DefaultClause:
|
||||
return spanForNodeArray((n as CaseClause | DefaultClause).statements);
|
||||
case SyntaxKind.ObjectLiteralExpression:
|
||||
return spanForObjectOrArrayLiteral(n);
|
||||
case SyntaxKind.ArrayLiteralExpression:
|
||||
@@ -256,6 +259,10 @@ namespace ts.OutliningElementsCollector {
|
||||
const closeToken = findChildOfKind(n, close, sourceFile);
|
||||
return openToken && closeToken && spanBetweenTokens(openToken, closeToken, hintSpanNode, sourceFile, autoCollapse, useFullStart);
|
||||
}
|
||||
|
||||
function spanForNodeArray(nodeArray: NodeArray<Node>): OutliningSpan | undefined {
|
||||
return nodeArray.length ? createOutliningSpan(createTextSpanFromRange(nodeArray), OutliningSpanKind.Code) : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function functionSpan(node: FunctionLike, body: Block, sourceFile: SourceFile): OutliningSpan | undefined {
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
//// }|]
|
||||
//// }|])
|
||||
////switch(1)[| {
|
||||
//// case 1: break;
|
||||
//// case 1:[| break;|]
|
||||
////}|]
|
||||
////
|
||||
////var array =[| [
|
||||
|
||||
37
tests/cases/fourslash/outliningSpansSwitchCases.ts
Normal file
37
tests/cases/fourslash/outliningSpansSwitchCases.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
////switch (undefined)[| {
|
||||
//// case 0:[|
|
||||
//// console.log(1)
|
||||
//// console.log(2)
|
||||
//// break;
|
||||
//// console.log(3);|]
|
||||
//// case 1:[|
|
||||
//// break;|]
|
||||
//// case 2:[|
|
||||
//// break;
|
||||
//// console.log(3);|]
|
||||
//// case 3:[|
|
||||
//// console.log(4);|]
|
||||
////
|
||||
//// case 4:
|
||||
//// case 5:
|
||||
//// case 6:[|
|
||||
////
|
||||
////
|
||||
//// console.log(5);|]
|
||||
////
|
||||
//// case 7:[| console.log(6);|]
|
||||
////
|
||||
//// case 8:[| [|{
|
||||
//// console.log(8);
|
||||
//// break;
|
||||
//// }|]
|
||||
//// console.log(8);|]
|
||||
////
|
||||
//// default:[|
|
||||
//// console.log(7);
|
||||
//// console.log(8);|]
|
||||
////}|]
|
||||
|
||||
verify.outliningSpansInCurrentFile(test.ranges(), "code");
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
/// <reference path="../fourslash.ts"/>
|
||||
|
||||
////// interface
|
||||
////interface IFoo[| {
|
||||
@@ -26,7 +26,7 @@
|
||||
//// }|]
|
||||
////}|]
|
||||
////switch(1)[| {
|
||||
//// case 1: break;
|
||||
//// case 1:[| break;|]
|
||||
////}|]
|
||||
////
|
||||
////var array =[| [
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
//// }|]
|
||||
////}|]
|
||||
////switch(1)[| {
|
||||
//// case 1: break;
|
||||
//// case 1:[| break;|]
|
||||
////}|]
|
||||
////
|
||||
////var array =[| [
|
||||
|
||||
Reference in New Issue
Block a user