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

feat(language-service): Append symbol type to hover tooltip #34515

Closed
wants to merge 1 commit into from

Conversation

@kyliau
Copy link
Member

kyliau commented Dec 20, 2019

Now that #34177 fixed the TypeWrapper
to have a proper name, we have the information needed to show the type
name in a hover tooltip.

Screen Shot 2019-12-20 at 10 32 22 AM

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@kyliau kyliau requested a review from angular/tools-language-service as a code owner Dec 20, 2019
@ngbot ngbot bot added this to the needsTriage milestone Dec 20, 2019
@googlebot googlebot added the cla: yes label Dec 20, 2019
Now that #34177 fixed the `TypeWrapper`
to have a proper name, we have the information needed to show the type
name in a hover tooltip.
@kyliau kyliau force-pushed the kyliau:docs-for-types branch from d7b185f to 5802d26 Dec 20, 2019
@kyliau kyliau requested a review from angular/fw-integration as a code owner Dec 20, 2019
@@ -113,7 +113,7 @@ describe('hover', () => {
expect(quickInfo).toBeTruthy();
const {textSpan, displayParts} = quickInfo !;
expect(textSpan).toEqual(marker);
expect(toText(displayParts)).toBe('(directive) StringModel');
expect(toText(displayParts)).toBe('(directive) StringModel: typeof StringModel');

This comment has been minimized.

Copy link
@ayazhafiz

ayazhafiz Dec 20, 2019

Member

hm.. this seems a bit unexpected, no? This suggests StringModel's type is registered as the typeof the value and not the StringModel class. Do you know why they would be different?

This comment has been minimized.

Copy link
@kyliau

kyliau Dec 20, 2019

Author Member

This surprised me too when I first saw it.
It is actually correct, because here we are pointing to the class itself (specifically, the constructor function), and not to an instance of the class.
This section in the TypeScript handbook does a pretty good job on explaining the difference between the two.

This comment has been minimized.

Copy link
@ayazhafiz

ayazhafiz Dec 20, 2019

Member

I see. I guess my confusion was because classes create both a type and a value, so yes here we do expect to get the type of the class value rather than the type of the class instance, as you mention.

@@ -113,7 +113,7 @@ describe('hover', () => {
expect(quickInfo).toBeTruthy();
const {textSpan, displayParts} = quickInfo !;
expect(textSpan).toEqual(marker);
expect(toText(displayParts)).toBe('(directive) StringModel');
expect(toText(displayParts)).toBe('(directive) StringModel: typeof StringModel');

This comment has been minimized.

Copy link
@ayazhafiz

ayazhafiz Dec 20, 2019

Member

I see. I guess my confusion was because classes create both a type and a value, so yes here we do expect to get the type of the class value rather than the type of the class instance, as you mention.

@alxhub alxhub closed this in 9b9116c Dec 20, 2019
alxhub added a commit that referenced this pull request Dec 20, 2019
Now that #34177 fixed the `TypeWrapper`
to have a proper name, we have the information needed to show the type
name in a hover tooltip.

PR Close #34515
januwA added a commit to januwA/angular that referenced this pull request Jan 2, 2020
pull (#1)
* fix(language-service): completions after "let x of |" in ngFor (angular#34473)

This commit fixes a bug in which we do testing for completions.
Subsequently, this exposes another bug in our implementation whereby
suggestions are not provided in "ngFor" where there should have been.

Currently, multiple test cases are grouped together in a single
template. This requires the template to be somewhat complete so that
test cases that depend on variables declared earlier would pass.

Consider the following example:

```
  template: `
    <div *ngFor="let ~{for-person}person of ~{for-people}people">
      <span>Name: {{~{for-interp-person}person.~{for-interp-name}name}}</span>
      <span>Age: {{person.~{for-interp-age}age}}</span>
    </div>`,
```

In order to test `~{for-interp-person}`, `people` has to be included after
`~{for-people}`. This means the test case for `~{for-people}` is not
reflective of the actual use case because the variable is already there!
In real case, the expression would be incomplete, and our implementation
failed to take that into account.

This commit breaks such test into individual tests, and fix the bugs in
the underlying implementation.

PR Close angular#34473

* feat(language-service): Append symbol type to hover tooltip (angular#34515)

Now that angular#34177 fixed the `TypeWrapper`
to have a proper name, we have the information needed to show the type
name in a hover tooltip.

PR Close angular#34515

Co-authored-by: Keen Yee Liau <kyliau@google.com>
@angular-automatic-lock-bot

This comment has been minimized.

Copy link

angular-automatic-lock-bot bot commented Jan 20, 2020

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants
You can’t perform that action at this time.