Initial fix for rename for parameter property declaration

This commit is contained in:
Yui T
2015-12-11 19:27:24 -08:00
parent f51de5b28f
commit 0f3eb0a058
5 changed files with 30 additions and 4 deletions
+1 -4
View File
@@ -1444,10 +1444,7 @@ namespace ts {
// If this is a property-parameter, then also declare the property symbol into the
// containing class.
if (node.flags & NodeFlags.AccessibilityModifier &&
node.parent.kind === SyntaxKind.Constructor &&
isClassLike(node.parent.parent)) {
if (isPropertyParameterDeclaration(node)) {
const classDeclaration = <ClassLikeDeclaration>node.parent.parent;
declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, SymbolFlags.Property, SymbolFlags.PropertyExcludes);
}
+11
View File
@@ -67,6 +67,7 @@ namespace ts {
// The language service will always care about the narrowed type of a symbol, because that is
// the type the language says the symbol should have.
getTypeOfSymbolAtLocation: getNarrowedTypeOfSymbol,
getSymbolOfParameterPropertyDeclaration,
getDeclaredTypeOfSymbol,
getPropertiesOfType,
getPropertyOfType,
@@ -427,6 +428,16 @@ namespace ts {
}
// return undefined if we can't find a symbol.
}
function getSymbolOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[] {
const constructoDeclaration = parameter.parent;
const classDeclaration = parameter.parent.parent;
const parameterSymbol = getSymbol(constructoDeclaration.locals, parameterName, SymbolFlags.Value);
const propertySymbol = getSymbol(classDeclaration.symbol.members, parameterName, SymbolFlags.Value);
return parameterSymbol && propertySymbol ? [parameterSymbol, propertySymbol] : undefined;
}
function isBlockScopedNameDeclaredBeforeUse(declaration: Declaration, usage: Node): boolean {
const declarationFile = getSourceFileOfNode(declaration);
+1
View File
@@ -1723,6 +1723,7 @@ namespace ts {
getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[];
getSymbolAtLocation(node: Node): Symbol;
getSymbolOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[];
getShorthandAssignmentValueSymbol(location: Node): Symbol;
getTypeAtLocation(node: Node): Type;
typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string;
+6
View File
@@ -2741,4 +2741,10 @@ namespace ts {
}
}
}
export function isPropertyParameterDeclaration(node: ParameterDeclaration): boolean {
// If this is a property-parameter, then also declare the property symbol into the
// containing class.
return node.flags & NodeFlags.AccessibilityModifier && node.parent.kind === SyntaxKind.Constructor && isClassLike(node.parent.parent);
}
}