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

More completion for unsaved code. #712

Merged
merged 41 commits into from
Mar 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a0b4361
setup + minimum needed to understand aliases
zth Jan 24, 2023
0a1a7c7
add (mostly working) moving into function arguments
zth Jan 24, 2023
dc4b999
handle jsx context
zth Jan 24, 2023
709ab03
add broken example test
zth Jan 24, 2023
73cf40b
handle pipe chains as assigned value
zth Jan 25, 2023
83973e8
support leveraging type annotations when inferring
zth Jan 25, 2023
b80c5df
start work on following pattern path
zth Jan 25, 2023
c9d6bbc
slight cleanup
zth Jan 26, 2023
2e4747f
make Toption work with both extracted and type expr types
zth Feb 3, 2023
ecbb7b7
make Tarray work with both extracted and type expr types
zth Feb 3, 2023
8669c59
start working on moving through nested pattern paths
zth Feb 3, 2023
e1764e6
follow tuples
zth Feb 3, 2023
df5db9d
handle switches
zth Feb 3, 2023
1b1e21f
poc complete pattern of function parameter
zth Feb 3, 2023
071e4b4
follow variant payloads
zth Feb 3, 2023
407b53e
follow polyvariant payloads
zth Feb 3, 2023
8090975
follow options
zth Feb 3, 2023
ccd19b6
follow arrays
zth Feb 3, 2023
01873ff
add test
zth Feb 3, 2023
647513b
factor away lookingForPat
zth Feb 3, 2023
611a440
correct order
zth Feb 3, 2023
7e32420
fix
zth Feb 3, 2023
10530c5
fix cross file
zth Feb 3, 2023
13946e0
apply pipe transform to ctx path extraction so pipes can be tracked a…
zth Feb 5, 2023
109fc43
handle processing of functions and fn args
zth Feb 5, 2023
f2ad8ba
refactor to make less invasive
zth Feb 7, 2023
65166fc
fix after rebase
zth Feb 10, 2023
9630859
missed traversing switch expr when no cases
zth Feb 11, 2023
171d49e
illustrate new issue with pipe completion paths
zth Feb 11, 2023
4bb9b77
Completion debug
cristianoc Mar 7, 2023
27820c8
Emit completable where it is processed.
cristianoc Mar 7, 2023
d6aa0fd
Print ContextPath
cristianoc Mar 7, 2023
707ab5a
Print Path
cristianoc Mar 7, 2023
cd2ad40
example of when pipe completion across files doesnt work
zth Feb 11, 2023
08f002b
Add debug for pipe internals.
cristianoc Mar 8, 2023
d972afe
Print pathFromEnv and whether the path was found.
cristianoc Mar 8, 2023
2bf84ea
refactor
cristianoc Mar 8, 2023
ba861ce
Fix pipe completion across files.
cristianoc Mar 8, 2023
dafa03e
debug output
zth Mar 8, 2023
3c9193f
remove now irrelevant comments about issues
zth Mar 8, 2023
ed0cdee
changleog
zth Mar 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

## master

#### :rocket: New Feature

- Greatly extend completion abilities for unsaved code. WARNING: Might be a bit unstable initially. Report any issues you see. https://github.com/rescript-lang/rescript-vscode/pull/712

## 1.14.0

#### :rocket: New Feature
Expand Down
2 changes: 2 additions & 0 deletions analysis/src/Cfg.ml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
let supportsSnippets = ref false

let debugFollowCtxPath = ref false
28 changes: 6 additions & 22 deletions analysis/src/Commands.ml
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
let getCompletions ~debug ~path ~pos ~currentFile ~forHover =
let textOpt = Files.readFile currentFile in
match textOpt with
| None | Some "" -> []
| Some text -> (
let completion ~debug ~path ~pos ~currentFile =
let completions =
match
CompletionFrontEnd.completionWithParser ~debug ~path ~posCursor:pos
~currentFile ~text
Completions.getCompletions ~debug ~path ~pos ~currentFile ~forHover:false
with
| None -> []
| Some (completable, scope) -> (
if debug then
Printf.printf "Completable: %s\n"
(SharedTypes.Completable.toString completable);
(* Only perform expensive ast operations if there are completables *)
match Cmt.loadFullCmtFromPath ~path with
| None -> []
| Some full ->
let env = SharedTypes.QueryEnv.fromFile full.file in
completable
|> CompletionBackEnd.processCompletable ~debug ~full ~pos ~scope ~env
~forHover))

let completion ~debug ~path ~pos ~currentFile =
| Some (completions, _) -> completions
in
print_endline
(getCompletions ~debug ~path ~pos ~currentFile ~forHover:false
(completions
|> List.map CompletionBackEnd.completionToItem
|> List.map Protocol.stringifyCompletionItem
|> Protocol.array)
Expand Down
Loading