Skip to content

Treat special property access symbol differently when retriving documentation #10426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 20, 2016

Conversation

zhengbli
Copy link
Contributor

@zhengbli zhengbli commented Aug 19, 2016

Fixes #9518

We used to not be able to get documentation for the following case:

// @Filename: a.js
/**
* Modify the parameter
* @param {string} p1
*/
var foo = function (p1) { }
exports.foo = foo;

// @Filename: b.js
import a = require("./a");
a.fo/*Cursor Here*/

The completion entry detail at cursor position is supposed to show Modify the parameter comment but it wasn't. This PR fixes the issue.

... when retriving documentation
@zhengbli
Copy link
Contributor Author

Ping @vladima and @mhegazy

// The pattern of such special property access is that the parent symbol is the symbol of the file.
if (symbol.parent && forEach(symbol.parent.declarations, declaration => declaration.kind === SyntaxKind.SourceFile)) {
forEach(symbol.declarations, declaration => {
if (declaration.parent && declaration.parent.kind === SyntaxKind.BinaryExpression) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: invert the condition to reduce nesting

@vladima
Copy link
Contributor

vladima commented Aug 19, 2016

👍 with a few nits

if (rhsSymbol) {
documentation = rhsSymbol.getDocumentationComment();
if (documentation.length > 0) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

break since you are not in lambda anymore

@zhengbli zhengbli merged commit d8ab098 into microsoft:master Aug 20, 2016
@zhengbli zhengbli deleted the 9518 branch August 20, 2016 00:09
//// * @param {string} p1
//// */
//// var foo = function (p1) { }
//// exports.foo = foo;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we also add test for module.exports.foo case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vladima Sure, added at #10458

zhengbli added a commit that referenced this pull request Aug 21, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
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.

Better JavaScript completion thru JSDOC
3 participants