mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Initial fix for rename for parameter property declaration
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user