Fixed bug where tagged templates with a literal adjacent to EOF showed sig help.

This commit is contained in:
Daniel Rosenwasser 2014-11-25 14:37:40 -08:00
parent 44e6bcf7ff
commit 5fd0701ce5
7 changed files with 51 additions and 6 deletions

View File

@ -715,7 +715,7 @@ module ts {
};
}
}
function emitEnumDeclaration(node: EnumDeclaration) {
if (resolver.isDeclarationVisible(node)) {
emitJsDocComments(node);
@ -3558,7 +3558,7 @@ module ts {
return leadingComments;
}
function getLeadingCommentsToEmit(node: Node) {
// Emit the leading comments only if the parent's pos doesn't match because parent should take care of emitting these comments
if (node.parent.kind === SyntaxKind.SourceFile || node.pos !== node.parent.pos) {

View File

@ -823,9 +823,10 @@ module ts {
return false;
}
// If we didn't end in a backtick, we must still be in the middle of a template.
// If we did, make sure that it's not the *initial* backtick.
return sourceText.charCodeAt(node.end - 1) !== CharacterCodes.backtick || node.text.length === 0;
// If we didn't end in a backtick, we must still be in the middle of a template literal,
// but if it's the *initial* backtick (whereby the token is 1 char long), then it's unclosed.
var width = node.end - getTokenPosOfNode(node);
return width < 2 || sourceText.charCodeAt(node.end - 1) !== CharacterCodes.backtick;
}
export function isModifier(token: SyntaxKind): boolean {

View File

@ -296,7 +296,7 @@ module ts.SignatureHelp {
Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression);
// If we're just after a template tail, don't show signature help.
if (node.kind === SyntaxKind.TemplateTail && position >= node.getEnd() && !isUnterminatedTemplateEnd(<LiteralExpression>node)) {
if (node.kind === SyntaxKind.TemplateTail && !isInsideTemplateLiteral(<LiteralExpression>node, position)) {
return undefined;
}

View File

@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
//// function foo(strs, ...rest) {
//// }
////
//// /*1*/fo/*2*/o /*3*/`abcd${0 + 1}abcd{1 + 1}`/*4*/ /*5*/
test.markers().forEach(m => {
goTo.position(m.position);
verify.not.signatureHelpPresent();
});

View File

@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
//// function foo(strs, ...rest) {
//// }
////
//// /*1*/fo/*2*/o /*3*/`abcd${0 + 1}abcd{1 + 1}abcd`/*4*/ /*5*/
test.markers().forEach(m => {
goTo.position(m.position);
verify.not.signatureHelpPresent();
});

View File

@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
//// function foo(strs, ...rest) {
//// }
////
//// /*1*/fo/*2*/o /*3*/``/*4*/ /*5*/
test.markers().forEach(m => {
goTo.position(m.position);
verify.not.signatureHelpPresent();
});

View File

@ -0,0 +1,11 @@
/// <reference path='fourslash.ts' />
//// function foo(strs, ...rest) {
//// }
////
//// /*1*/fo/*2*/o /*3*/`abcd`/*4*/ /*5*/
test.markers().forEach(m => {
goTo.position(m.position);
verify.not.signatureHelpPresent();
});