forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move] Provide code completion via language server
Implement a completion provider in the move-analyzer language server, so users of the Visual Studio Code extension see code completion suggestions as they type. This first iteration of completion in the language server is as simple as possible, and performs no semantic analysis. However, it must still lex the source program. That is because, as soon as move-analyzer informs VS Code that it provides completions, VS Code stops its internal completion engine entirely. Originally, the intent of this change to move-analyzer was to *supplement* VS Code's completion items (for example, if you typed `foo` anywhere in the source file, VS Code would surface `foo` as a completion item everywhere else) with Move's keywords and built-in operators. Since there is no easy way to add to VS Code's simple textual completion engine, this commit implements such an engine on its own, and adds to that the Move keywords and operators. Doing so resulted in several decisions and future work items: * Users spend most of their time editing source code that is not saved to disk. They only save that code to disk at certain times, such as when they feel it is worth saving. To provide completions, move-analyzer cannot just rely on what's on disk, and so must receive notifications from the language server client as to what source buffers the user is editing. (This could be improved by processing incremental updates from the client.) * Language servers can define "trigger characters" that prompt the client to present completions. For Move and many other languages, `.` and `::` make sense for these (for example, `foo.` and `foo::`). Move keywords (`if`, `fun`, etc.) and operators (`move` and `copy`) can't appear in these positions, so they are filtered out when the user's cursor appears in these positions. (This could be improved by performing semantic analysis and filtering completion items based on whether the cursor is within a `address`, `module`, or `fun` block, based on what identifiers are in scope, etc.) * Currently, the source file being edited is lexed whenever completions are requested for that file. Instead, move-analyzer could maintain an ever-ready syntax tree view of the entire package being edited, that is updated as files are modified. When completions are suggested, they ought to be readily available based on this tree, instead of being computed reactively as requested. * I noticed that certain contextual keywords were not included in the regex-based TextMate grammar for Move, so I added them. (Once the language server begins relying on parsed, semantic analyzed views of Move programs, it can begin providing semantically-aware syntax highlighting that ensures these are not colored as keywords unless appropriate.) Closes: aptos-labs#9589
- Loading branch information
1 parent
20b2b8b
commit a5d1c18
Showing
120 changed files
with
2,857 additions
and
2,477 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
64 changes: 32 additions & 32 deletions
64
.../DPN/releases/artifacts/current/build/DiemCoreFramework/docs/AccountFreezing.md
Large diffs are not rendered by default.
Oops, something went wrong.
86 changes: 43 additions & 43 deletions
86
...rk/DPN/releases/artifacts/current/build/DiemCoreFramework/docs/AccountLimits.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.