mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
add template literal spans (#34699)
This commit is contained in:
1 parent
9cc0fcd3da
commit
234680851b
2 files changed
+30
No files matched your search
@@ -202,6 +202,9 @@ namespace ts.OutliningElementsCollector {
|
||||
case SyntaxKind.JsxSelfClosingElement:
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
return spanForJSXAttributes((<JsxOpeningLikeElement>n).attributes);
|
||||
case SyntaxKind.TemplateExpression:
|
||||
case SyntaxKind.NoSubstitutionTemplateLiteral:
|
||||
return spanForTemplateLiteral(<TemplateExpression | NoSubstitutionTemplateLiteral>n);
|
||||
}
|
||||
|
||||
function spanForJSXElement(node: JsxElement): OutliningSpan | undefined {
|
||||
@@ -225,6 +228,13 @@ namespace ts.OutliningElementsCollector {
|
||||
return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), OutliningSpanKind.Code);
|
||||
}
|
||||
|
||||
function spanForTemplateLiteral(node: TemplateExpression | NoSubstitutionTemplateLiteral) {
|
||||
if (node.kind === SyntaxKind.NoSubstitutionTemplateLiteral && node.text.length === 0) {
|
||||
return undefined;
|
||||
}
|
||||
return createOutliningSpanFromBounds(node.getStart(sourceFile), node.getEnd(), OutliningSpanKind.Code);
|
||||
}
|
||||
|
||||
function spanForObjectOrArrayLiteral(node: Node, open: SyntaxKind.OpenBraceToken | SyntaxKind.OpenBracketToken = SyntaxKind.OpenBraceToken): OutliningSpan | undefined {
|
||||
// If the block has no leading keywords and is inside an array literal or call expression,
|
||||
// we only want to collapse the span of the block.
|
||||
|
||||
Reference in new issue
Block a user