Added syntactic classification for templates; also made 'spans' a NodeArray.

This commit is contained in:
Daniel Rosenwasser
2014-10-24 17:14:41 -07:00
parent 799609c8e8
commit c03dc107ca
6 changed files with 58 additions and 3 deletions

View File

@@ -1406,13 +1406,17 @@ module ts {
template.head = parseLiteralNode();
Debug.assert(template.head.kind === SyntaxKind.TemplateHead, "Template head has wrong token kind");
var templateSpans: TemplateSpan[] = [];
var templateSpans = <NodeArray<TemplateSpan>>[];
templateSpans.pos = getNodePos();
do {
templateSpans.push(parseTemplateSpan());
}
while (templateSpans[templateSpans.length - 1].literal.kind === SyntaxKind.TemplateMiddle)
templateSpans.end = getNodeEnd();
template.templateSpans = templateSpans;
return finishNode(template);
}

View File

@@ -400,7 +400,7 @@ module ts {
export interface TemplateExpression extends Expression {
head: LiteralExpression;
templateSpans: TemplateSpan[]
templateSpans: NodeArray<TemplateSpan>;
}
export interface TemplateSpan extends Node {

View File

@@ -4901,6 +4901,10 @@ module ts {
// TODO: we should get another classification type for these literals.
return ClassificationTypeNames.stringLiteral;
}
else if (isTemplateLiteralKind(tokenKind)) {
// TODO (drosen): we should *also* get another classification type for these literals.
return ClassificationTypeNames.stringLiteral;
}
else if (tokenKind === SyntaxKind.Identifier) {
switch (token.parent.kind) {
case SyntaxKind.ClassDeclaration: