|
1 |
| -// Copyright (c) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0. |
2 |
| -// See LICENSE.txt in the project root for complete license information. |
3 |
| - |
4 | 1 | ///<reference path='services.ts' />
|
5 | 2 |
|
6 | 3 | module ts.SignatureHelp {
|
@@ -130,172 +127,6 @@ module ts.SignatureHelp {
|
130 | 127 | // return null;
|
131 | 128 | //}
|
132 | 129 |
|
133 |
| - ////public static getSignatureInfoFromSignatureSymbol(symbol: TypeScript.PullSymbol, signatures: TypeScript.PullSignatureSymbol[], enclosingScopeSymbol: TypeScript.PullSymbol, compilerState: LanguageServiceCompiler) { |
134 |
| - //// var signatureGroup: FormalSignatureItemInfo[] = []; |
135 |
| - |
136 |
| - //// var hasOverloads = signatures.length > 1; |
137 |
| - |
138 |
| - //// for (var i = 0, n = signatures.length; i < n; i++) { |
139 |
| - //// var signature = signatures[i]; |
140 |
| - |
141 |
| - //// // filter out the definition signature if there are overloads |
142 |
| - //// if (hasOverloads && signature.isDefinition()) { |
143 |
| - //// continue; |
144 |
| - //// } |
145 |
| - |
146 |
| - //// var signatureGroupInfo = new FormalSignatureItemInfo(); |
147 |
| - //// var paramIndexInfo: number[] = []; |
148 |
| - //// var functionName = signature.getScopedNameEx(enclosingScopeSymbol).toString(); |
149 |
| - //// if (!functionName && (!symbol.isType() || (<TypeScript.PullTypeSymbol>symbol).isNamedTypeSymbol())) { |
150 |
| - //// functionName = symbol.getScopedNameEx(enclosingScopeSymbol).toString(); |
151 |
| - //// } |
152 |
| - |
153 |
| - //// var signatureMemberName = signature.getSignatureTypeNameEx(functionName, /*shortform*/ false, /*brackets*/ false, enclosingScopeSymbol, /*getParamMarkerInfo*/ true, /*getTypeParameterMarkerInfo*/ true); |
154 |
| - //// signatureGroupInfo.signatureInfo = TypeScript.MemberName.memberNameToString(signatureMemberName, paramIndexInfo); |
155 |
| - //// signatureGroupInfo.docComment = signature.docComments(); |
156 |
| - |
157 |
| - //// var parameterMarkerIndex = 0; |
158 |
| - |
159 |
| - //// if (signature.isGeneric()) { |
160 |
| - //// var typeParameters = signature.getTypeParameters(); |
161 |
| - //// for (var j = 0, m = typeParameters.length; j < m; j++) { |
162 |
| - //// var typeParameter = typeParameters[j]; |
163 |
| - //// var signatureTypeParameterInfo = new FormalTypeParameterInfo(); |
164 |
| - //// signatureTypeParameterInfo.name = typeParameter.getDisplayName(); |
165 |
| - //// signatureTypeParameterInfo.docComment = typeParameter.docComments(); |
166 |
| - //// signatureTypeParameterInfo.minChar = paramIndexInfo[2 * parameterMarkerIndex]; |
167 |
| - //// signatureTypeParameterInfo.limChar = paramIndexInfo[2 * parameterMarkerIndex + 1]; |
168 |
| - //// parameterMarkerIndex++; |
169 |
| - //// signatureGroupInfo.typeParameters.push(signatureTypeParameterInfo); |
170 |
| - //// } |
171 |
| - //// } |
172 |
| - |
173 |
| - //// var parameters = signature.parameters; |
174 |
| - //// for (var j = 0, m = parameters.length; j < m; j++) { |
175 |
| - //// var parameter = parameters[j]; |
176 |
| - //// var signatureParameterInfo = new FormalParameterInfo(); |
177 |
| - //// signatureParameterInfo.isVariable = signature.hasVarArgs && (j === parameters.length - 1); |
178 |
| - //// signatureParameterInfo.name = parameter.getDisplayName(); |
179 |
| - //// signatureParameterInfo.docComment = parameter.docComments(); |
180 |
| - //// signatureParameterInfo.minChar = paramIndexInfo[2 * parameterMarkerIndex]; |
181 |
| - //// signatureParameterInfo.limChar = paramIndexInfo[2 * parameterMarkerIndex + 1]; |
182 |
| - //// parameterMarkerIndex++; |
183 |
| - //// signatureGroupInfo.parameters.push(signatureParameterInfo); |
184 |
| - //// } |
185 |
| - |
186 |
| - //// signatureGroup.push(signatureGroupInfo); |
187 |
| - //// } |
188 |
| - |
189 |
| - //// return signatureGroup; |
190 |
| - ////} |
191 |
| - |
192 |
| - ////public static getSignatureInfoFromGenericSymbol(symbol: TypeScript.PullSymbol, enclosingScopeSymbol: TypeScript.PullSymbol, compilerState: LanguageServiceCompiler) { |
193 |
| - //// var signatureGroupInfo = new FormalSignatureItemInfo(); |
194 |
| - |
195 |
| - //// var paramIndexInfo: number[] = []; |
196 |
| - //// var symbolName = symbol.getScopedNameEx(enclosingScopeSymbol, /*skipTypeParametersInName*/ false, /*useConstaintInName*/ true, /*getPrettyTypeName*/ false, /*getTypeParamMarkerInfo*/ true); |
197 |
| - |
198 |
| - //// signatureGroupInfo.signatureInfo = TypeScript.MemberName.memberNameToString(symbolName, paramIndexInfo); |
199 |
| - //// signatureGroupInfo.docComment = symbol.docComments(); |
200 |
| - |
201 |
| - //// var parameterMarkerIndex = 0; |
202 |
| - |
203 |
| - //// var typeSymbol = symbol.type; |
204 |
| - |
205 |
| - //// var typeParameters = typeSymbol.getTypeParameters(); |
206 |
| - //// for (var i = 0, n = typeParameters.length; i < n; i++) { |
207 |
| - //// var typeParameter = typeParameters[i]; |
208 |
| - //// var signatureTypeParameterInfo = new FormalTypeParameterInfo(); |
209 |
| - //// signatureTypeParameterInfo.name = typeParameter.getDisplayName(); |
210 |
| - //// signatureTypeParameterInfo.docComment = typeParameter.docComments(); |
211 |
| - //// signatureTypeParameterInfo.minChar = paramIndexInfo[2 * i]; |
212 |
| - //// signatureTypeParameterInfo.limChar = paramIndexInfo[2 * i + 1]; |
213 |
| - //// signatureGroupInfo.typeParameters.push(signatureTypeParameterInfo); |
214 |
| - //// } |
215 |
| - |
216 |
| - //// return [signatureGroupInfo]; |
217 |
| - ////} |
218 |
| - |
219 |
| - ////public static getActualSignatureInfoFromCallExpression(ast: IExpressionWithArgumentListSyntax, caretPosition: number, typeParameterInformation: IPartiallyWrittenTypeArgumentListInformation): ActualSignatureInfo { |
220 |
| - //// if (!ast) { |
221 |
| - //// return null; |
222 |
| - //// } |
223 |
| - |
224 |
| - //// var result = new ActualSignatureInfo(); |
225 |
| - |
226 |
| - //// // The expression is not guaranteed to be complete, we need to populate the min and lim with the most accurate information we have about |
227 |
| - //// // type argument and argument lists |
228 |
| - //// var parameterMinChar = caretPosition; |
229 |
| - //// var parameterLimChar = caretPosition; |
230 |
| - |
231 |
| - //// if (ast.argumentList.typeArgumentList) { |
232 |
| - //// parameterMinChar = Math.min(start(ast.argumentList.typeArgumentList)); |
233 |
| - //// parameterLimChar = Math.max(Math.max(start(ast.argumentList.typeArgumentList), end(ast.argumentList.typeArgumentList) + trailingTriviaWidth(ast.argumentList.typeArgumentList))); |
234 |
| - //// } |
235 |
| - |
236 |
| - //// if (ast.argumentList.arguments) { |
237 |
| - //// parameterMinChar = Math.min(parameterMinChar, end(ast.argumentList.openParenToken)); |
238 |
| - //// parameterLimChar = Math.max(parameterLimChar, |
239 |
| - //// ast.argumentList.closeParenToken.fullWidth() > 0 ? start(ast.argumentList.closeParenToken) : fullEnd(ast.argumentList)); |
240 |
| - //// } |
241 |
| - |
242 |
| - //// result.parameterMinChar = parameterMinChar; |
243 |
| - //// result.parameterLimChar = parameterLimChar; |
244 |
| - //// result.currentParameterIsTypeParameter = false; |
245 |
| - //// result.currentParameter = -1; |
246 |
| - |
247 |
| - //// if (typeParameterInformation) { |
248 |
| - //// result.currentParameterIsTypeParameter = true; |
249 |
| - //// result.currentParameter = typeParameterInformation.argumentIndex; |
250 |
| - //// } |
251 |
| - //// else if (ast.argumentList.arguments && ast.argumentList.arguments.length > 0) { |
252 |
| - //// result.currentParameter = 0; |
253 |
| - //// for (var index = 0; index < ast.argumentList.arguments.length; index++) { |
254 |
| - //// if (caretPosition > end(ast.argumentList.arguments[index]) + lastToken(ast.argumentList.arguments[index]).trailingTriviaWidth()) { |
255 |
| - //// result.currentParameter++; |
256 |
| - //// } |
257 |
| - //// } |
258 |
| - //// } |
259 |
| - |
260 |
| - //// return result; |
261 |
| - ////} |
262 |
| - |
263 |
| - ////public static getActualSignatureInfoFromPartiallyWritenGenericExpression(caretPosition: number, typeParameterInformation: IPartiallyWrittenTypeArgumentListInformation): ActualSignatureInfo { |
264 |
| - //// var result = new ActualSignatureInfo(); |
265 |
| - |
266 |
| - //// result.parameterMinChar = start(typeParameterInformation.lessThanToken); |
267 |
| - //// result.parameterLimChar = Math.max(fullEnd(typeParameterInformation.lessThanToken), caretPosition); |
268 |
| - //// result.currentParameterIsTypeParameter = true; |
269 |
| - //// result.currentParameter = typeParameterInformation.argumentIndex; |
270 |
| - |
271 |
| - //// return result; |
272 |
| - ////} |
273 |
| - |
274 |
| - ////public static isSignatureHelpBlocker(sourceUnit: TypeScript.SourceUnitSyntax, position: number): boolean { |
275 |
| - //// // We shouldn't be getting a possition that is outside the file because |
276 |
| - //// // isEntirelyInsideComment can't handle when the position is out of bounds, |
277 |
| - //// // callers should be fixed, however we should be resiliant to bad inputs |
278 |
| - //// // so we return true (this position is a blocker for getting signature help) |
279 |
| - //// if (position < 0 || position > fullWidth(sourceUnit)) { |
280 |
| - //// return true; |
281 |
| - //// } |
282 |
| - |
283 |
| - //// return TypeScript.Syntax.isEntirelyInsideComment(sourceUnit, position); |
284 |
| - ////} |
285 |
| - |
286 |
| - ////public static isTargetOfObjectCreationExpression(positionedToken: TypeScript.ISyntaxToken): boolean { |
287 |
| - //// var positionedParent = TypeScript.Syntax.getAncestorOfKind(positionedToken, TypeScript.SyntaxKind.ObjectCreationExpression); |
288 |
| - //// if (positionedParent) { |
289 |
| - //// var objectCreationExpression = <TypeScript.ObjectCreationExpressionSyntax> positionedParent; |
290 |
| - //// var expressionRelativeStart = objectCreationExpression.newKeyword.fullWidth(); |
291 |
| - //// var tokenRelativeStart = positionedToken.fullStart() - fullStart(positionedParent); |
292 |
| - //// return tokenRelativeStart >= expressionRelativeStart && |
293 |
| - //// tokenRelativeStart <= (expressionRelativeStart + fullWidth(objectCreationExpression.expression)); |
294 |
| - //// } |
295 |
| - |
296 |
| - //// return false; |
297 |
| - ////} |
298 |
| - |
299 | 130 | //private static moveBackUpTillMatchingTokenKind(token: TypeScript.ISyntaxToken, tokenKind: TypeScript.SyntaxKind, matchingTokenKind: TypeScript.SyntaxKind): TypeScript.ISyntaxToken {
|
300 | 131 | // if (!token || token.kind() !== tokenKind) {
|
301 | 132 | // throw TypeScript.Errors.invalidOperation();
|
@@ -360,8 +191,10 @@ module ts.SignatureHelp {
|
360 | 191 |
|
361 | 192 | return createSignatureHelpItems(candidates, resolvedSignature, argumentList);
|
362 | 193 |
|
363 |
| - // If node is an argument, returns its index in the argument list |
364 |
| - // If not, returns -1 |
| 194 | + /** |
| 195 | + * If node is an argument, returns its index in the argument list. |
| 196 | + * If not, returns -1. |
| 197 | + */ |
365 | 198 | function getImmediatelyContainingArgumentList(node: Node): Node {
|
366 | 199 | if (node.parent.kind !== SyntaxKind.CallExpression && node.parent.kind !== SyntaxKind.NewExpression) {
|
367 | 200 | return undefined;
|
|
0 commit comments