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

feat(vscode): symbol and property completions #1753

Merged
merged 27 commits into from Mar 10, 2023
Merged

Conversation

MarkMcCulloh
Copy link
Contributor

@MarkMcCulloh MarkMcCulloh commented Mar 8, 2023

Misc

Parser Changes

  • More surgical usage of tree-sitter errors. We no longer throw away entire expressions just because they contain an error
    • This often replaces Unknown parser error with something more useful

Grammar changes

  • Formated grammar.js
  • The "property" part of nested identifiers is now optional (!)
    • Note, the rust parser will still fail on this. This change was made to improve the error recovery of incomplete references. We can provide a better error message than tree-sitter can. Plus, the lsp handles this better
    • Better error handling for this would require us to write our own additional tree-sitter scanner in C, which I decided to not do (cause I don't wanna)

Misc compiler change

  • Made parent on SymbolEnv public
    • the usual "with_ancestry" was not good enough on iter() and it didn't seem valuable to change or make new iterators

Extension changes

  • Forced the wordPattern languageConfiguration to be set for Wing in vscode, this ensures autocomplete gets triggered when typing words (without having to use a trigger character)

Corpus changes

  • Due to grammar/parser changes, updated invalid examples with more focused errors

LSP changes

  • When compiling for the LSP, disabled capture visiting. It seems very fragile with incomplete code so it needs to be revisited.

Main Event

Completion Support for Symbols/Properties

autocomplete.mp4

What's missing?

Lots of stuff! but I'm tired of working on this now so...

  • Can't handle incomplete nested expressions, only nested identifiers
    • This is most notable for calls like a.b().
    • (sidenote) resolve_reference() really needs to be exposed outside of TypeChecker
  • props/methods of generic classes/builtins are not reified (shows T1)
  • Many details of various types completion types are missing
  • No ordering on the locality of suggestions

@MarkMcCulloh MarkMcCulloh requested a review from a team as a code owner March 8, 2023 19:30
Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Can't wait for this to ship!

libs/wingc/src/ast.rs Show resolved Hide resolved
libs/wingc/src/parser.rs Show resolved Hide resolved
libs/wingc/src/parser.rs Show resolved Hide resolved
libs/wingc/src/lsp/completions.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@yoav-steinberg yoav-steinberg left a comment

Choose a reason for hiding this comment

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

✨ amazing work.
Didn't go deeply into the lsp code cause it's a lot and I'm not too familiar with it.
I added lots of tiny nitpicks but some might be important so I'm not approving yet.

examples/tests/invalid/optional_invoke.w Outdated Show resolved Hide resolved
examples/tests/invalid/optionals.w Outdated Show resolved Hide resolved
libs/wingc/src/ast.rs Outdated Show resolved Hide resolved
libs/wingc/src/lsp/completions.rs Show resolved Hide resolved
libs/wingc/src/lsp/completions.rs Show resolved Hide resolved
libs/wingc/src/lsp/completions.rs Outdated Show resolved Hide resolved
libs/wingc/src/parser.rs Show resolved Hide resolved
tools/hangar/src/__snapshots__/invalid.test.ts.snap Outdated Show resolved Hide resolved
tools/hangar/src/__snapshots__/invalid.test.ts.snap Outdated Show resolved Hide resolved
Copy link
Contributor

@Chriscbr Chriscbr left a comment

Choose a reason for hiding this comment

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

Really looking forward to shipping this. I added some more feedback, the main one is about tests.

I also think it could be really helpful to create a tracking issue for the known gaps in the different LSP features so that we can try and identify what parts of the LSP / extension our contributors can help with, which could be good first issues, etc.

libs/tree-sitter-wing/grammar.js Show resolved Hide resolved
libs/wingc/src/lsp/completions.rs Show resolved Hide resolved
libs/wingc/src/lsp/completions.rs Show resolved Hide resolved
libs/wingc/src/lsp/completions.rs Show resolved Hide resolved
@mergify
Copy link
Contributor

mergify bot commented Mar 10, 2023

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit e94bcac into main Mar 10, 2023
@mergify mergify bot deleted the mark/dot-completion branch March 10, 2023 19:39
@monadabot
Copy link
Contributor

Congrats! 🚀 This was released in Wing 0.5.114.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants