diff --git a/kythe/typescript/indexer.ts b/kythe/typescript/indexer.ts index 1cc600df07..dcacef68c6 100644 --- a/kythe/typescript/indexer.ts +++ b/kythe/typescript/indexer.ts @@ -2375,6 +2375,16 @@ class Visitor { if (refType == RefType.WRITE || refType == RefType.READ_WRITE) { this.emitEdge(anchor, EdgeKind.REF_WRITES, name); } + // For classes emit ref/id to the type node in addition to regular + // ref. When user check refs for a class - they usually check get + // refs of the class node, not the constructor node. That's why + // we need ref/id from all usages to the class node. + if (sym.flags & ts.SymbolFlags.Class) { + const className = this.host.getSymbolName(sym, TSNamespace.TYPE); + if (className != null) { + this.emitEdge(anchor, EdgeKind.REF_ID, className); + } + } this.addInfluencer(name); } diff --git a/kythe/typescript/testdata/class.ts b/kythe/typescript/testdata/class.ts index 53531ed9d6..4b1872e30c 100644 --- a/kythe/typescript/testdata/class.ts +++ b/kythe/typescript/testdata/class.ts @@ -94,6 +94,7 @@ class SubSubclass extends Class implements IExtended { } //- @Class ref ClassValue +//- @Class ref/id Class let instance = new Class(3, 'a'); //- @otherMember ref OtherMember instance.otherMember; @@ -101,3 +102,7 @@ instance.otherMember; // Using Class in type position should still create a link to the class. //- @Class ref Class let useAsType: Class = instance; + +//- @Class ref ClassValue +//- @Class ref/id Class +Class;