ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.66k stars 750 forks source link

[Improvement]: Improve Language Server Completions with `completionItem/resolve` #41223

Open malinthar opened 1 year ago

malinthar commented 1 year ago

Description

LS auto completions takes a long time to respond when the project is relatively large and the compilation is fairly large. We can now use the CompletionItemResolve (https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItem_resolve) request to compute the text edit separately.

This is quite simillar to the codeActionResolve request implemented in the Ballerina Language Server. With this we can provide fast completions even if the project is quite large.

Describe your problem(s)

No response

Describe your solution(s)

No response

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

nipunayf commented 7 months ago

The response time for retrieving completion items is determined by the execution times of both APIs: didChange (which heavily includes updating the project) and completions APIs (which includes the computation of the completion items). After measuring the performance of retrieving the completions for the project https://github.com/ballerina-platform/module-ballerinax-health.fhir.r4, it was found that for a majority of the samples, the performance delay was bound by updating the project rather than the latter. However, for instances that include a high number of completion items, the completions API took a major fraction of the performance delay (around 80%). Ideally, it would be nice to have this feature to address such cases; however, for now, the issue is labeled to do later since the gain in performance does not outweigh the effort put in.