Skip to content

Commit ac88d8d

Browse files
committed
More cleanup and PR feedback
1 parent 66f9fe5 commit ac88d8d

File tree

4 files changed

+16
-176
lines changed

4 files changed

+16
-176
lines changed

Jakefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ var servicesSources = [
5454
}).concat([
5555
"services.ts",
5656
"shims.ts",
57-
"signatureHelp.ts"
57+
"signatureHelp.ts",
58+
"utilities.ts"
5859
].map(function (f) {
5960
return path.join(servicesDirectory, f);
6061
}));

src/services/services.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/// <reference path='breakpoints.ts' />
1212
/// <reference path='indentation.ts' />
1313
/// <reference path='signatureHelp.ts' />
14-
/// <reference path='servicesSyntaxUtilities.ts' />
14+
/// <reference path='utilities.ts' />
1515
/// <reference path='formatting\formatting.ts' />
1616
/// <reference path='formatting\smartIndenter.ts' />
1717

@@ -3446,7 +3446,9 @@ module ts {
34463446
}
34473447

34483448
// Signature help
3449-
// This is a semantic operation
3449+
/**
3450+
* This is a semantic operation.
3451+
*/
34503452
function getSignatureHelpItems(fileName: string, position: number): SignatureHelpItems {
34513453
synchronizeHostData();
34523454

@@ -3456,7 +3458,9 @@ module ts {
34563458
return SignatureHelp.getSignatureHelpItems(sourceFile, position, typeInfoResolver, cancellationToken);
34573459
}
34583460

3459-
// This is a syntactic operation
3461+
/**
3462+
* This is a syntactic operation
3463+
*/
34603464
function getSignatureHelpCurrentArgumentState(fileName: string, position: number, applicableSpanStart: number): SignatureHelpState {
34613465
fileName = TypeScript.switchToForwardSlashes(fileName);
34623466
var sourceFile = getCurrentSourceFile(fileName);

src/services/signatureHelp.ts

Lines changed: 4 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
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-
41
///<reference path='services.ts' />
52

63
module ts.SignatureHelp {
@@ -130,172 +127,6 @@ module ts.SignatureHelp {
130127
// return null;
131128
//}
132129

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-
299130
//private static moveBackUpTillMatchingTokenKind(token: TypeScript.ISyntaxToken, tokenKind: TypeScript.SyntaxKind, matchingTokenKind: TypeScript.SyntaxKind): TypeScript.ISyntaxToken {
300131
// if (!token || token.kind() !== tokenKind) {
301132
// throw TypeScript.Errors.invalidOperation();
@@ -360,8 +191,10 @@ module ts.SignatureHelp {
360191

361192
return createSignatureHelpItems(candidates, resolvedSignature, argumentList);
362193

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+
*/
365198
function getImmediatelyContainingArgumentList(node: Node): Node {
366199
if (node.parent.kind !== SyntaxKind.CallExpression && node.parent.kind !== SyntaxKind.NewExpression) {
367200
return undefined;

src/services/servicesSyntaxUtilities.ts renamed to src/services/utilities.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ module ts {
3131
return syntaxList;
3232
}
3333

34-
// Includes the start position of each child, but excludes the end
34+
/**
35+
* Includes the start position of each child, but excludes the end.
36+
*/
3537
export function findListItemIndexContainingPosition(list: Node, position: number): number {
3638
Debug.assert(list.kind === SyntaxKind.SyntaxList);
3739
var children = list.getChildren();

0 commit comments

Comments
 (0)