Skip to content

Allow to find all references for constructors#10540

Merged
12 commits merged into
masterfrom
constructor_references
Sep 1, 2016
Merged

Allow to find all references for constructors#10540
12 commits merged into
masterfrom
constructor_references

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Aug 25, 2016

Fixes #2114

We accomplish this by looking for the symbol of the constructor but the name of the class.
We also need new code to find constructor calls by super() and new this().

Comment thread src/services/services.ts Outdated
// For that to work, the jsdoc comments should still be the leading trivia of the first child.
// Restoring the scanner position ensures that.
// For that to work, the jsdoc comments should still be the leading trivia of the first child.
// Restoring the scanner position ensures that.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this comment block is gone in master)

@ghost ghost force-pushed the constructor_references branch from 1ccabe4 to 65023a2 Compare August 26, 2016 16:19
@ghost ghost changed the title All to find all references for constructors Allow to find all references for constructors Aug 26, 2016
@ghost ghost force-pushed the constructor_references branch from 65023a2 to 3f126a5 Compare August 26, 2016 16:19
Comment thread src/services/services.ts Outdated
}

/** Get `C` given `N` if `N` is in the position `class C extends N` */
function tryGetClassExtendingNode(node: Node): ClassLikeDeclaration | undefined {
Copy link
Copy Markdown
Member

@sandersn sandersn Aug 26, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there something like this inside compiler/ ? I remember using something very similar that uses symbols to follow declarations, but there may also be a function that operates solely on nodes. #Closed

Fixes a bug when constructor overloads are improper and no signatures can be found.
Comment thread src/services/services.ts Outdated
: isConstructor
// For constructor, get type of the class.
? typeChecker.getTypeOfSymbolAtLocation(symbol.parent, location)
: typeChecker.getTypeOfSymbolAtLocation(symbol, location);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what was the old behaviour without the isConstructor case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I hover over constructor in a class named K I get a display like "constructor K(n: number): K", but when I hover over K, I get "class K". Is that the old behaviour?

@ghost ghost assigned sandersn Aug 29, 2016
@ghost ghost assigned zhengbli Aug 30, 2016
Comment thread src/services/services.ts
return isCallOrNewExpressionTarget(node, SyntaxKind.NewExpression);
}

function isCallOrNewExpressionTarget(node: Node, kind: SyntaxKind) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind: SyntaxKind.CallExpression | SyntaxKind.NewExpression

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would require us to do a new LKG to get that feature.

@ghost ghost merged commit 8038eb9 into master Sep 1, 2016
@ghost ghost deleted the constructor_references branch September 1, 2016 20:24
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants