mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-18 07:29:16 -05:00
add template literal spans (#34699)
This commit is contained in:
committed by
Daniel Rosenwasser
parent
9cc0fcd3da
commit
234680851b
@@ -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