From 1532f721d0c217ae63d8a07ad1a2da8ce75f8216 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 11 Nov 2014 13:58:50 -0800 Subject: [PATCH 01/16] Initial signature help work for tagged templates. --- src/compiler/parser.ts | 9 ++ src/compiler/types.ts | 2 +- src/services/signatureHelp.ts | 198 +++++++++++++++++++++++----------- 3 files changed, 145 insertions(+), 64 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 132213f950a..b50eccee0c1 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -467,6 +467,15 @@ module ts { } } + export function getInvoker(node: CallLikeExpression): Expression { + if (node.kind === SyntaxKind.TaggedTemplateExpression) { + return (node).tag; + } + else { + return (node).func; + } + } + export function isExpression(node: Node): boolean { switch (node.kind) { case SyntaxKind.ThisKeyword: diff --git a/src/compiler/types.ts b/src/compiler/types.ts index d7d4ba48b08..ffb451080f7 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -720,7 +720,7 @@ module ts { getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; getContextualType(node: Node): Type; - getResolvedSignature(node: CallExpression, candidatesOutArray?: Signature[]): Signature; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; isUndefinedSymbol(symbol: Symbol): boolean; diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 41f64c1b8db..a8d2b40af5d 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -164,6 +164,20 @@ module ts.SignatureHelp { //} var emptyArray: any[] = []; + export const enum ArgumentListKind { + TypeArguments, + CallArguments, + TaggedTemplateArguments + } + + export interface ArgumentListInfo { + kind: ArgumentListKind; + invocation: CallLikeExpression; + arguments: Node | NodeArray; + argumentIndex: number; + argumentCount: number; + } + export function getSignatureHelpItems(sourceFile: SourceFile, position: number, typeInfoResolver: TypeChecker, cancellationToken: CancellationTokenObject): SignatureHelpItems { // Decide whether to show signature help var startingToken = findTokenOnLeftOfPosition(sourceFile, position); @@ -180,7 +194,7 @@ module ts.SignatureHelp { return undefined; } - var call = argumentInfo.list.parent; + var call: CallLikeExpression = argumentInfo.invocation; var candidates = []; var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates); cancellationToken.throwIfCancellationRequested(); @@ -195,47 +209,109 @@ module ts.SignatureHelp { * If node is an argument, returns its index in the argument list. * If not, returns -1. */ - function getImmediatelyContainingArgumentInfo(node: Node): ListItemInfo { - if (node.parent.kind !== SyntaxKind.CallExpression && node.parent.kind !== SyntaxKind.NewExpression) { - return undefined; - } + function getImmediatelyContainingArgumentInfo(node: Node): ArgumentListInfo { + var callLikeExpr: CallLikeExpression; - // There are 3 cases to handle: - // 1. The token introduces a list, and should begin a sig help session - // 2. The token is either not associated with a list, or ends a list, so the session should end - // 3. The token is buried inside a list, and should give sig help - // - // The following are examples of each: - // - // Case 1: - // foo<$T, U>($a, b) -> The token introduces a list, and should begin a sig help session - // Case 2: - // fo$o$(a, b)$ -> The token is either not associated with a list, or ends a list, so the session should end - // Case 3: - // foo(a$, $b$) -> The token is buried inside a list, and should give sig help - var parent = node.parent; - // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === SyntaxKind.LessThanToken || node.kind === SyntaxKind.OpenParenToken) { - // Find the list that starts right *after* the < or ( token. - // If the user has just opened a list, consider this item 0. - var list = getChildListThatStartsWithOpenerToken(parent, node, sourceFile); - Debug.assert(list !== undefined); - return { - list: list, - listItemIndex: 0 - }; - } + if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) { + var callExpression = node.parent; + // There are 3 cases to handle: + // 1. The token introduces a list, and should begin a sig help session + // 2. The token is either not associated with a list, or ends a list, so the session should end + // 3. The token is buried inside a list, and should give sig help + // + // The following are examples of each: + // + // Case 1: + // foo<#T, U>(#a, b) -> The token introduces a list, and should begin a sig help session + // Case 2: + // fo#o#(a, b)# -> The token is either not associated with a list, or ends a list, so the session should end + // Case 3: + // foo(a#, #b#) -> The token is buried inside a list, and should give sig help + // Find out if 'node' is an argument, a type argument, or neither + if (node.kind === SyntaxKind.LessThanToken || + node.kind === SyntaxKind.OpenParenToken) { + // Find the list that starts right *after* the < or ( token. + // If the user has just opened a list, consider this item 0. + var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + Debug.assert(list !== undefined); + return { + kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments, + invocation: callExpression, + arguments: list, + argumentIndex: 0, + argumentCount: getCommaBasedArgCount(list) + }; + } - // findListItemInfo can return undefined if we are not in parent's argument list - // or type argument list. This includes cases where the cursor is: - // - To the right of the closing paren - // - Between the type arguments and the arguments (greater than token) - // - On the target of the call (parent.func) - // - On the 'new' keyword in a 'new' expression - return findListItemInfo(node); + // findListItemInfo can return undefined if we are not in parent's argument list + // or type argument list. This includes cases where the cursor is: + // - To the right of the closing paren, non-substitution template, or template tail. + // - Between the type arguments and the arguments (greater than token) + // - On the target of the call (parent.func) + // - On the 'new' keyword in a 'new' expression + var listItemInfo = findListItemInfo(node); + if (listItemInfo) { + var list = listItemInfo.list; + var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + return { + kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments, + invocation: callExpression, + arguments: list, + argumentIndex: (listItemInfo.listItemIndex + 1) >> 1, + argumentCount: getCommaBasedArgCount(list) + }; + } + } + else if (node.parent.kind === SyntaxKind.TemplateExpression && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { + Debug.assert(node.kind === SyntaxKind.TemplateHead, "Expected 'TemplateHead' as token."); + + var templateExpression = node.parent; + var tagExpression = templateExpression.parent; + + // argumentIndex is 1 to adjust for the TemplateStringsArray + return getArgumentListInfoForTemplate(tagExpression, templateExpression.templateSpans, /*argumentIndex*/ 1); + } + else if (node.parent.kind === SyntaxKind.TemplateSpan && node.parent.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { + var templateSpan = node.parent; + var templateExpression = templateSpan.parent; + var tagExpression = templateExpression.parent; + Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression); + + // We need to account for the TemplateStringsArray, so we add at least 1. + // Then, if we're on the template literal, we want to jump to the next argument, + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var adjustedIndex = isTemplateLiteralKind(node.kind) ? spanIndex + 2 : spanIndex + 1 + + return getArgumentListInfoForTemplate(tagExpression, templateExpression.templateSpans, adjustedIndex); + } + + return undefined; } - function getContainingArgumentInfo(node: Node): ListItemInfo { + function getArgumentListInfoForTemplate(tagExpression: TaggedTemplateExpression, spans: NodeArray, argumentIndex: number): ArgumentListInfo { + var argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral + ? 1 + : (tagExpression.template).templateSpans.length + 1; + + return { + kind: ArgumentListKind.TaggedTemplateArguments, + invocation: tagExpression, + arguments: spans, + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + + // The number of arguments is the number of commas plus one, unless the list + // is completely empty, in which case there are 0 arguments. + function getCommaBasedArgCount(argumentsList: Node) { + return argumentsList.getChildCount() === 0 + ? 0 + : 1 + countWhere(argumentsList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken); + } + + function getContainingArgumentInfo(node: Node): ArgumentListInfo { for (var n = node; n.kind !== SyntaxKind.SourceFile; n = n.parent) { if (n.kind === SyntaxKind.FunctionBlock) { return undefined; @@ -292,15 +368,14 @@ module ts.SignatureHelp { return maxParamsSignatureIndex; } - function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentInfoOrTypeArgumentInfo: ListItemInfo): SignatureHelpItems { - var argumentListOrTypeArgumentList = argumentInfoOrTypeArgumentInfo.list; - var parent = argumentListOrTypeArgumentList.parent; - var isTypeParameterHelp = parent.typeArguments && parent.typeArguments.pos === argumentListOrTypeArgumentList.pos; - Debug.assert(isTypeParameterHelp || parent.arguments.pos === argumentListOrTypeArgumentList.pos); + function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentListInfo: ArgumentListInfo): SignatureHelpItems { + var argumentsList = argumentListInfo.arguments; + var isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments; - var callTargetNode = (argumentListOrTypeArgumentList.parent).func; - var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTargetNode); - var callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); + var invocation = argumentListInfo.invocation; + var invokerNode = getInvoker(invocation) + var invokerSymbol = typeInfoResolver.getSymbolInfo(invokerNode); + var callTargetDisplayParts = invokerSymbol && symbolToDisplayParts(typeInfoResolver, invokerSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items: SignatureHelpItem[] = map(candidates, candidateSignature => { var signatureHelpParameters: SignatureHelpParameter[]; var prefixParts: SymbolDisplayPart[] = []; @@ -310,18 +385,18 @@ module ts.SignatureHelp { prefixParts.push.apply(prefixParts, callTargetDisplayParts); } - if (isTypeParameterHelp) { + if (isTypeParameterList) { prefixParts.push(punctuationPart(SyntaxKind.LessThanToken)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; suffixParts.push(punctuationPart(SyntaxKind.GreaterThanToken)); var parameterParts = mapToDisplayParts(writer => - typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, argumentListOrTypeArgumentList)); + typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.parameters, writer, invocation)); suffixParts.push.apply(suffixParts, parameterParts); } else { var typeParameterParts = mapToDisplayParts(writer => - typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, argumentListOrTypeArgumentList)); + typeInfoResolver.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation)); prefixParts.push.apply(prefixParts, typeParameterParts); prefixParts.push(punctuationPart(SyntaxKind.OpenParenToken)); var parameters = candidateSignature.parameters; @@ -330,7 +405,7 @@ module ts.SignatureHelp { } var returnTypeParts = mapToDisplayParts(writer => - typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, argumentListOrTypeArgumentList)); + typeInfoResolver.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation)); suffixParts.push.apply(suffixParts, returnTypeParts); return { @@ -351,26 +426,23 @@ module ts.SignatureHelp { // // The applicable span is from the first bar to the second bar (inclusive, // but not including parentheses) - var applicableSpanStart = argumentListOrTypeArgumentList.getFullStart(); - var applicableSpanEnd = skipTrivia(sourceFile.text, argumentListOrTypeArgumentList.end, /*stopAfterLineBreak*/ false); + var applicableSpanStart = argumentsList.pos; + var applicableSpanEnd = skipTrivia(sourceFile.text, argumentsList.end, /*stopAfterLineBreak*/ false); var applicableSpan = new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); // The listItemIndex we got back includes commas. Our goal is to return the index of the proper // item (not including commas). Here are some examples: - // 1. foo(a, b, c $) -> the listItemIndex is 4, we want to return 2 - // 2. foo(a, b, $ c) -> listItemIndex is 3, we want to return 2 - // 3. foo($a) -> listItemIndex is 0, we want to return 0 + // 1. foo(a, b, c #) -> the listItemIndex is 4, we want to return 2 + // 2. foo(a, b, # c) -> listItemIndex is 3, we want to return 2 + // 3. foo(#a) -> listItemIndex is 0, we want to return 0 // // In general, we want to subtract the number of commas before the current index. // But if we are on a comma, we also want to pretend we are on the argument *following* // the comma. That amounts to taking the ceiling of half the index. - var argumentIndex = (argumentInfoOrTypeArgumentInfo.listItemIndex + 1) >> 1; + var argumentIndex = argumentListInfo.argumentIndex; - // argumentCount is the number of commas plus one, unless the list is completely empty, - // in which case there are 0. - var argumentCount = argumentListOrTypeArgumentList.getChildCount() === 0 - ? 0 - : 1 + countWhere(argumentListOrTypeArgumentList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken); + // argumentCount is the *apparent* number of arguments. + var argumentCount = argumentListInfo.argumentCount; var selectedItemIndex = candidates.indexOf(bestSignature); if (selectedItemIndex < 0) { @@ -387,7 +459,7 @@ module ts.SignatureHelp { function createSignatureHelpParameterForParameter(parameter: Symbol): SignatureHelpParameter { var displayParts = mapToDisplayParts(writer => - typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, argumentListOrTypeArgumentList)); + typeInfoResolver.getSymbolDisplayBuilder().buildParameterDisplay(parameter, writer, invocation)); var isOptional = !!(parameter.valueDeclaration.flags & NodeFlags.QuestionMark); @@ -401,7 +473,7 @@ module ts.SignatureHelp { function createSignatureHelpParameterForTypeParameter(typeParameter: TypeParameter): SignatureHelpParameter { var displayParts = mapToDisplayParts(writer => - typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, argumentListOrTypeArgumentList)); + typeInfoResolver.getSymbolDisplayBuilder().buildTypeParameterDisplay(typeParameter, writer, invocation)); return { name: typeParameter.symbol.name, From 15560a80eaa968124dcd8dd229c44d36b69f00e4 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 12 Nov 2014 16:30:25 -0800 Subject: [PATCH 02/16] Stylistic changes/comment fixups. --- src/compiler/parser.ts | 2 +- src/services/signatureHelp.ts | 41 ++++++++++++++++++++--------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 005a5218d56..05ee465e94d 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -471,7 +471,7 @@ module ts { } } - export function getInvoker(node: CallLikeExpression): Expression { + export function getCallLikeInvoker(node: CallLikeExpression): Expression { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index a8d2b40af5d..8a6e8475f5d 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -174,7 +174,7 @@ module ts.SignatureHelp { kind: ArgumentListKind; invocation: CallLikeExpression; arguments: Node | NodeArray; - argumentIndex: number; + argumentIndex?: number; argumentCount: number; } @@ -194,7 +194,7 @@ module ts.SignatureHelp { return undefined; } - var call: CallLikeExpression = argumentInfo.invocation; + var call = argumentInfo.invocation; var candidates = []; var resolvedSignature = typeInfoResolver.getResolvedSignature(call, candidates); cancellationToken.throwIfCancellationRequested(); @@ -254,16 +254,30 @@ module ts.SignatureHelp { if (listItemInfo) { var list = listItemInfo.list; var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; + + // The listItemIndex we got back includes commas. Our goal is to return the index of the proper + // item (not including commas). Here are some examples: + // 1. foo(a, b, c #) -> the listItemIndex is 4, we want to return 2 + // 2. foo(a, b, # c) -> listItemIndex is 3, we want to return 2 + // 3. foo(#a) -> listItemIndex is 0, we want to return 0 + // + // In general, we want to subtract the number of commas before the current index. + // But if we are on a comma, we also want to pretend we are on the argument *following* + // the comma. That amounts to taking the ceiling of half the index. + var argumentIndex = (listItemInfo.listItemIndex + 1) >> 1; + return { kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments, invocation: callExpression, arguments: list, - argumentIndex: (listItemInfo.listItemIndex + 1) >> 1, + argumentIndex: argumentIndex, argumentCount: getCommaBasedArgCount(list) }; } } else if (node.parent.kind === SyntaxKind.TemplateExpression && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { + // TODO (drosen): Can't get sig help to trigger within the template head itself; only when directly to the right. + // Also, need to ensure that this works on NoSubstitutionTemplateExpressions when unterminated. Debug.assert(node.kind === SyntaxKind.TemplateHead, "Expected 'TemplateHead' as token."); var templateExpression = node.parent; @@ -303,9 +317,9 @@ module ts.SignatureHelp { }; } - // The number of arguments is the number of commas plus one, unless the list - // is completely empty, in which case there are 0 arguments. function getCommaBasedArgCount(argumentsList: Node) { + // The number of arguments is the number of commas plus one, unless the list + // is completely empty, in which case there are 0 arguments. return argumentsList.getChildCount() === 0 ? 0 : 1 + countWhere(argumentsList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken); @@ -373,16 +387,16 @@ module ts.SignatureHelp { var isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments; var invocation = argumentListInfo.invocation; - var invokerNode = getInvoker(invocation) + var invokerNode = getCallLikeInvoker(invocation) var invokerSymbol = typeInfoResolver.getSymbolInfo(invokerNode); - var callTargetDisplayParts = invokerSymbol && symbolToDisplayParts(typeInfoResolver, invokerSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); + var invokerDisplayParts = invokerSymbol && symbolToDisplayParts(typeInfoResolver, invokerSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items: SignatureHelpItem[] = map(candidates, candidateSignature => { var signatureHelpParameters: SignatureHelpParameter[]; var prefixParts: SymbolDisplayPart[] = []; var suffixParts: SymbolDisplayPart[] = []; - if (callTargetDisplayParts) { - prefixParts.push.apply(prefixParts, callTargetDisplayParts); + if (invokerDisplayParts) { + prefixParts.push.apply(prefixParts, invokerDisplayParts); } if (isTypeParameterList) { @@ -430,15 +444,6 @@ module ts.SignatureHelp { var applicableSpanEnd = skipTrivia(sourceFile.text, argumentsList.end, /*stopAfterLineBreak*/ false); var applicableSpan = new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); - // The listItemIndex we got back includes commas. Our goal is to return the index of the proper - // item (not including commas). Here are some examples: - // 1. foo(a, b, c #) -> the listItemIndex is 4, we want to return 2 - // 2. foo(a, b, # c) -> listItemIndex is 3, we want to return 2 - // 3. foo(#a) -> listItemIndex is 0, we want to return 0 - // - // In general, we want to subtract the number of commas before the current index. - // But if we are on a comma, we also want to pretend we are on the argument *following* - // the comma. That amounts to taking the ceiling of half the index. var argumentIndex = argumentListInfo.argumentIndex; // argumentCount is the *apparent* number of arguments. From 64960cf873353b94e51107a3457c3dd8279dee73 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 14 Nov 2014 17:13:00 -0800 Subject: [PATCH 03/16] Got sig help working in the template head. --- src/services/signatureHelp.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 8a6e8475f5d..a131bff919f 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -173,7 +173,7 @@ module ts.SignatureHelp { export interface ArgumentListInfo { kind: ArgumentListKind; invocation: CallLikeExpression; - arguments: Node | NodeArray; + argumentRange: TextRange; argumentIndex?: number; argumentCount: number; } @@ -238,7 +238,7 @@ module ts.SignatureHelp { return { kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments, invocation: callExpression, - arguments: list, + argumentRange: list, argumentIndex: 0, argumentCount: getCommaBasedArgCount(list) }; @@ -269,22 +269,20 @@ module ts.SignatureHelp { return { kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments, invocation: callExpression, - arguments: list, + argumentRange: list, argumentIndex: argumentIndex, argumentCount: getCommaBasedArgCount(list) }; } } else if (node.parent.kind === SyntaxKind.TemplateExpression && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { - // TODO (drosen): Can't get sig help to trigger within the template head itself; only when directly to the right. - // Also, need to ensure that this works on NoSubstitutionTemplateExpressions when unterminated. Debug.assert(node.kind === SyntaxKind.TemplateHead, "Expected 'TemplateHead' as token."); var templateExpression = node.parent; var tagExpression = templateExpression.parent; // argumentIndex is 1 to adjust for the TemplateStringsArray - return getArgumentListInfoForTemplate(tagExpression, templateExpression.templateSpans, /*argumentIndex*/ 1); + return getArgumentListInfoForTemplate(tagExpression, /*argumentIndex*/ 1); } else if (node.parent.kind === SyntaxKind.TemplateSpan && node.parent.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { var templateSpan = node.parent; @@ -297,13 +295,13 @@ module ts.SignatureHelp { var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); var adjustedIndex = isTemplateLiteralKind(node.kind) ? spanIndex + 2 : spanIndex + 1 - return getArgumentListInfoForTemplate(tagExpression, templateExpression.templateSpans, adjustedIndex); + return getArgumentListInfoForTemplate(tagExpression, adjustedIndex); } return undefined; } - function getArgumentListInfoForTemplate(tagExpression: TaggedTemplateExpression, spans: NodeArray, argumentIndex: number): ArgumentListInfo { + function getArgumentListInfoForTemplate(tagExpression: TaggedTemplateExpression, argumentIndex: number): ArgumentListInfo { var argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral ? 1 : (tagExpression.template).templateSpans.length + 1; @@ -311,7 +309,7 @@ module ts.SignatureHelp { return { kind: ArgumentListKind.TaggedTemplateArguments, invocation: tagExpression, - arguments: spans, + argumentRange: tagExpression.template, argumentIndex: argumentIndex, argumentCount: argumentCount }; @@ -383,7 +381,7 @@ module ts.SignatureHelp { } function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentListInfo: ArgumentListInfo): SignatureHelpItems { - var argumentsList = argumentListInfo.arguments; + var argumentsList = argumentListInfo.argumentRange; var isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments; var invocation = argumentListInfo.invocation; From 6f8f79efe2aa706817c865ed838ecc7d0c7a6b2b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Fri, 14 Nov 2014 17:30:19 -0800 Subject: [PATCH 04/16] Got sig help working in tagged no-sub templates. --- src/services/signatureHelp.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index a131bff919f..fc62ff34d0a 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -275,6 +275,9 @@ module ts.SignatureHelp { }; } } + else if (node.kind === SyntaxKind.NoSubstitutionTemplateLiteral && node.parent.kind === SyntaxKind.TaggedTemplateExpression) { + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); + } else if (node.parent.kind === SyntaxKind.TemplateExpression && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { Debug.assert(node.kind === SyntaxKind.TemplateHead, "Expected 'TemplateHead' as token."); From 34087bd9ec9a99a0cda613768356256f2a17ffa3 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 17 Nov 2014 15:13:58 -0800 Subject: [PATCH 05/16] Refactored code, adjusted for residing out of bounds of the template. --- src/compiler/parser.ts | 2 +- src/services/signatureHelp.ts | 142 +++++++++++++++++++++++----------- src/services/utilities.ts | 5 ++ 3 files changed, 103 insertions(+), 46 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a3626caa0a3..804f8c9780c 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -811,7 +811,7 @@ module ts { } export function isUnterminatedTemplateEnd(node: LiteralExpression) { - Debug.assert(node.kind === SyntaxKind.NoSubstitutionTemplateLiteral || node.kind === SyntaxKind.TemplateTail); + Debug.assert(isTemplateLiteralKind(node.kind)); var sourceText = getSourceFileOfNode(node).text; // If we're not at the EOF, we know we must be terminated. diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index fc62ff34d0a..bba70da4627 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -173,7 +173,7 @@ module ts.SignatureHelp { export interface ArgumentListInfo { kind: ArgumentListKind; invocation: CallLikeExpression; - argumentRange: TextRange; + argumentsSpan: TypeScript.TextSpan; argumentIndex?: number; argumentCount: number; } @@ -186,7 +186,7 @@ module ts.SignatureHelp { return undefined; } - var argumentInfo = getContainingArgumentInfo(startingToken); + var argumentInfo = getContainingArgumentInfo(startingToken, position); cancellationToken.throwIfCancellationRequested(); // Semantic filtering of signature help @@ -209,7 +209,7 @@ module ts.SignatureHelp { * If node is an argument, returns its index in the argument list. * If not, returns -1. */ - function getImmediatelyContainingArgumentInfo(node: Node): ArgumentListInfo { + function getImmediatelyContainingArgumentInfo(node: Node, position: number): ArgumentListInfo { var callLikeExpr: CallLikeExpression; if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) { @@ -238,7 +238,7 @@ module ts.SignatureHelp { return { kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments, invocation: callExpression, - argumentRange: list, + argumentsSpan: getApplicableSpanForArguments(list), argumentIndex: 0, argumentCount: getCommaBasedArgCount(list) }; @@ -269,23 +269,25 @@ module ts.SignatureHelp { return { kind: isTypeArgList ? ArgumentListKind.TypeArguments : ArgumentListKind.CallArguments, invocation: callExpression, - argumentRange: list, + argumentsSpan: getApplicableSpanForArguments(list), argumentIndex: argumentIndex, argumentCount: getCommaBasedArgCount(list) }; } } else if (node.kind === SyntaxKind.NoSubstitutionTemplateLiteral && node.parent.kind === SyntaxKind.TaggedTemplateExpression) { - return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); + // Check if we're actually inside the template; + // otherwise we'll fall out and return undefined. + if (isInsideTemplateLiteral(node, position)) { + return getArgumentListInfoForTemplate(node.parent, /*argumentIndex*/ 0); + } } - else if (node.parent.kind === SyntaxKind.TemplateExpression && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { - Debug.assert(node.kind === SyntaxKind.TemplateHead, "Expected 'TemplateHead' as token."); - + else if (node.kind === SyntaxKind.TemplateHead && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; + var argumentIndex = getArgumentIndexForTemplatePiece(/*spanIndex*/ 0, node, position); - // argumentIndex is 1 to adjust for the TemplateStringsArray - return getArgumentListInfoForTemplate(tagExpression, /*argumentIndex*/ 1); + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } else if (node.parent.kind === SyntaxKind.TemplateSpan && node.parent.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { var templateSpan = node.parent; @@ -293,31 +295,25 @@ module ts.SignatureHelp { var tagExpression = templateExpression.parent; Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression); - // We need to account for the TemplateStringsArray, so we add at least 1. - // Then, if we're on the template literal, we want to jump to the next argument, - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var adjustedIndex = isTemplateLiteralKind(node.kind) ? spanIndex + 2 : spanIndex + 1 + // If we're just after a template tail, don't show signature help. + if (node.kind === SyntaxKind.TemplateTail && position >= node.getEnd() && !isUnterminatedTemplateEnd(node)) { + return undefined; + } - return getArgumentListInfoForTemplate(tagExpression, adjustedIndex); + // The cursor can either be in or after the template literal. + // If inside, we want to highlight the first argument. + // If after, we'll want to highlight the next parameter. + // We actually shouldn't be able to show up before because you should be at the left-most token. + + var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); + + return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } return undefined; } - function getArgumentListInfoForTemplate(tagExpression: TaggedTemplateExpression, argumentIndex: number): ArgumentListInfo { - var argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral - ? 1 - : (tagExpression.template).templateSpans.length + 1; - - return { - kind: ArgumentListKind.TaggedTemplateArguments, - invocation: tagExpression, - argumentRange: tagExpression.template, - argumentIndex: argumentIndex, - argumentCount: argumentCount - }; - } - function getCommaBasedArgCount(argumentsList: Node) { // The number of arguments is the number of commas plus one, unless the list // is completely empty, in which case there are 0 arguments. @@ -326,7 +322,75 @@ module ts.SignatureHelp { : 1 + countWhere(argumentsList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken); } - function getContainingArgumentInfo(node: Node): ArgumentListInfo { + // spanIndex is either the index for a given template span, or 0 for a template head. + // This does not give appropriate results for a NoSubstitutionTemplateLiteral + function getArgumentIndexForTemplatePiece(spanIndex: number, node: Node, position: number): number { + // TemplateSpans are expression-template pairs, and ordered as such. + // Because of the TemplateStringsArray arg, we have to offset ourselves by 1 for substitution expressions. + // There are three cases we can encounter: + // 1. We are precisely in the template literal (argIndex = 0) + // 2. We are in or to the right of the substitution expression (argIndex = spanIndex + 1) + // 3. We are directly to the right of the template literal, but not + // enough to put us in the substitution expression; we should consider ourselves part of + // the *next* span's expression (argIndex = (spanIndex + 1) + 1). + // + // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` + // ^ ^ ^ ^ ^ ^ ^ ^ ^ + // Cases: 1 1 3 2 1 3 2 2 1 + Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); + if (isTemplateLiteralKind(node.kind)) { + if (isInsideTemplateLiteral(node, position)) { + return 0; + } + return spanIndex + 2; + } + return spanIndex + 1; + } + + function getArgumentListInfoForTemplate(tagExpression: TaggedTemplateExpression, argumentIndex: number): ArgumentListInfo { + var argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral + ? 1 + : (tagExpression.template).templateSpans.length + 1; + + return { + kind: ArgumentListKind.TaggedTemplateArguments, + invocation: tagExpression, + argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression.template), + argumentIndex: argumentIndex, + argumentCount: argumentCount + }; + } + + function getApplicableSpanForArguments(argumentsList: Node): TypeScript.TextSpan { + // We use full start and skip trivia on the end because we want to include trivia on + // both sides. For example, + // + // foo( /*comment */ a, b, c /*comment*/ ) + // | | + // + // The applicable span is from the first bar to the second bar (inclusive, + // but not including parentheses) + var applicableSpanStart = argumentsList.pos; + var applicableSpanEnd = skipTrivia(sourceFile.text, argumentsList.end, /*stopAfterLineBreak*/ false); + return new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + + function getApplicableSpanForTaggedTemplate(template: TemplateExpression | LiteralExpression): TypeScript.TextSpan { + var applicableSpanStart = template.getStart(); + var applicableSpanEnd = template.getEnd(); + + // Adjust the span end in case the template is unclosed - + if (template.kind === SyntaxKind.TemplateExpression) { + var lastSpan = lastOrUndefined((template).templateSpans); + if (lastSpan.literal.kind === SyntaxKind.Missing) { + applicableSpanEnd = skipTrivia(sourceFile.text, template.end, /*stopAfterLineBreak*/ false); + } + } + + return new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); + } + + function getContainingArgumentInfo(node: Node, position: number): ArgumentListInfo { for (var n = node; n.kind !== SyntaxKind.SourceFile; n = n.parent) { if (n.kind === SyntaxKind.FunctionBlock) { return undefined; @@ -338,7 +402,7 @@ module ts.SignatureHelp { Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); } - var argumentInfo = getImmediatelyContainingArgumentInfo(n); + var argumentInfo = getImmediatelyContainingArgumentInfo(n, position); if (argumentInfo) { return argumentInfo; } @@ -384,7 +448,7 @@ module ts.SignatureHelp { } function createSignatureHelpItems(candidates: Signature[], bestSignature: Signature, argumentListInfo: ArgumentListInfo): SignatureHelpItems { - var argumentsList = argumentListInfo.argumentRange; + var applicableSpan = argumentListInfo.argumentsSpan; var isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments; var invocation = argumentListInfo.invocation; @@ -433,18 +497,6 @@ module ts.SignatureHelp { }; }); - // We use full start and skip trivia on the end because we want to include trivia on - // both sides. For example, - // - // foo( /*comment */ a, b, c /*comment*/ ) - // | | - // - // The applicable span is from the first bar to the second bar (inclusive, - // but not including parentheses) - var applicableSpanStart = argumentsList.pos; - var applicableSpanEnd = skipTrivia(sourceFile.text, argumentsList.end, /*stopAfterLineBreak*/ false); - var applicableSpan = new TypeScript.TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); - var argumentIndex = argumentListInfo.argumentIndex; // argumentCount is the *apparent* number of arguments. diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 8620f8d1920..ab651491518 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -320,4 +320,9 @@ module ts { export function isPunctuation(kind: SyntaxKind): boolean { return SyntaxKind.FirstPunctuation <= kind && kind <= SyntaxKind.LastPunctuation; } + + export function isInsideTemplateLiteral(node: LiteralExpression, position: number) { + return (node.getStart() < position && position < node.getEnd()) + || (isUnterminatedTemplateEnd(node) && position >= node.getEnd()); + } } \ No newline at end of file From 0416c6fdb8923c5d4aef88bbee72bf523fd3f277 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 17 Nov 2014 15:31:58 -0800 Subject: [PATCH 06/16] Fixed isUnclosedTemplateLiteral to account for new possible inputs. --- src/compiler/parser.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 804f8c9780c..7db9b9101da 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -819,6 +819,11 @@ module ts { return false; } + // We can only be unclosed if we have a tail or a no-sub template. + if (node.kind !== SyntaxKind.TemplateTail && node.kind !== SyntaxKind.NoSubstitutionTemplateLiteral) { + 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; From 69f7d39d4373afdb17d7d7f637f069ab70433286 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 18 Nov 2014 13:40:42 -0800 Subject: [PATCH 07/16] Fixed template head offsetting. --- src/services/signatureHelp.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 223b523c42f..10c036dc38d 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -164,13 +164,17 @@ module ts.SignatureHelp { //} var emptyArray: any[] = []; - export const enum ArgumentListKind { + const enum Constants { + HeadSpanIndex = -1 + } + + const enum ArgumentListKind { TypeArguments, CallArguments, TaggedTemplateArguments } - export interface ArgumentListInfo { + interface ArgumentListInfo { kind: ArgumentListKind; invocation: CallLikeExpression; argumentsSpan: TextSpan; @@ -285,7 +289,7 @@ module ts.SignatureHelp { else if (node.kind === SyntaxKind.TemplateHead && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - var argumentIndex = getArgumentIndexForTemplatePiece(/*spanIndex*/ 0, node, position); + var argumentIndex = getArgumentIndexForTemplatePiece(Constants.HeadSpanIndex, node, position); return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } @@ -322,7 +326,7 @@ module ts.SignatureHelp { : 1 + countWhere(argumentsList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken); } - // spanIndex is either the index for a given template span, or 0 for a template head. + // spanIndex is either the index for a given template span, or Constants.HeadSpanIndex for a template head. // This does not give appropriate results for a NoSubstitutionTemplateLiteral function getArgumentIndexForTemplatePiece(spanIndex: number, node: Node, position: number): number { // TemplateSpans are expression-template pairs, and ordered as such. @@ -336,7 +340,7 @@ module ts.SignatureHelp { // // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ - // Cases: 1 1 3 2 1 3 2 2 1 + // Case: 1 1 3 2 1 3 2 2 1 Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node."); if (isTemplateLiteralKind(node.kind)) { if (isInsideTemplateLiteral(node, position)) { From 4e18efd25cb1460c667a1282c3f45964410d456a Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 18 Nov 2014 13:48:24 -0800 Subject: [PATCH 08/16] Tests for signature help on tagged templates with no overloads. --- .../fourslash/signatureHelpTaggedTemplates1.ts | 15 +++++++++++++++ .../fourslash/signatureHelpTaggedTemplates2.ts | 15 +++++++++++++++ .../fourslash/signatureHelpTaggedTemplates3.ts | 15 +++++++++++++++ .../fourslash/signatureHelpTaggedTemplates4.ts | 15 +++++++++++++++ .../fourslash/signatureHelpTaggedTemplates5.ts | 15 +++++++++++++++ .../fourslash/signatureHelpTaggedTemplates6.ts | 15 +++++++++++++++ .../fourslash/signatureHelpTaggedTemplates7.ts | 15 +++++++++++++++ .../signatureHelpTaggedTemplatesIncomplete1.ts | 15 +++++++++++++++ .../signatureHelpTaggedTemplatesIncomplete2.ts | 15 +++++++++++++++ .../signatureHelpTaggedTemplatesIncomplete3.ts | 15 +++++++++++++++ .../signatureHelpTaggedTemplatesIncomplete4.ts | 15 +++++++++++++++ .../signatureHelpTaggedTemplatesIncomplete5.ts | 15 +++++++++++++++ .../signatureHelpTaggedTemplatesIncomplete6.ts | 15 +++++++++++++++ .../signatureHelpTaggedTemplatesNegatives1.ts | 11 +++++++++++ .../signatureHelpTaggedTemplatesNested1.ts | 13 +++++++++++++ .../signatureHelpTaggedTemplatesNested2.ts | 14 ++++++++++++++ 16 files changed, 233 insertions(+) create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplates1.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplates2.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplates3.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplates4.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplates5.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplates6.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplates7.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives1.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts new file mode 100644 index 00000000000..457551f160a --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f `/*1*/ qwe/*2*/rty /*3*/$/*4*/{ 123 }/*5*/ as/*6*/df /*7*/$/*8*/{ 41234 }/*9*/ zxc/*10*/vb /*11*/$/*12*/{ g ` ` }/*13*/ /*14*/ /*15*/` + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("templateStrings"); + verify.currentParameterSpanIs("templateStrings: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts new file mode 100644 index 00000000000..fa29c21ff21 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f `/*1*/ qwe/*2*/rty /*3*/$/*4*/{ 123 }/*5*/ as/*6*/df /*7*/$/*8*/{ 41234 }/*9*/ zxc/*10*/vb /*11*/$/*12*/{ g ` ` }/*13*/ /*14*/ /*15*/ + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("templateStrings"); + verify.currentParameterSpanIs("templateStrings: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts new file mode 100644 index 00000000000..5670cadfd4e --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` qwerty ${/*1*/ /*2*/123/*3*/ /*4*/} asdf ${ 41234 } zxcvb ${ g ` ` } ` + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("x"); + verify.currentParameterSpanIs("x: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts new file mode 100644 index 00000000000..bbbd869de09 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` qwerty ${ 123 } asdf ${/*1*/ /*2*/ /*3*/41/*4*/234/*5*/ /*6*/} zxcvb ${ g ` ` } ` + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("y"); + verify.currentParameterSpanIs("y: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts new file mode 100644 index 00000000000..68a95121240 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${/*1*/ /*2*/g/*3*/ /*4*/` `/*5*/ /*6*/} ` + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("z"); + verify.currentParameterSpanIs("z: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts new file mode 100644 index 00000000000..c1080b3f7e5 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${ g `/*1*/ /*2*/ /*3*/` } ` + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('g(templateStrings: any, x: any, y: any, z: any): string'); + verify.currentParameterHelpArgumentNameIs("templateStrings"); + verify.currentParameterSpanIs("templateStrings: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts new file mode 100644 index 00000000000..eb25ac6f647 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f `/*1*/ /*2*/ + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("templateStrings"); + verify.currentParameterSpanIs("templateStrings: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts new file mode 100644 index 00000000000..65a250fce31 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f `/*1*/ /*2*/${ + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("templateStrings"); + verify.currentParameterSpanIs("templateStrings: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts new file mode 100644 index 00000000000..c2baa7b187d --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` ${/*1*/ /*2*/ + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("x"); + verify.currentParameterSpanIs("x: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts new file mode 100644 index 00000000000..ccaebc1f1b6 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` ${ }/*1*/ /*2*/ + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("templateStrings"); + verify.currentParameterSpanIs("templateStrings: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts new file mode 100644 index 00000000000..e220ec60679 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` ${ } ${/*1*/ /*2*/ + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("y"); + verify.currentParameterSpanIs("y: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts new file mode 100644 index 00000000000..1655841575d --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` ${ } ${ }/*1*/ /*2*/ + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("templateStrings"); + verify.currentParameterSpanIs("templateStrings: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts new file mode 100644 index 00000000000..67d81d6558e --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts @@ -0,0 +1,15 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f ` ${ 123 } ${/*1*/ } ` + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); + verify.currentParameterHelpArgumentNameIs("y"); + verify.currentParameterSpanIs("y: any"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives1.ts new file mode 100644 index 00000000000..c61f1a871e4 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNegatives1.ts @@ -0,0 +1,11 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// /*1*/f/*2*/ /*3*/` qwerty ${ 123 } asdf ${ 41234 } zxcvb ${ g ` ` } `/*4*/ + +test.markers().forEach(m => { + goTo.position(m.position); + verify.not.signatureHelpPresent(); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts new file mode 100644 index 00000000000..934bea21ed5 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts @@ -0,0 +1,13 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f `a ${ g `/*1*/alpha/*2*/ ${/*3*/ 12/*4*/3 /*5*/} beta /*6*/${ /*7*/456 /*8*/} gamma/*9*/` } b ${ g `/*10*/txt/*11*/` } c ${ g `/*12*/aleph /*13*/$/*14*/{ 12/*15*/3 } beit/*16*/` } d`; + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('g(templateStrings: any, x: any, y: any, z: any): string'); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts new file mode 100644 index 00000000000..9ff5103f30a --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts @@ -0,0 +1,14 @@ +/// + +//// function f(templateStrings, x, y, z) { return 10; } +//// function g(templateStrings, x, y, z) { return ""; } +//// +//// f `/*1*/a $/*2*/{ /*3*/g /*4*/`alpha ${ 123 } beta ${ 456 } gamma`/*5*/ }/*6*/ b $/*7*/{ /*8*/g /*9*/`txt`/*10*/ } /*11*/c ${ /*12*/g /*13*/`aleph ${ 123 } beit`/*14*/ } d/*15*/`; +debugger; + +test.markers().forEach(m => { + goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); +}); \ No newline at end of file From dfe79621fe508a42ebc5a10cc87057ff95147aed Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 18 Nov 2014 17:41:58 -0800 Subject: [PATCH 09/16] Added tests for overloads. --- .../signatureHelpTaggedTemplates1.ts | 3 +++ .../signatureHelpTaggedTemplates2.ts | 3 +++ .../signatureHelpTaggedTemplates3.ts | 3 +++ .../signatureHelpTaggedTemplates4.ts | 3 +++ .../signatureHelpTaggedTemplates5.ts | 3 +++ .../signatureHelpTaggedTemplates6.ts | 5 ++++- .../signatureHelpTaggedTemplates7.ts | 3 +++ ...signatureHelpTaggedTemplatesIncomplete1.ts | 3 +++ ...signatureHelpTaggedTemplatesIncomplete2.ts | 3 +++ ...signatureHelpTaggedTemplatesIncomplete3.ts | 3 +++ ...signatureHelpTaggedTemplatesIncomplete4.ts | 3 +++ ...signatureHelpTaggedTemplatesIncomplete5.ts | 3 +++ ...signatureHelpTaggedTemplatesIncomplete6.ts | 3 +++ .../signatureHelpTaggedTemplatesNested1.ts | 2 ++ .../signatureHelpTaggedTemplatesNested2.ts | 2 ++ ...eHelpTaggedTemplatesWithOverloadedTags1.ts | 20 +++++++++++++++++++ ...eHelpTaggedTemplatesWithOverloadedTags2.ts | 20 +++++++++++++++++++ ...eHelpTaggedTemplatesWithOverloadedTags3.ts | 20 +++++++++++++++++++ ...eHelpTaggedTemplatesWithOverloadedTags4.ts | 20 +++++++++++++++++++ ...eHelpTaggedTemplatesWithOverloadedTags5.ts | 20 +++++++++++++++++++ ...eHelpTaggedTemplatesWithOverloadedTags6.ts | 20 +++++++++++++++++++ ...eHelpTaggedTemplatesWithOverloadedTags7.ts | 20 +++++++++++++++++++ ...eHelpTaggedTemplatesWithOverloadedTags8.ts | 20 +++++++++++++++++++ 23 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts index 457551f160a..78b4b586a0c 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(4); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts index fa29c21ff21..c4b75657be5 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(4); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts index 5670cadfd4e..2616a0797be 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(4); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("x"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts index bbbd869de09..995eddf3f65 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(4); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("y"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts index 68a95121240..01bd606cbf5 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(4); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("z"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts index c1080b3f7e5..96909c8aeac 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts @@ -7,8 +7,11 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); - verify.currentSignatureParamterCountIs(4); + verify.signatureHelpArgumentCountIs(4); + + //verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('g(templateStrings: any, x: any, y: any, z: any): string'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts index eb25ac6f647..ddb120b4089 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(1); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts index 65a250fce31..edc6b932e5f 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(2); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts index c2baa7b187d..51ca619c4be 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(2); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("x"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts index ccaebc1f1b6..05aaef5bc50 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(2); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts index e220ec60679..e615f0156c0 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(3); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("y"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts index 1655841575d..531ce46b3c8 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(3); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts index 67d81d6558e..fcfd569daff 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts @@ -7,7 +7,10 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.signatureHelpArgumentCountIs(3); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("y"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts index 934bea21ed5..a20e43b20bc 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts @@ -7,7 +7,9 @@ test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('g(templateStrings: any, x: any, y: any, z: any): string'); }); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts index 9ff5103f30a..488209dfac7 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts @@ -8,7 +8,9 @@ debugger; test.markers().forEach(m => { goTo.position(m.position); + verify.signatureHelpCountIs(1); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); }); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts new file mode 100644 index 00000000000..608af7dbb96 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `/*1*/ /*2*/$/*3*/{ + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(2); + + verify.currentSignatureParamterCountIs(2); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o1: string): number'); + verify.currentParameterHelpArgumentNameIs("templateStrings"); + verify.currentParameterSpanIs("templateStrings: string[]"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts new file mode 100644 index 00000000000..c7908bdb52a --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `${/*1*/ /*2*/ /*3*/ + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(2); + + verify.currentSignatureParamterCountIs(2); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o1: string): number'); + verify.currentParameterHelpArgumentNameIs("p1_o1"); + verify.currentParameterSpanIs("p1_o1: string"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts new file mode 100644 index 00000000000..22256db1f0e --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `${/*1*/ "s/*2*/tring" /*3*/ } ${ + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(3); + + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean'); + verify.currentParameterHelpArgumentNameIs("p1_o3"); + verify.currentParameterSpanIs("p1_o3: string"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts new file mode 100644 index 00000000000..700cc2194bf --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `${/*1*/ 123.456/*2*/ /*3*/ } ${ + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(3); + + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); + verify.currentParameterHelpArgumentNameIs("p1_o2"); + verify.currentParameterSpanIs("p1_o2: number"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts new file mode 100644 index 00000000000..20701c0e98d --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `${ } ${/*1*/ /*2*/ /*3*/ + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(3); + + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); + verify.currentParameterHelpArgumentNameIs("p2_o2"); + verify.currentParameterSpanIs("p2_o2: number"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts new file mode 100644 index 00000000000..7bfd17c254a --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `${ } ${/*1*/ /*2*/ /*3*/} + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(3); + + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); + verify.currentParameterHelpArgumentNameIs("p2_o2"); + verify.currentParameterSpanIs("p2_o2: number"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts new file mode 100644 index 00000000000..4f747d3d8eb --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `${ } ${/*1*/ fa/*2*/lse /*3*/} + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(3); + + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean'); + verify.currentParameterHelpArgumentNameIs("p2_o3"); + verify.currentParameterSpanIs("p2_o3: boolean"); +}); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts new file mode 100644 index 00000000000..f97c2569730 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `${ undefined } ${ undefined } ${/*1*/ 10/*2*/./*3*/01 /*4*/} ` + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(4); + + verify.currentSignatureParamterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); + verify.currentParameterHelpArgumentNameIs("p3_o2"); + verify.currentParameterSpanIs("p3_o2: number"); +}); \ No newline at end of file From 513a8c3e9767db5eb955a1e53da5b22318a3180b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 18 Nov 2014 17:48:58 -0800 Subject: [PATCH 10/16] Fixed broken test. --- tests/cases/fourslash/signatureHelpTaggedTemplates6.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts index 96909c8aeac..71b85b1821b 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts @@ -9,9 +9,9 @@ test.markers().forEach(m => { goTo.position(m.position); verify.signatureHelpCountIs(1); - verify.signatureHelpArgumentCountIs(4); + verify.signatureHelpArgumentCountIs(1); - //verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParamterCountIs(4); verify.currentSignatureHelpIs('g(templateStrings: any, x: any, y: any, z: any): string'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); From b98f6b46887a2b3b21cf2ad36260479eb44d21af Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 19 Nov 2014 11:55:05 -0800 Subject: [PATCH 11/16] Paramter -> Parameter --- tests/cases/fourslash/fourslash.ts | 4 ++-- tests/cases/fourslash/genericParameterHelp.ts | 2 +- .../signatureHelpAnonymousFunction.ts | 2 +- tests/cases/fourslash/signatureHelpAtEOF.ts | 2 +- .../signatureHelpBeforeSemicolon1.ts | 2 +- .../fourslash/signatureHelpCallExpression.ts | 2 +- .../signatureHelpConstructExpression.ts | 2 +- .../signatureHelpConstructorInheritance.ts | 2 +- .../signatureHelpConstructorOverload.ts | 4 ++-- .../cases/fourslash/signatureHelpEmptyList.ts | 2 +- .../signatureHelpFunctionOverload.ts | 4 ++-- .../signatureHelpFunctionParameter.ts | 2 +- .../signatureHelpImplicitConstructor.ts | 2 +- .../fourslash/signatureHelpIncompleteCalls.ts | 6 ++--- .../fourslash/signatureHelpObjectLiteral.ts | 24 +++++++++---------- ...signatureHelpOnOverloadsDifferentArity3.ts | 6 ++--- .../signatureHelpSuperConstructorOverload.ts | 4 ++-- .../signatureHelpTaggedTemplates1.ts | 2 +- .../signatureHelpTaggedTemplates2.ts | 2 +- .../signatureHelpTaggedTemplates3.ts | 2 +- .../signatureHelpTaggedTemplates4.ts | 2 +- .../signatureHelpTaggedTemplates5.ts | 2 +- .../signatureHelpTaggedTemplates6.ts | 2 +- .../signatureHelpTaggedTemplates7.ts | 2 +- ...signatureHelpTaggedTemplatesIncomplete1.ts | 2 +- ...signatureHelpTaggedTemplatesIncomplete2.ts | 2 +- ...signatureHelpTaggedTemplatesIncomplete3.ts | 2 +- ...signatureHelpTaggedTemplatesIncomplete4.ts | 2 +- ...signatureHelpTaggedTemplatesIncomplete5.ts | 2 +- ...signatureHelpTaggedTemplatesIncomplete6.ts | 2 +- .../signatureHelpTaggedTemplatesNested1.ts | 2 +- .../signatureHelpTaggedTemplatesNested2.ts | 3 +-- ...eHelpTaggedTemplatesWithOverloadedTags1.ts | 2 +- ...eHelpTaggedTemplatesWithOverloadedTags2.ts | 2 +- ...eHelpTaggedTemplatesWithOverloadedTags3.ts | 2 +- ...eHelpTaggedTemplatesWithOverloadedTags4.ts | 2 +- ...eHelpTaggedTemplatesWithOverloadedTags5.ts | 2 +- ...eHelpTaggedTemplatesWithOverloadedTags6.ts | 2 +- ...eHelpTaggedTemplatesWithOverloadedTags7.ts | 2 +- ...eHelpTaggedTemplatesWithOverloadedTags8.ts | 2 +- 40 files changed, 59 insertions(+), 60 deletions(-) diff --git a/tests/cases/fourslash/fourslash.ts b/tests/cases/fourslash/fourslash.ts index c71f8987bdf..c0372d46063 100644 --- a/tests/cases/fourslash/fourslash.ts +++ b/tests/cases/fourslash/fourslash.ts @@ -301,11 +301,11 @@ module FourSlashInterface { FourSlash.currentTestState.verifySignatureHelpArgumentCount(expected); } - public currentSignatureParamterCountIs(expected: number) { + public currentSignatureParameterCountIs(expected: number) { FourSlash.currentTestState.verifyCurrentSignatureHelpParameterCount(expected); } - public currentSignatureTypeParamterCountIs(expected: number) { + public currentSignatureTypeParameterCountIs(expected: number) { FourSlash.currentTestState.verifyCurrentSignatureHelpTypeParameterCount(expected); } diff --git a/tests/cases/fourslash/genericParameterHelp.ts b/tests/cases/fourslash/genericParameterHelp.ts index 17882485fd7..6bbb957f0f9 100644 --- a/tests/cases/fourslash/genericParameterHelp.ts +++ b/tests/cases/fourslash/genericParameterHelp.ts @@ -14,7 +14,7 @@ ////testFunction<, ,/*5*/>(null, null, null); // goTo.marker("1"); -// verify.currentSignatureParamterCountIs(3); +// verify.currentSignatureParameterCountIs(3); // verify.currentSignatureHelpIs("testFunction(a: T, b: U, c: M): M"); // verify.currentParameterHelpArgumentNameIs("T"); diff --git a/tests/cases/fourslash/signatureHelpAnonymousFunction.ts b/tests/cases/fourslash/signatureHelpAnonymousFunction.ts index cc723c713d6..ba812a2f8d3 100644 --- a/tests/cases/fourslash/signatureHelpAnonymousFunction.ts +++ b/tests/cases/fourslash/signatureHelpAnonymousFunction.ts @@ -7,7 +7,7 @@ goTo.marker('anonymousFunction1'); verify.signatureHelpCountIs(1); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentSignatureHelpIs('(a: number, b: string): string'); verify.currentParameterHelpArgumentNameIs("a"); verify.currentParameterSpanIs("a: number"); diff --git a/tests/cases/fourslash/signatureHelpAtEOF.ts b/tests/cases/fourslash/signatureHelpAtEOF.ts index 64c4aaeeb2c..d2e1fa0418d 100644 --- a/tests/cases/fourslash/signatureHelpAtEOF.ts +++ b/tests/cases/fourslash/signatureHelpAtEOF.ts @@ -10,6 +10,6 @@ verify.signatureHelpPresent(); verify.signatureHelpCountIs(1); verify.currentSignatureHelpIs("Foo(arg1: string, arg2: string): void"); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentParameterHelpArgumentNameIs("arg1"); verify.currentParameterSpanIs("arg1: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpBeforeSemicolon1.ts b/tests/cases/fourslash/signatureHelpBeforeSemicolon1.ts index 2b0b07056bf..d3bdd42ef1a 100644 --- a/tests/cases/fourslash/signatureHelpBeforeSemicolon1.ts +++ b/tests/cases/fourslash/signatureHelpBeforeSemicolon1.ts @@ -10,6 +10,6 @@ verify.signatureHelpPresent(); verify.signatureHelpCountIs(1); verify.currentSignatureHelpIs("Foo(arg1: string, arg2: string): void"); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentParameterHelpArgumentNameIs("arg1"); verify.currentParameterSpanIs("arg1: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpCallExpression.ts b/tests/cases/fourslash/signatureHelpCallExpression.ts index 50d89aaae4e..fd9758cfa54 100644 --- a/tests/cases/fourslash/signatureHelpCallExpression.ts +++ b/tests/cases/fourslash/signatureHelpCallExpression.ts @@ -5,7 +5,7 @@ goTo.marker('1'); verify.signatureHelpCountIs(1); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentSignatureHelpIs('fnTest(str: string, num: number): void'); verify.currentParameterHelpArgumentNameIs('str'); diff --git a/tests/cases/fourslash/signatureHelpConstructExpression.ts b/tests/cases/fourslash/signatureHelpConstructExpression.ts index a88cb3fce68..00efee0a479 100644 --- a/tests/cases/fourslash/signatureHelpConstructExpression.ts +++ b/tests/cases/fourslash/signatureHelpConstructExpression.ts @@ -6,7 +6,7 @@ goTo.marker('1'); verify.signatureHelpCountIs(1); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentSignatureHelpIs('sampleCls(str: string, num: number): sampleCls'); verify.currentParameterHelpArgumentNameIs('str'); diff --git a/tests/cases/fourslash/signatureHelpConstructorInheritance.ts b/tests/cases/fourslash/signatureHelpConstructorInheritance.ts index b066eab3fd4..a2e683d69bb 100644 --- a/tests/cases/fourslash/signatureHelpConstructorInheritance.ts +++ b/tests/cases/fourslash/signatureHelpConstructorInheritance.ts @@ -16,7 +16,7 @@ goTo.marker('indirectSuperCall'); verify.signatureHelpCountIs(2); -verify.currentSignatureParamterCountIs(1); +verify.currentSignatureParameterCountIs(1); verify.currentSignatureHelpIs('B2(n: number): B2'); verify.currentParameterHelpArgumentNameIs("n"); verify.currentParameterSpanIs("n: number"); diff --git a/tests/cases/fourslash/signatureHelpConstructorOverload.ts b/tests/cases/fourslash/signatureHelpConstructorOverload.ts index ce276e09d8f..9aab48f71ae 100644 --- a/tests/cases/fourslash/signatureHelpConstructorOverload.ts +++ b/tests/cases/fourslash/signatureHelpConstructorOverload.ts @@ -6,11 +6,11 @@ goTo.marker('1'); verify.signatureHelpCountIs(2); -verify.currentSignatureParamterCountIs(0); +verify.currentSignatureParameterCountIs(0); verify.currentSignatureHelpIs('clsOverload(): clsOverload'); goTo.marker('2'); -verify.currentSignatureParamterCountIs(1); +verify.currentSignatureParameterCountIs(1); verify.currentSignatureHelpIs('clsOverload(test: string): clsOverload'); verify.currentParameterHelpArgumentNameIs('test'); verify.currentParameterSpanIs("test: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpEmptyList.ts b/tests/cases/fourslash/signatureHelpEmptyList.ts index 6ea70159dcc..b6318656f4f 100644 --- a/tests/cases/fourslash/signatureHelpEmptyList.ts +++ b/tests/cases/fourslash/signatureHelpEmptyList.ts @@ -12,7 +12,7 @@ verify.signatureHelpPresent(); verify.signatureHelpCountIs(1); verify.currentSignatureHelpIs("Foo(arg1: string, arg2: string): void"); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentParameterHelpArgumentNameIs("arg1"); verify.currentParameterSpanIs("arg1: string"); diff --git a/tests/cases/fourslash/signatureHelpFunctionOverload.ts b/tests/cases/fourslash/signatureHelpFunctionOverload.ts index 2c1cdb51291..cc02ba12570 100644 --- a/tests/cases/fourslash/signatureHelpFunctionOverload.ts +++ b/tests/cases/fourslash/signatureHelpFunctionOverload.ts @@ -8,11 +8,11 @@ goTo.marker('functionOverload1'); verify.signatureHelpCountIs(2); -verify.currentSignatureParamterCountIs(0); +verify.currentSignatureParameterCountIs(0); verify.currentSignatureHelpIs('functionOverload(): any'); goTo.marker('functionOverload2'); -verify.currentSignatureParamterCountIs(1); +verify.currentSignatureParameterCountIs(1); verify.currentSignatureHelpIs('functionOverload(test: string): any'); verify.currentParameterHelpArgumentNameIs("test"); verify.currentParameterSpanIs("test: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpFunctionParameter.ts b/tests/cases/fourslash/signatureHelpFunctionParameter.ts index cb2264f2c42..b61e56dedcb 100644 --- a/tests/cases/fourslash/signatureHelpFunctionParameter.ts +++ b/tests/cases/fourslash/signatureHelpFunctionParameter.ts @@ -6,7 +6,7 @@ goTo.marker('parameterFunction1'); verify.signatureHelpCountIs(1); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentSignatureHelpIs('callback(a: number, b: string): void'); verify.currentParameterHelpArgumentNameIs("a"); verify.currentParameterSpanIs("a: number"); diff --git a/tests/cases/fourslash/signatureHelpImplicitConstructor.ts b/tests/cases/fourslash/signatureHelpImplicitConstructor.ts index 9e42d25dbe9..4324767d00a 100644 --- a/tests/cases/fourslash/signatureHelpImplicitConstructor.ts +++ b/tests/cases/fourslash/signatureHelpImplicitConstructor.ts @@ -7,4 +7,4 @@ goTo.marker(); verify.signatureHelpCountIs(1); verify.currentSignatureHelpIs("ImplicitConstructor(): ImplicitConstructor"); -verify.currentSignatureParamterCountIs(0); +verify.currentSignatureParameterCountIs(0); diff --git a/tests/cases/fourslash/signatureHelpIncompleteCalls.ts b/tests/cases/fourslash/signatureHelpIncompleteCalls.ts index e73217b1d8c..ec4fcccc0fe 100644 --- a/tests/cases/fourslash/signatureHelpIncompleteCalls.ts +++ b/tests/cases/fourslash/signatureHelpIncompleteCalls.ts @@ -17,13 +17,13 @@ goTo.marker('incompleteCalls1'); verify.currentSignatureHelpIs("f1(): void"); -verify.currentSignatureParamterCountIs(0); +verify.currentSignatureParameterCountIs(0); goTo.marker('incompleteCalls2'); -verify.currentSignatureParamterCountIs(1); +verify.currentSignatureParameterCountIs(1); verify.currentSignatureHelpIs("f2(n: number): number"); goTo.marker('incompleteCalls3'); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentSignatureHelpIs("f3(n: number, s: string): string"); verify.currentParameterHelpArgumentNameIs("s"); diff --git a/tests/cases/fourslash/signatureHelpObjectLiteral.ts b/tests/cases/fourslash/signatureHelpObjectLiteral.ts index cbc5df697b9..6853c3fee36 100644 --- a/tests/cases/fourslash/signatureHelpObjectLiteral.ts +++ b/tests/cases/fourslash/signatureHelpObjectLiteral.ts @@ -1,17 +1,17 @@ /// ////var objectLiteral = { n: 5, s: "", f: (a: number, b: string) => "" }; -////objectLiteral.f(/*objectLiteral1*/4, /*objectLiteral2*/""); - -goTo.marker('objectLiteral1'); -verify.signatureHelpCountIs(1); -verify.currentSignatureParamterCountIs(2); -verify.currentSignatureHelpIs('f(a: number, b: string): string'); - -verify.currentParameterHelpArgumentNameIs("a"); -verify.currentParameterSpanIs("a: number"); - -goTo.marker('objectLiteral2'); -verify.currentSignatureHelpIs('f(a: number, b: string): string'); +////objectLiteral.f(/*objectLiteral1*/4, /*objectLiteral2*/""); + +goTo.marker('objectLiteral1'); +verify.signatureHelpCountIs(1); +verify.currentSignatureParameterCountIs(2); +verify.currentSignatureHelpIs('f(a: number, b: string): string'); + +verify.currentParameterHelpArgumentNameIs("a"); +verify.currentParameterSpanIs("a: number"); + +goTo.marker('objectLiteral2'); +verify.currentSignatureHelpIs('f(a: number, b: string): string'); verify.currentParameterHelpArgumentNameIs("b"); verify.currentParameterSpanIs("b: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity3.ts b/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity3.ts index c217a12ef58..f9754c7d1fd 100644 --- a/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity3.ts +++ b/tests/cases/fourslash/signatureHelpOnOverloadsDifferentArity3.ts @@ -10,17 +10,17 @@ goTo.marker(); verify.signatureHelpCountIs(4); verify.currentSignatureHelpIs("f(): any"); -verify.currentSignatureParamterCountIs(0); +verify.currentSignatureParameterCountIs(0); verify.signatureHelpArgumentCountIs(0); edit.insert(", "); verify.signatureHelpCountIs(4); verify.currentSignatureHelpIs("f(s: string, b: boolean): any"); -verify.currentSignatureParamterCountIs(2); +verify.currentSignatureParameterCountIs(2); verify.currentParameterHelpArgumentNameIs("b"); verify.currentParameterSpanIs("b: boolean"); edit.insert(", "); verify.signatureHelpCountIs(4); verify.currentSignatureHelpIs("f(s: string, b: boolean): any"); -verify.currentSignatureParamterCountIs(2); \ No newline at end of file +verify.currentSignatureParameterCountIs(2); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts b/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts index 1be8c3202a1..aa2e3e4856c 100644 --- a/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts +++ b/tests/cases/fourslash/signatureHelpSuperConstructorOverload.ts @@ -20,9 +20,9 @@ goTo.marker('superOverload1'); verify.signatureHelpCountIs(2); verify.currentSignatureHelpIs("SuperOverloadlBase(): SuperOverloadlBase"); -verify.currentSignatureParamterCountIs(0); +verify.currentSignatureParameterCountIs(0); goTo.marker('superOverload2'); -verify.currentSignatureParamterCountIs(1); +verify.currentSignatureParameterCountIs(1); verify.currentSignatureHelpIs("SuperOverloadlBase(test: string): SuperOverloadlBase"); verify.currentParameterHelpArgumentNameIs("test"); verify.currentParameterSpanIs("test: string"); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts index 78b4b586a0c..39644ba8c24 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates1.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts index c4b75657be5..123a6cc4c2c 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates2.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts index 2616a0797be..f203468ca04 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates3.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("x"); verify.currentParameterSpanIs("x: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts index 995eddf3f65..13ee47a3309 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates4.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("y"); verify.currentParameterSpanIs("y: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts index 01bd606cbf5..7cd2affd675 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates5.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(4); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("z"); verify.currentParameterSpanIs("z: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts index 71b85b1821b..7671666bb54 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates6.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(1); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('g(templateStrings: any, x: any, y: any, z: any): string'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts index ddb120b4089..35bed336f39 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplates7.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(1); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts index edc6b932e5f..1da96ea5c1b 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete1.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(2); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts index 51ca619c4be..68ff7202f01 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete2.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(2); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("x"); verify.currentParameterSpanIs("x: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts index 05aaef5bc50..8165da7f67b 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete3.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(2); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts index e615f0156c0..8c970b60c77 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete4.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(3); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("y"); verify.currentParameterSpanIs("y: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts index 531ce46b3c8..f93da36ce5c 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete5.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(3); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts index fcfd569daff..10d81eb80f4 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesIncomplete6.ts @@ -11,7 +11,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); verify.signatureHelpArgumentCountIs(3); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); verify.currentParameterHelpArgumentNameIs("y"); verify.currentParameterSpanIs("y: any"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts index a20e43b20bc..a3c9f7ccce4 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested1.ts @@ -10,6 +10,6 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(1); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('g(templateStrings: any, x: any, y: any, z: any): string'); }); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts index 488209dfac7..d72fa74d985 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesNested2.ts @@ -4,13 +4,12 @@ //// function g(templateStrings, x, y, z) { return ""; } //// //// f `/*1*/a $/*2*/{ /*3*/g /*4*/`alpha ${ 123 } beta ${ 456 } gamma`/*5*/ }/*6*/ b $/*7*/{ /*8*/g /*9*/`txt`/*10*/ } /*11*/c ${ /*12*/g /*13*/`aleph ${ 123 } beit`/*14*/ } d/*15*/`; -debugger; test.markers().forEach(m => { goTo.position(m.position); verify.signatureHelpCountIs(1); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: any, x: any, y: any, z: any): number'); }); \ No newline at end of file diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts index 608af7dbb96..6850b1bc54f 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags1.ts @@ -13,7 +13,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(2); - verify.currentSignatureParamterCountIs(2); + verify.currentSignatureParameterCountIs(2); verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o1: string): number'); verify.currentParameterHelpArgumentNameIs("templateStrings"); verify.currentParameterSpanIs("templateStrings: string[]"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts index c7908bdb52a..8466c6b05f2 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags2.ts @@ -13,7 +13,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(2); - verify.currentSignatureParamterCountIs(2); + verify.currentSignatureParameterCountIs(2); verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o1: string): number'); verify.currentParameterHelpArgumentNameIs("p1_o1"); verify.currentParameterSpanIs("p1_o1: string"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts index 22256db1f0e..3843ed34b16 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags3.ts @@ -13,7 +13,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean'); verify.currentParameterHelpArgumentNameIs("p1_o3"); verify.currentParameterSpanIs("p1_o3: string"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts index 700cc2194bf..a1072366a98 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags4.ts @@ -13,7 +13,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); verify.currentParameterHelpArgumentNameIs("p1_o2"); verify.currentParameterSpanIs("p1_o2: number"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts index 20701c0e98d..2646e70b39c 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags5.ts @@ -13,7 +13,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); verify.currentParameterHelpArgumentNameIs("p2_o2"); verify.currentParameterSpanIs("p2_o2: number"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts index 7bfd17c254a..62410a5fda3 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags6.ts @@ -13,7 +13,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); verify.currentParameterHelpArgumentNameIs("p2_o2"); verify.currentParameterSpanIs("p2_o2: number"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts index 4f747d3d8eb..9a24aacf86b 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags7.ts @@ -13,7 +13,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(3); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean'); verify.currentParameterHelpArgumentNameIs("p2_o3"); verify.currentParameterSpanIs("p2_o3: boolean"); diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts index f97c2569730..8000f15d3c6 100644 --- a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags8.ts @@ -13,7 +13,7 @@ test.markers().forEach(m => { verify.signatureHelpCountIs(3); verify.signatureHelpArgumentCountIs(4); - verify.currentSignatureParamterCountIs(4); + verify.currentSignatureParameterCountIs(4); verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); verify.currentParameterHelpArgumentNameIs("p3_o2"); verify.currentParameterSpanIs("p3_o2: number"); From db69ec1da607b26467fa89c14a60c6ef8df87139 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Wed, 19 Nov 2014 11:57:01 -0800 Subject: [PATCH 12/16] getCallLikeInvoker -> getInvokedExpression --- src/compiler/parser.ts | 2 +- src/services/signatureHelp.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index addc7f40c93..f7c9635eb04 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -475,7 +475,7 @@ module ts { } } - export function getCallLikeInvoker(node: CallLikeExpression): Expression { + export function getInvokedExpression(node: CallLikeExpression): Expression { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; } diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 10c036dc38d..541e289037b 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -456,7 +456,7 @@ module ts.SignatureHelp { var isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments; var invocation = argumentListInfo.invocation; - var invokerNode = getCallLikeInvoker(invocation) + var invokerNode = getInvokedExpression(invocation) var invokerSymbol = typeInfoResolver.getSymbolInfo(invokerNode); var invokerDisplayParts = invokerSymbol && symbolToDisplayParts(typeInfoResolver, invokerSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items: SignatureHelpItem[] = map(candidates, candidateSignature => { From 0404e8481e07a1017f91cb6298dc19dd026c78bc Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 20 Nov 2014 17:00:01 -0800 Subject: [PATCH 13/16] Addressed some CR feedback. --- src/services/signatureHelp.ts | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 541e289037b..0f61a69d51f 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -210,12 +210,10 @@ module ts.SignatureHelp { return createSignatureHelpItems(candidates, resolvedSignature, argumentInfo); /** - * If node is an argument, returns its index in the argument list. - * If not, returns -1. + * Returns relevant information for the argument list and the current argument if we are + * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node: Node, position: number): ArgumentListInfo { - var callLikeExpr: CallLikeExpression; - if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) { var callExpression = node.parent; // There are 3 cases to handle: @@ -329,14 +327,13 @@ module ts.SignatureHelp { // spanIndex is either the index for a given template span, or Constants.HeadSpanIndex for a template head. // This does not give appropriate results for a NoSubstitutionTemplateLiteral function getArgumentIndexForTemplatePiece(spanIndex: number, node: Node, position: number): number { - // TemplateSpans are expression-template pairs, and ordered as such. - // Because of the TemplateStringsArray arg, we have to offset ourselves by 1 for substitution expressions. + // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. // There are three cases we can encounter: - // 1. We are precisely in the template literal (argIndex = 0) - // 2. We are in or to the right of the substitution expression (argIndex = spanIndex + 1) - // 3. We are directly to the right of the template literal, but not - // enough to put us in the substitution expression; we should consider ourselves part of - // the *next* span's expression (argIndex = (spanIndex + 1) + 1). + // 1. We are precisely in the template literal (argIndex = 0). + // 2. We are in or to the right of the substitution expression (argIndex = spanIndex + 1). + // 3. We are directly to the right of the template literal, but because we look for the token on the left, + // not enough to put us in the substitution expression; we should consider ourselves part of + // the *next* span's expression by offsetting the index (argIndex = (spanIndex + 1) + 1). // // Example: f `# abcd $#{# 1 + 1# }# efghi ${ #"#hello"# } # ` // ^ ^ ^ ^ ^ ^ ^ ^ ^ @@ -352,6 +349,7 @@ module ts.SignatureHelp { } function getArgumentListInfoForTemplate(tagExpression: TaggedTemplateExpression, argumentIndex: number): ArgumentListInfo { + // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. var argumentCount = tagExpression.template.kind === SyntaxKind.NoSubstitutionTemplateLiteral ? 1 : (tagExpression.template).templateSpans.length + 1; From 7211dfa84d190635265aa4a1a878967bbc3bc51b Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 20 Nov 2014 17:54:46 -0800 Subject: [PATCH 14/16] Added test. --- ...eHelpTaggedTemplatesWithOverloadedTags9.ts | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts diff --git a/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts new file mode 100644 index 00000000000..aee06c1df53 --- /dev/null +++ b/tests/cases/fourslash/signatureHelpTaggedTemplatesWithOverloadedTags9.ts @@ -0,0 +1,20 @@ +/// + +//// function f(templateStrings: string[], p1_o1: string): number; +//// function f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string; +//// function f(templateStrings: string[], p1_o3: string, p2_o3: boolean, p3_o3: number): boolean; +//// function f(...foo[]: any) { return ""; } +//// +//// f `${/*1*/ /*2*/ /*3*/} ${ + +test.markers().forEach(m => { + goTo.position(m.position); + + verify.signatureHelpCountIs(3); + verify.signatureHelpArgumentCountIs(3); + + verify.currentSignatureParameterCountIs(4); + verify.currentSignatureHelpIs('f(templateStrings: string[], p1_o2: number, p2_o2: number, p3_o2: number): string'); + verify.currentParameterHelpArgumentNameIs("p1_o2"); + verify.currentParameterSpanIs("p1_o2: number"); +}); \ No newline at end of file From a71c527a9ea7128681a47269db798a151ccfdf4f Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Thu, 20 Nov 2014 17:56:24 -0800 Subject: [PATCH 15/16] Amended comment. --- src/compiler/parser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f7c9635eb04..a1e050b8fb1 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -822,7 +822,7 @@ module ts { return false; } - // We can only be unclosed if we have a tail or a no-sub template. + // The literal can only be unterminated if it is a template tail or a no-sub template. if (node.kind !== SyntaxKind.TemplateTail && node.kind !== SyntaxKind.NoSubstitutionTemplateLiteral) { return false; } From 1bbb0348913ffd2456684fed8cd976a5928be774 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Mon, 24 Nov 2014 16:24:15 -0800 Subject: [PATCH 16/16] Addressed CR feedback. --- src/compiler/parser.ts | 6 ++-- src/services/signatureHelp.ts | 54 ++++++++++++++++++----------------- src/services/utilities.ts | 2 +- 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index a1e050b8fb1..97186b22bb0 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -479,9 +479,9 @@ module ts { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; } - else { - return (node).func; - } + + // Will either be a CallExpression or NewExpression. + return (node).func; } export function isExpression(node: Node): boolean { diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 0f61a69d51f..7d7d52a62c4 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -164,10 +164,6 @@ module ts.SignatureHelp { //} var emptyArray: any[] = []; - const enum Constants { - HeadSpanIndex = -1 - } - const enum ArgumentListKind { TypeArguments, CallArguments, @@ -190,7 +186,7 @@ module ts.SignatureHelp { return undefined; } - var argumentInfo = getContainingArgumentInfo(startingToken, position); + var argumentInfo = getContainingArgumentInfo(startingToken); cancellationToken.throwIfCancellationRequested(); // Semantic filtering of signature help @@ -213,7 +209,7 @@ module ts.SignatureHelp { * Returns relevant information for the argument list and the current argument if we are * in the argument of an invocation; returns undefined otherwise. */ - function getImmediatelyContainingArgumentInfo(node: Node, position: number): ArgumentListInfo { + function getImmediatelyContainingArgumentInfo(node: Node): ArgumentListInfo { if (node.parent.kind === SyntaxKind.CallExpression || node.parent.kind === SyntaxKind.NewExpression) { var callExpression = node.parent; // There are 3 cases to handle: @@ -287,7 +283,9 @@ module ts.SignatureHelp { else if (node.kind === SyntaxKind.TemplateHead && node.parent.parent.kind === SyntaxKind.TaggedTemplateExpression) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - var argumentIndex = getArgumentIndexForTemplatePiece(Constants.HeadSpanIndex, node, position); + Debug.assert(templateExpression.kind === SyntaxKind.TemplateExpression); + + var argumentIndex = isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } @@ -302,13 +300,8 @@ module ts.SignatureHelp { return undefined; } - // The cursor can either be in or after the template literal. - // If inside, we want to highlight the first argument. - // If after, we'll want to highlight the next parameter. - // We actually shouldn't be able to show up before because you should be at the left-most token. - var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); - var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node, position); + var argumentIndex = getArgumentIndexForTemplatePiece(spanIndex, node); return getArgumentListInfoForTemplate(tagExpression, argumentIndex); } @@ -324,9 +317,9 @@ module ts.SignatureHelp { : 1 + countWhere(argumentsList.getChildren(), arg => arg.kind === SyntaxKind.CommaToken); } - // spanIndex is either the index for a given template span, or Constants.HeadSpanIndex for a template head. + // spanIndex is either the index for a given template span. // This does not give appropriate results for a NoSubstitutionTemplateLiteral - function getArgumentIndexForTemplatePiece(spanIndex: number, node: Node, position: number): number { + function getArgumentIndexForTemplatePiece(spanIndex: number, node: Node): number { // Because the TemplateStringsArray is the first argument, we have to offset each substitution expression by 1. // There are three cases we can encounter: // 1. We are precisely in the template literal (argIndex = 0). @@ -357,7 +350,7 @@ module ts.SignatureHelp { return { kind: ArgumentListKind.TaggedTemplateArguments, invocation: tagExpression, - argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression.template), + argumentsSpan: getApplicableSpanForTaggedTemplate(tagExpression), argumentIndex: argumentIndex, argumentCount: argumentCount }; @@ -377,22 +370,31 @@ module ts.SignatureHelp { return new TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } - function getApplicableSpanForTaggedTemplate(template: TemplateExpression | LiteralExpression): TextSpan { + function getApplicableSpanForTaggedTemplate(taggedTemplate: TaggedTemplateExpression): TextSpan { + var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - // Adjust the span end in case the template is unclosed - + // We need to adjust the end position for the case where the template does not have a tail. + // Otherwise, we will not show signature help past the expression. + // For example, + // + // ` ${ 1 + 1 foo(10) + // | | + // + // This is because a Missing node has no width. However, what we actually want is to include trivia + // leading up to the next token in case the user is about to type in a TemplateMiddle or TemplateTail. if (template.kind === SyntaxKind.TemplateExpression) { var lastSpan = lastOrUndefined((template).templateSpans); if (lastSpan.literal.kind === SyntaxKind.Missing) { - applicableSpanEnd = skipTrivia(sourceFile.text, template.end, /*stopAfterLineBreak*/ false); + applicableSpanEnd = skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); } } return new TextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } - function getContainingArgumentInfo(node: Node, position: number): ArgumentListInfo { + function getContainingArgumentInfo(node: Node): ArgumentListInfo { for (var n = node; n.kind !== SyntaxKind.SourceFile; n = n.parent) { if (n.kind === SyntaxKind.FunctionBlock) { return undefined; @@ -404,7 +406,7 @@ module ts.SignatureHelp { Debug.fail("Node of kind " + n.kind + " is not a subspan of its parent of kind " + n.parent.kind); } - var argumentInfo = getImmediatelyContainingArgumentInfo(n, position); + var argumentInfo = getImmediatelyContainingArgumentInfo(n); if (argumentInfo) { return argumentInfo; } @@ -454,16 +456,16 @@ module ts.SignatureHelp { var isTypeParameterList = argumentListInfo.kind === ArgumentListKind.TypeArguments; var invocation = argumentListInfo.invocation; - var invokerNode = getInvokedExpression(invocation) - var invokerSymbol = typeInfoResolver.getSymbolInfo(invokerNode); - var invokerDisplayParts = invokerSymbol && symbolToDisplayParts(typeInfoResolver, invokerSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); + var callTarget = getInvokedExpression(invocation) + var callTargetSymbol = typeInfoResolver.getSymbolInfo(callTarget); + var callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined); var items: SignatureHelpItem[] = map(candidates, candidateSignature => { var signatureHelpParameters: SignatureHelpParameter[]; var prefixParts: SymbolDisplayPart[] = []; var suffixParts: SymbolDisplayPart[] = []; - if (invokerDisplayParts) { - prefixParts.push.apply(prefixParts, invokerDisplayParts); + if (callTargetDisplayParts) { + prefixParts.push.apply(prefixParts, callTargetDisplayParts); } if (isTypeParameterList) { diff --git a/src/services/utilities.ts b/src/services/utilities.ts index ab651491518..4aacad24c87 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -323,6 +323,6 @@ module ts { export function isInsideTemplateLiteral(node: LiteralExpression, position: number) { return (node.getStart() < position && position < node.getEnd()) - || (isUnterminatedTemplateEnd(node) && position >= node.getEnd()); + || (isUnterminatedTemplateEnd(node) && position === node.getEnd()); } } \ No newline at end of file