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 partial completion and rename functionality in LSP/VSCode #1143

Merged
merged 12 commits into from
Sep 19, 2023

Conversation

thpani
Copy link
Contributor

@thpani thpani commented Sep 5, 2023

Output of my 🥧 week:

Add partial support for the completion and rename LSP endpoints in the VSCode plugin.

The logic for completion is a bit funky, because in most cases, when the endpoint is called, we don't have parsable source code. Hopefully we can alleviate this in the future by having an incremental parser.

The other thing I noted was that analysis as currently delayed by some timeout after parsing. While this works for hovering, it gives me mismatching IDs in the parser result and the analysis output when completion is called.
Thus, I'm currently calling analysis synchronously in completeIdentifier – I'm sure you have suggestions how to improve this :)

  • Tests added for any new code
  • Documentation added for any new functionality
  • Entries added to the respective CHANGELOG.md for any new functionality
  • Feature table on README.md updated for any listed functionality

@thpani thpani added vscode VScode plugin usability Usability issues labels Sep 5, 2023
@thpani thpani requested review from konnov and bugarela September 5, 2023 09:00
@thpani thpani self-assigned this Sep 5, 2023
@thpani thpani force-pushed the th/vsc-complete branch 2 times, most recently from db2498a to 77462be Compare September 5, 2023 09:10
Copy link
Collaborator

@bugarela bugarela left a comment

Choose a reason for hiding this comment

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

This is a lot of work! Congrats on finding a way to make this work in our current setting 😅. I'm now even more motivated to get incremental parsing in place.

quint/src/ir/IRFinder.ts Outdated Show resolved Hide resolved
vscode/quint-vscode/server/src/server.ts Outdated Show resolved Hide resolved
vscode/quint-vscode/server/src/complete.ts Outdated Show resolved Hide resolved
vscode/quint-vscode/server/src/complete.ts Outdated Show resolved Hide resolved
vscode/quint-vscode/server/src/complete.ts Show resolved Hide resolved
vscode/quint-vscode/server/src/complete.ts Show resolved Hide resolved
quint/src/index.ts Outdated Show resolved Hide resolved
const declIds = findDeclByNameAtPos(identifier, position, sourceFile, parsedData)

// FIXME: use analysisOutputByDocument
const [_, aop] = analyzeModules(table, modules)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have you tried using analysisOutputByDocument? I'm not sure exactly what the consequences of the delay might be, but we might be fine with it.

We might also be fine with running the analysis when users type .. The reason for the delay is that we can't run it every time a user types anything, since that becomes laggy pretty quickly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We could try to trigger the async job here and avoid running it twice, but I'm not sure it's worth the trouble. The real improvement will be with incremental parsing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have you tried using analysisOutputByDocument? I'm not sure exactly what the consequences of the delay might be, but we might be fine with it.

Yeah, I tried that, but in 99% of cases the analysis output and the parsed data are out of sync by then (i.e., using disjoint sets of IDs).

I guess the delay is fine for hover, because an analysis will be triggered until you move your mouse, but for triggering completion, the LSP request wins the race against the timeout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe we should make analysisOutputByDocument a Promise? Then I could wait for that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we should make analysisOutputByDocument a Promise? Then I could wait for that.

I'm not sure if that's a good idea because everything else is fine with outdated information - it's better to show the latest information than make the user wait, I think.

Perhaps we could have another version of analysisOutputByDocument that is a promise and use it only for this scenario.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to combine this with a promise, but I couldn't find a way to use the same analysis action both with a timeout and as a promise.

I'm off next week, maybe you have an idea here, otherwise I'll take another stab at it when I'm back!

Copy link
Collaborator

Choose a reason for hiding this comment

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

I gave this a shot and I think I got something pretty OK, please take a look and see if you agree: ea330e0

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 looks great! Thanks for taking a shot at it! 🙏

@thpani thpani merged commit 5f801dd into main Sep 19, 2023
15 checks passed
@thpani thpani deleted the th/vsc-complete branch September 19, 2023 09:08
@bugarela bugarela mentioned this pull request Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
usability Usability issues vscode VScode plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants