-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Leverage function contract information (#1888)
When a function is annotated with a function contract, use this additional type information to enable completion in the LSP (and also use the domain as the type of the function's argument in the typing environment, even if we are in walk mode). Contract data are easy to fetch during typechecking when available and use them improve the developer experience by bringing in more static information.
- Loading branch information
Showing
4 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
lsp/nls/tests/inputs/completion-fun-parameter-contract.ncl
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
### /file.ncl | ||
{ | ||
Schema = { | ||
foo | { bar }, | ||
baz, | ||
}, | ||
some_func | ||
| Schema -> Dyn | ||
= fun src => | ||
{ | ||
some_val = src.foo, | ||
}, | ||
} | ||
### [[request]] | ||
### type = "Completion" | ||
### textDocument.uri = "file:///file.ncl" | ||
### position = { line = 9, character = 23 } | ||
### context = { triggerKind = 2, triggerCharacter = "." } |
5 changes: 5 additions & 0 deletions
5
...tests/snapshots/main__lsp__nls__tests__inputs__completion-fun-parameter-contract.ncl.snap
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
source: lsp/nls/tests/main.rs | ||
expression: output | ||
--- | ||
[baz, foo] |