Skip to content

feat: Improve hover text for common kinds of symbols #94

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 2 commits into from
Apr 28, 2022

Conversation

varungandhi-src
Copy link
Contributor

Fixes #53. This is a very simplified version of the logic present in the TypeScript codebase.

Enum members do not work currently because of #93. I'll fix that first.

Test plan

Did some manual testing. Here's a truncated LSIF diff for lsif-node:

--- dump-before.lsif	2022-04-27 16:10:17.000000000 -0700
+++ dump-after.lsif	2022-04-27 16:59:10.000000000 -0700
@@ -5 +5 @@
-{"id":5,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\nWriter\n```\n\n---\n\n"}}}
+{"id":5,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\ninterface Writer\n```\n\n---\n\n"}}}
@@ -16 +16 @@
-{"id":16,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(...data: string[]) => void\n```\n\n---\n\n"}}}
+{"id":16,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(method) writeln(...data: string[]) => void\n```\n\n---\n\n"}}}
@@ -26 +26 @@
-{"id":26,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\nstring[]\n```\n\n---\n\n"}}}
+{"id":26,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(parameter) data: string[]\n```\n\n---\n\n"}}}
@@ -36 +36 @@
-{"id":36,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\nFileWriter\n```\n\n---\n\n"}}}
+{"id":36,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\nclass FileWriter\n```\n\n---\n\n"}}}
@@ -46 +46 @@
-{"id":46,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\nnumber\n```\n\n---\n\n"}}}
+{"id":46,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(property) fd: number\n```\n\n---\n\n"}}}
@@ -56 +56 @@
-{"id":56,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(...data: string[]) => void\n```\n\n---\n\n"}}}
+{"id":56,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(method) writeln(...data: string[]) => void\n```\n\n---\n\n"}}}
@@ -66 +66 @@
-{"id":66,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\nstring[]\n```\n\n---\n\n"}}}
+{"id":66,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(parameter) data: string[]\n```\n\n---\n\n"}}}
@@ -76 +76 @@
-{"id":76,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(buffer: Buffer) => void\n```\n\n---\n\n"}}}
+{"id":76,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(method) writeBuffer(buffer: Buffer) => void\n```\n\n---\n\n"}}}
@@ -86 +86 @@
-{"id":86,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\nBuffer\n```\n\n---\n\n"}}}
+{"id":86,"type":"vertex","label":"hoverResult","result":{"contents":{"kind":"markdown","value":"```ts\n(parameter) buffer: Buffer\n```\n\n---\n\n"}}}
@@ -96 +96 @@

I will add automated tests once TJ has ported the hover testing code to TypeScript.

Copy link
Member

@olafurpg olafurpg left a comment

Choose a reason for hiding this comment

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

LGTM 👍 This is already a big upgrade. I think it would be nice to have a special case for function so that we use : instead of => but we can fix that in a separate PR as well.

@varungandhi-src varungandhi-src marked this pull request as ready for review April 28, 2022 16:51
return this._length
// ^^^^^^^ reference syntax 1.0.0 src/`accessors.ts`/C#_length.
}
set length(value: number) {
// ^^^^^^ definition syntax 1.0.0 src/`accessors.ts`/C#`<get>length`().
// documentation ```ts\nnumber\n```
// documentation ```ts\nget length: number\n```
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is incorrect.

Copy link
Contributor Author

@varungandhi-src varungandhi-src Apr 28, 2022

Choose a reason for hiding this comment

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

Hmm, there seems to be something consistently wrong with how we're handling accessors. Notice the

definition syntax 1.0.0 src/`accessors.ts`/C#`<get>length`().

right above this, it should be <set> and not <get>. I'll fix the accessors in a separate PR.

@varungandhi-src varungandhi-src merged commit 860ea23 into main Apr 28, 2022
@varungandhi-src varungandhi-src deleted the vg/better-hovers branch April 28, 2022 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update pretty-printing of signatures in hover messages to mimic the formatting in hovers from the TypeScript language server
2 participants