Skip to content

Commit 53d084e

Browse files
committed
Qualify properties methods of the instantiated symbol correctly.
1 parent 0af16a5 commit 53d084e

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

src/services/services.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2613,30 +2613,31 @@ module ts {
26132613

26142614
function getSymbolDisplayPartsofSymbol(symbol: Symbol, sourceFile: SourceFile, enclosingDeclaration: Node, typeResolver: TypeChecker): SymbolDisplayPart[] {
26152615
var displayParts: SymbolDisplayPart[] = [];
2616-
if (symbol.flags & SymbolFlags.Class) {
2616+
var symbolFlags = typeResolver.getTargetSymbol(symbol).flags;
2617+
if (symbolFlags & SymbolFlags.Class) {
26172618
displayParts.push(keywordPart(SyntaxKind.ClassKeyword));
26182619
displayParts.push(spacePart());
26192620
displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile));
26202621
}
2621-
if (symbol.flags & SymbolFlags.Interface) {
2622+
if (symbolFlags & SymbolFlags.Interface) {
26222623
addNewLineIfDisplayPartsExist();
26232624
displayParts.push(keywordPart(SyntaxKind.InterfaceKeyword));
26242625
displayParts.push(spacePart());
26252626
displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile));
26262627
}
2627-
if (symbol.flags & SymbolFlags.Enum) {
2628+
if (symbolFlags & SymbolFlags.Enum) {
26282629
addNewLineIfDisplayPartsExist();
26292630
displayParts.push(keywordPart(SyntaxKind.EnumKeyword));
26302631
displayParts.push(spacePart());
26312632
displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile));
26322633
}
2633-
if (symbol.flags & SymbolFlags.Module) {
2634+
if (symbolFlags & SymbolFlags.Module) {
26342635
addNewLineIfDisplayPartsExist();
26352636
displayParts.push(keywordPart(SyntaxKind.ModuleKeyword));
26362637
displayParts.push(spacePart());
26372638
displayParts.push.apply(displayParts, symbolToDisplayParts(typeResolver, symbol, sourceFile));
26382639
}
2639-
if (symbol.flags & SymbolFlags.TypeParameter) {
2640+
if (symbolFlags & SymbolFlags.TypeParameter) {
26402641
addNewLineIfDisplayPartsExist();
26412642
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
26422643
displayParts.push(textPart("type parameter"));
@@ -2647,37 +2648,37 @@ module ts {
26472648
else {
26482649
//public static string FormatSymbolName(string name, string fullSymbolName, string kind, out bool useTypeName)
26492650
var text: string;
2650-
if (symbol.flags & SymbolFlags.Property) {
2651+
if (symbolFlags & SymbolFlags.Property) {
26512652
text = "property";
26522653
}
2653-
else if (symbol.flags & SymbolFlags.EnumMember) {
2654+
else if (symbolFlags & SymbolFlags.EnumMember) {
26542655
text = "enum member";
26552656
}
2656-
else if (symbol.flags & SymbolFlags.Function) {
2657+
else if (symbolFlags & SymbolFlags.Function) {
26572658
text = "function";
26582659
}
2659-
else if (symbol.flags & SymbolFlags.Variable) {
2660+
else if (symbolFlags & SymbolFlags.Variable) {
26602661
if (ts.forEach(symbol.declarations, declaration => declaration.kind === SyntaxKind.Parameter)) {
26612662
text = "parameter";
26622663
}
26632664
else {
26642665
text = "var";
26652666
}
26662667
}
2667-
else if (symbol.flags & SymbolFlags.Method) {
2668+
else if (symbolFlags & SymbolFlags.Method) {
26682669
text = "method";
26692670
}
2670-
else if (symbol.flags & SymbolFlags.Constructor) {
2671+
else if (symbolFlags & SymbolFlags.Constructor) {
26712672
text = "constructor";
26722673
}
2673-
else if (symbol.flags & SymbolFlags.GetAccessor) {
2674+
else if (symbolFlags & SymbolFlags.GetAccessor) {
26742675
text = "getter";
26752676
}
2676-
else if (symbol.flags & SymbolFlags.SetAccessor) {
2677+
else if (symbolFlags & SymbolFlags.SetAccessor) {
26772678
text = "setter";
26782679
}
26792680

2680-
if (text || symbol.flags & SymbolFlags.Signature) {
2681+
if (text || symbolFlags & SymbolFlags.Signature) {
26812682
addNewLineIfDisplayPartsExist();
26822683
if (text) {
26832684
displayParts.push(punctuationPart(SyntaxKind.OpenParenToken));
@@ -2689,23 +2690,23 @@ module ts {
26892690
}
26902691

26912692
var type = typeResolver.getTypeOfSymbol(symbol);
2692-
if (symbol.flags & SymbolFlags.Property ||
2693-
symbol.flags & SymbolFlags.Variable) {
2693+
if (symbolFlags & SymbolFlags.Property ||
2694+
symbolFlags & SymbolFlags.Variable) {
26942695
if (type) {
26952696
displayParts.push(punctuationPart(SyntaxKind.ColonToken));
26962697
displayParts.push(spacePart());
26972698
displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, type, enclosingDeclaration, TypeFormatFlags.NoTruncation));
26982699
}
26992700
}
2700-
else if (symbol.flags & SymbolFlags.Function ||
2701-
symbol.flags & SymbolFlags.Method ||
2702-
symbol.flags & SymbolFlags.Signature ||
2703-
symbol.flags & SymbolFlags.Accessor) {
2701+
else if (symbolFlags & SymbolFlags.Function ||
2702+
symbolFlags & SymbolFlags.Method ||
2703+
symbolFlags & SymbolFlags.Signature ||
2704+
symbolFlags & SymbolFlags.Accessor) {
27042705
if (type) {
27052706
displayParts.push.apply(displayParts, typeToDisplayParts(typeResolver, type, enclosingDeclaration, TypeFormatFlags.NoTruncation | TypeFormatFlags.NoArrowStyleTopLevelSignature));
27062707
}
27072708
}
2708-
else if (symbol.flags & SymbolFlags.EnumMember) {
2709+
else if (symbolFlags & SymbolFlags.EnumMember) {
27092710
var declaration = symbol.declarations[0];
27102711
if (declaration.kind === SyntaxKind.EnumMember) {
27112712
var constantValue = typeResolver.getEnumMemberValue(<EnumMember>declaration);

tests/cases/fourslash/completionListOfGnericSymbol.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
////a./**/
77

88
goTo.marker();
9-
verify.memberListContains('length', "number", /*docComments*/ undefined, /*kind*/ "property");
10-
verify.memberListContains('toString', "() => string", /*docComments*/ undefined, /*kind*/ "method");
9+
// TODO. show as Array<number> or Array<T>.length instead
10+
verify.memberListContains('length', "(property) Array.length: number", /*docComments*/ undefined, /*kind*/ "property");
11+
verify.memberListContains('toString', "(method) Array.toString(): string", /*docComments*/ undefined, /*kind*/ "method");
1112

0 commit comments

Comments
 (0)