Skip to content
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

Add see tag support #39760

Merged
merged 36 commits into from Sep 9, 2020
Merged

Add see tag support #39760

merged 36 commits into from Sep 9, 2020

Conversation

@Kingwl
Copy link
Member

@Kingwl Kingwl commented Jul 27, 2020

Fixes a part of #35524

seetag

@Kingwl Kingwl marked this pull request as draft Jul 27, 2020
Kingwl added 2 commits Jul 27, 2020
@Kingwl Kingwl changed the title Add see tag parser Add see tag support Jul 27, 2020
@Kingwl
Copy link
Member Author

@Kingwl Kingwl commented Jul 27, 2020

Friendly ping @sandersn .

I'm not sure what is the expected of unittests:: JSDocParsing

@Kingwl Kingwl marked this pull request as ready for review Jul 27, 2020
@sandersn
Copy link
Member

@sandersn sandersn commented Jul 27, 2020

Couple of quick comments -- I've only glanced at the code, haven't really read it yet.

  1. The jsDocParsing unittests are pretty basic. I think the existing test for @see there is sufficient.
  2. The tests I'd like to see are goto-def tests, obviously.
  3. My understanding of jsdoc is that braces are not required here since these aren't type references, but we might as well parse them because people may still use them ... and they aren't ambiguous, so why not?
Kingwl added 3 commits Jul 28, 2020
@Kingwl
Copy link
Member Author

@Kingwl Kingwl commented Jul 28, 2020

Hoops. Seems not my fault.

@Kingwl
Copy link
Member Author

@Kingwl Kingwl commented Aug 3, 2020

UP ↑

@Kingwl
Copy link
Member Author

@Kingwl Kingwl commented Aug 27, 2020

I'm sorry, but I don't know how to refer to the methods of a class in the classes' jsdoc comment.

And I'm not sure what is the expected behavior in below case:

function foo (a: string) {
    /**
     * @see {a}
     */
    function bar (a: string) {

    }
}

When we apply goto-def at see tag, It should be linked to function foo or bar ?

wip
@sandersn
Copy link
Member

@sandersn sandersn commented Sep 1, 2020

The class-method question is a variant of the function-parameter question:

class K {
  m { }
/**
 * Here's how to use C:
 * First, construct it, then call m
 * @see m
 */
class C {
  m() { }
}
}

I'm not sure what to do there either.

Probably we should resolve to the outer declaration. (foo:a and K.m) I'll ask the team to see if anybody else has opinions.

@sandersn sandersn added this to Waiting on author in PR Backlog Sep 1, 2020
egamma and others added 6 commits Sep 1, 2020
This reverts commit b3178d4.
@Kingwl
Copy link
Member Author

@Kingwl Kingwl commented Sep 2, 2020

@sandersn Is that a valid syntax?... I'm not sure what are you expected...

@typescript-bot pack this.

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Sep 2, 2020

Heya @Kingwl, I've started to run the tarball bundle task on this PR at 51b67d7. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

@typescript-bot typescript-bot commented Sep 2, 2020

Hey @Kingwl, I've packed this into an installable tgz. You can install it for testing by referencing it in your package.json like so:

{
    "devDependencies": {
        "typescript": "https://typescript.visualstudio.com/cf7ac146-d525-443c-b23c-0d58337efebc/_apis/build/builds/83979/artifacts?artifactName=tgz&fileId=9A8F21D752ED3524E8C7785D7AE26622ABF7CCFFE3F5BCDE9FA311FFB577030F02&fileName=/typescript-4.1.0-insiders.20200902.tgz"
    }
}

and then running npm install.


There is also a playground for this build.

@weswigham weswigham force-pushed the microsoft:master branch from 3b502f4 to 838a5e6 Sep 2, 2020
@sandersn
Copy link
Member

@sandersn sandersn commented Sep 3, 2020

Based on my comment on the original bug, here are some more test cases that need to be added. They don't have to pass, but I want to make sure they don't crash:

  1. @see Class#method -- this should, ideally, resolve to Class at least.
  2. @see {@link M.f} -- doesn't need to work yet.
  3. @see M.f() -- should, ideally, resolve to M.f and ignore the trailing ().

I'm going to do a bit more looking to see how well we'll be able to resolve module references in things like lodash. I think a lot of uses just make up a name for the module they are inside, even though it's never declared inside the module itself.

@sandersn
Copy link
Member

@sandersn sandersn commented Sep 9, 2020

The only question I have left before merging this is how to resolve x here:

/** @param x @see x */
function f(x) { }

Right now, @see x doesn't resolve in the scope of f.

But I don't actually think people write this. I'm going to figure out if that's the case.

Either way, I think the best thing is to resolve starting from the parameter list of a function declaration.

@Kingwl
Copy link
Member Author

@Kingwl Kingwl commented Sep 9, 2020

Maybe we could peek the parameters first if jsdoc attached on a function like declaration.
But that will point to two different symbol. Is that ok?

@sandersn
Copy link
Member

@sandersn sandersn commented Sep 9, 2020

If we resolveName starting from the parameter list, I think you can get it to resolve to just the parameter. So @see on a function should start from the parameter list probably. (or it may be the function itself, although I'd rather not resolve to locals of a function.)

Copy link
Member

@sandersn sandersn left a comment

My suggestion fixes the parameter name resolution, still need a test like

const x = 1
/** @see x */
function f(x) { }

To make sure that x resolves to the parameter.

src/compiler/checker.ts Outdated Show resolved Hide resolved
PR Backlog automation moved this from Waiting on author to Needs merge Sep 9, 2020
@sandersn sandersn merged commit ee5f51b into microsoft:master Sep 9, 2020
10 checks passed
10 checks passed
build (10.x)
Details
CodeQL-Build
Details
build (12.x)
Details
build (14.x)
Details
CodeQL No new alerts
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
license/cla All CLA requirements met.
Details
node10 Build #84654 succeeded
Details
node12 Build #84652 succeeded
Details
node14 Build #84653 succeeded
Details
PR Backlog automation moved this from Needs merge to Done Sep 9, 2020
@Kingwl Kingwl deleted the Kingwl:see-tag branch Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
PR Backlog
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

9 participants
You can’t perform that action at this time.