Skip to content

Conversation

@mjbvz
Copy link
Collaborator

@mjbvz mjbvz commented Jan 6, 2017

Fixes #18054

Adds an initial references code lens provider implementation for JS and TS

screen shot 2017-01-05 at 6 22 28 pm

Remaining work and issues:

We also need to investigate the perf impact of the code lens further. It will be opt in to start with

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jrieken What is the proper way to reject code lenses if resolving them fails? I tried using Promise.reject, but that leaves a bunch of ugly blank lines in the document:

screen shot 2017-01-05 at 7 17 23 pm

Copy link
Member

@jrieken jrieken Jan 6, 2017

Choose a reason for hiding this comment

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

I am afraid you cannot. The idea is that the editor does shake while we resolve things, e.g in the first, hopefully quick, phase we create all the empty space which make the editor 'jump' and then in the second phase we fill in those holes. Two options

  • know in the first phase which lenses you cannot fill in (this the very much preferred solution), or
  • use the new API of being able to tell the editor your set of lenses has changed. Will cause jumping/flicker and still requires you know valid lenses in the first phase

So, actually you only have one option ;-) and that is to only advertise lenses where you are sure you can fill them in

@mjbvz
Copy link
Collaborator Author

mjbvz commented Jan 6, 2017

I added a workaround for the TS issue. We still want the fix from TS (the same bug also impacts the find all references command) but this should unblock shipping a preview.

This feature is actually pretty neat:

screen shot 2017-01-06 at 11 52 17 am

Fixes microsoft#18054

Adds an references code lens provide for JS and TS
@dbaeumer
Copy link
Member

dbaeumer commented Jan 9, 2017

Very nice. One additional idea is to resolve the code lens even if it fails with a string like 'No references found' or 'Reference resolving failed' if it doesn't happen too often.

@mjbvz
Copy link
Collaborator Author

mjbvz commented Jan 9, 2017

@dbaeumer Thanks.

There are a few cases where TS has an internal error when attempting to determine the references (such as for public constructor). In that case, we use the messageCould not determine references. I've opened a bug on TS for this: microsoft/TypeScript#13330

@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
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.

Reference Code Lens for TypeScript

4 participants