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

Quick info on 'new' keyword should be the same as that of resolved expression #31180

Closed
DanielRosenwasser opened this issue Apr 30, 2019 · 12 comments · Fixed by #31262
Closed
Labels
Domain: Quick Info e.g. hover text, tool-tips, and tooltips. Experience Enhancement Noncontroversial enhancements Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this

Comments

@DanielRosenwasser
Copy link
Member

class C {
    /**
     * NOTE: this constructor is private! Please use the factory function
     */
    private constructor() { }
    static makeC() { new C(); }
}

new C();

Expected: Quick info on C and new in new C() should be the same.
Actual: no quick info on new

Why it matters

It'd be nice if hovering over the error at any point could also give you better quick info.

image

image

@DanielRosenwasser DanielRosenwasser added Help Wanted You can do this Good First Issue Well scoped, documented and has the green light Domain: Quick Info e.g. hover text, tool-tips, and tooltips. Experience Enhancement Noncontroversial enhancements labels Apr 30, 2019
@DanielRosenwasser
Copy link
Member Author

(Courtesy of @jonathandturner)

@DanielRosenwasser DanielRosenwasser changed the title Quick info on 'new' keyword should be the same as that of C Quick info on 'new' keyword should be the same as that of resolved expression Apr 30, 2019
@rpgeeganage
Copy link
Contributor

@DanielRosenwasser ,
May I work on this please?

@DanielRosenwasser
Copy link
Member Author

Yes you certainly may! This one will be in the language service. Start here in getQuickInfoAtPosition.

Tests can be found in tests/cases/fourslash. I'd make a quickInfoOnNewKeyword01.ts file there.

@DanielRosenwasser DanielRosenwasser added this to the Backlog milestone May 1, 2019
@rpgeeganage
Copy link
Contributor

@DanielRosenwasser
Thanks a lot. I’ll start working on this.

@rpgeeganage
Copy link
Contributor

I have started working on this. Will open a PR as soon as I finished it.
Thanks.

@rpgeeganage
Copy link
Contributor

rpgeeganage commented May 1, 2019

@DanielRosenwasser ,
Can you please help me on viewing the quick info?
I started with a test case. I added new file quickInfoOnNewKeyword01.ts in tests/cases/fourslash.
The content of the test file is as follows.

/// <reference path='fourslash.ts' />

////class C {
/////**
//// * NOTE: this constructor is private! Please use the factory function
//// */
////private constructor() { }
////static makeC() { new C(); }
////}
////
////new C();

debug.printCurrentQuickInfo();

After that I ran the test as gulp runtests --tests=quickInfoOnNewKeyword01.
The only output was:
Quick Info: class C
How can I print the entire quick info ?

@DanielRosenwasser
Copy link
Member Author

I'm not sure since it's been a while and I don't develop in the codebase as much anymore - but you'll have to look for where quick info is resolved for overloads (e.g. what code path is it taking for when you hover on the identifier?). Then, when the quick info target is a NewKeyword, find a way to dispatch the same logic.

@rpgeeganage
Copy link
Contributor

@DanielRosenwasser ,
Thanks a lot. I'll look into it.

@rpgeeganage
Copy link
Contributor

@sandersn ,
Can you please give me a small help on this please?
I have to debug till this line.
My test case:

////class Cat {
////  /**
////   * NOTE: this constructor is private! Please use the factory function
////   */
////  private constructor() { }
////
////  static makeCat() { new Cat(); }
////}

////ne/*1*/w C/*2*/at();

goTo.marker('2');
debug.printCurrentQuickInfo();
debug.printErrorList();

goTo.marker('1');
debug.printCurrentQuickInfo();
debug.printErrorList();

for the marker 2,
expression in below line evaluate as false
https://github.com/Microsoft/TypeScript/blob/master/src/services/services.ts#L1472
so,
symbol value is not null, so it goes to the following function.
https://github.com/Microsoft/TypeScript/blob/master/src/services/services.ts#L1484

const { symbolKind, displayParts, documentation, tags } = typeChecker.runWithCancellationToken(cancellationToken, typeChecker =>
  SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, getContainerNode(node), node)
);

but for the marker 1, symbol is undefined so, it doesn't go through the above function.
as a result, documentation is not properly generated.

@rpgeeganage
Copy link
Contributor

@RyanCavanaugh,
Will you be able to help me regarding this ticket, please?
Thanks.

@rpgeeganage
Copy link
Contributor

I have opened a PR (#31262).
Please review and give me feedback. Thanks a lot.

@DanielRosenwasser
Copy link
Member Author

Thanks @rpgeeganage!

@DanielRosenwasser DanielRosenwasser added the Fixed A PR has been merged for this issue label May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Domain: Quick Info e.g. hover text, tool-tips, and tooltips. Experience Enhancement Noncontroversial enhancements Fixed A PR has been merged for this issue Good First Issue Well scoped, documented and has the green light Help Wanted You can do this
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants