mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Some renaming and added comments as per feedback
This commit is contained in:
parent
1939c7f2cd
commit
c3c44dc3c8
@ -93,9 +93,9 @@ module ts {
|
||||
getIndexTypeOfType,
|
||||
getReturnTypeOfSignature,
|
||||
getSymbolsInScope,
|
||||
getSymbolInfoOfLocation,
|
||||
getSymbolAtLocation,
|
||||
getShorthandAssignmentValueSymbol,
|
||||
getTypeOfLocation,
|
||||
getTypeAtLocation,
|
||||
typeToString,
|
||||
getSymbolDisplayBuilder,
|
||||
symbolToString,
|
||||
@ -4398,18 +4398,30 @@ module ts {
|
||||
ts.forEach(containerNodes, node => { getTypeOfNode(node); });
|
||||
}
|
||||
|
||||
function getSymbolInfoOfLocation(node: Node): Symbol {
|
||||
function getSymbolAtLocation(node: Node): Symbol {
|
||||
resolveLocation(node);
|
||||
return getSymbolInfo(node);
|
||||
}
|
||||
|
||||
function getTypeOfLocation(node: Node): Type {
|
||||
function getTypeAtLocation(node: Node): Type {
|
||||
resolveLocation(node);
|
||||
return getTypeOfNode(node);
|
||||
}
|
||||
|
||||
function getTypeOfSymbolAtLocation(symbol: Symbol, node: Node): Type {
|
||||
resolveLocation(node);
|
||||
// Get the narrowed type of symbol at given location instead of just getting
|
||||
// the type of the symbol.
|
||||
// eg.
|
||||
// function foo(a: string | number) {
|
||||
// if (typeof a === "string") {
|
||||
// a/**/
|
||||
// }
|
||||
// }
|
||||
// getTypeOfSymbol for a would return type of parameter symbol string | number
|
||||
// Unless we provide location /**/, checker wouldn't know how to narrow the type
|
||||
// By using getNarrowedTypeOfSymbol would return string since it would be able to narrow
|
||||
// it by typeguard in the if true condition
|
||||
return getNarrowedTypeOfSymbol(symbol, node);
|
||||
}
|
||||
|
||||
|
||||
@ -891,9 +891,9 @@ module ts {
|
||||
getIndexTypeOfType(type: Type, kind: IndexKind): Type;
|
||||
getReturnTypeOfSignature(signature: Signature): Type;
|
||||
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
|
||||
getSymbolInfoOfLocation(node: Node): Symbol;
|
||||
getSymbolAtLocation(node: Node): Symbol;
|
||||
getShorthandAssignmentValueSymbol(location: Node): Symbol;
|
||||
getTypeOfLocation(node: Node): Type;
|
||||
getTypeAtLocation(node: Node): Type;
|
||||
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
|
||||
symbolToString(symbol: Symbol, enclosingDeclaration?: Node, meaning?: SymbolFlags): string;
|
||||
getSymbolDisplayBuilder(): SymbolDisplayBuilder;
|
||||
|
||||
@ -2428,7 +2428,7 @@ module ts {
|
||||
isMemberCompletion = true;
|
||||
|
||||
if (node.kind === SyntaxKind.Identifier || node.kind === SyntaxKind.QualifiedName || node.kind === SyntaxKind.PropertyAccessExpression) {
|
||||
var symbol = typeInfoResolver.getSymbolInfoOfLocation(node);
|
||||
var symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
|
||||
// This is an alias, follow what it aliases
|
||||
if (symbol && symbol.flags & SymbolFlags.Import) {
|
||||
@ -2445,7 +2445,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
var type = typeInfoResolver.getTypeOfLocation(node);
|
||||
var type = typeInfoResolver.getTypeAtLocation(node);
|
||||
if (type) {
|
||||
// Filter private properties
|
||||
forEach(type.getApparentProperties(), symbol => {
|
||||
@ -3089,7 +3089,7 @@ module ts {
|
||||
displayParts.push(punctuationPart(SyntaxKind.CloseParenToken));
|
||||
}
|
||||
else {
|
||||
var internalAliasSymbol = typeResolver.getSymbolInfoOfLocation(importDeclaration.moduleReference);
|
||||
var internalAliasSymbol = typeResolver.getSymbolAtLocation(importDeclaration.moduleReference);
|
||||
if (internalAliasSymbol) {
|
||||
displayParts.push(spacePart());
|
||||
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
|
||||
@ -3199,7 +3199,7 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var symbol = typeInfoResolver.getSymbolInfoOfLocation(node);
|
||||
var symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
if (!symbol) {
|
||||
// Try getting just type at this position and show
|
||||
switch (node.kind) {
|
||||
@ -3209,7 +3209,7 @@ module ts {
|
||||
case SyntaxKind.ThisKeyword:
|
||||
case SyntaxKind.SuperKeyword:
|
||||
// For the identifiers/this/super etc get the type at position
|
||||
var type = typeInfoResolver.getTypeOfLocation(node);
|
||||
var type = typeInfoResolver.getTypeAtLocation(node);
|
||||
if (type) {
|
||||
return {
|
||||
kind: ScriptElementKind.unknown,
|
||||
@ -3326,7 +3326,7 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var symbol = typeInfoResolver.getSymbolInfoOfLocation(node);
|
||||
var symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. node is string or number keyword,
|
||||
// or the symbol was an internal symbol and does not have a declaration e.g. undefined symbol
|
||||
@ -3958,7 +3958,7 @@ module ts {
|
||||
return getReferencesForSuperKeyword(node);
|
||||
}
|
||||
|
||||
var symbol = typeInfoResolver.getSymbolInfoOfLocation(node);
|
||||
var symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
|
||||
// Could not find a symbol e.g. unknown identifier
|
||||
if (!symbol) {
|
||||
@ -4210,7 +4210,7 @@ module ts {
|
||||
return;
|
||||
}
|
||||
|
||||
var referenceSymbol = typeInfoResolver.getSymbolInfoOfLocation(referenceLocation);
|
||||
var referenceSymbol = typeInfoResolver.getSymbolAtLocation(referenceLocation);
|
||||
if (referenceSymbol) {
|
||||
var referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
|
||||
var shorthandValueSymbol = typeInfoResolver.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
|
||||
@ -4443,7 +4443,7 @@ module ts {
|
||||
|
||||
function getPropertySymbolFromTypeReference(typeReference: TypeReferenceNode) {
|
||||
if (typeReference) {
|
||||
var type = typeInfoResolver.getTypeOfLocation(typeReference);
|
||||
var type = typeInfoResolver.getTypeAtLocation(typeReference);
|
||||
if (type) {
|
||||
var propertySymbol = typeInfoResolver.getPropertyOfType(type, propertyName);
|
||||
if (propertySymbol) {
|
||||
@ -4967,7 +4967,7 @@ module ts {
|
||||
// Only walk into nodes that intersect the requested span.
|
||||
if (node && span.intersectsWith(node.getStart(), node.getWidth())) {
|
||||
if (node.kind === SyntaxKind.Identifier && node.getWidth() > 0) {
|
||||
var symbol = typeInfoResolver.getSymbolInfoOfLocation(node);
|
||||
var symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
if (symbol) {
|
||||
var type = classifySymbol(symbol, getMeaningFromLocation(node));
|
||||
if (type) {
|
||||
@ -5396,7 +5396,7 @@ module ts {
|
||||
|
||||
// Can only rename an identifier.
|
||||
if (node && node.kind === SyntaxKind.Identifier) {
|
||||
var symbol = typeInfoResolver.getSymbolInfoOfLocation(node);
|
||||
var symbol = typeInfoResolver.getSymbolAtLocation(node);
|
||||
|
||||
// Only allow a symbol to be renamed if it actually has at least one declaration.
|
||||
if (symbol && symbol.getDeclarations() && symbol.getDeclarations().length > 0) {
|
||||
|
||||
@ -457,7 +457,7 @@ module ts.SignatureHelp {
|
||||
|
||||
var invocation = argumentListInfo.invocation;
|
||||
var callTarget = getInvokedExpression(invocation)
|
||||
var callTargetSymbol = typeInfoResolver.getSymbolInfoOfLocation(callTarget);
|
||||
var callTargetSymbol = typeInfoResolver.getSymbolAtLocation(callTarget);
|
||||
var callTargetDisplayParts = callTargetSymbol && symbolToDisplayParts(typeInfoResolver, callTargetSymbol, /*enclosingDeclaration*/ undefined, /*meaning*/ undefined);
|
||||
var items: SignatureHelpItem[] = map(candidates, candidateSignature => {
|
||||
var signatureHelpParameters: SignatureHelpParameter[];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user