Skip to content

feat(lsp): support for completions#306

Merged
baszalmstra merged 1 commit intomun-lang:masterfrom
baszalmstra:feature/completion
Apr 10, 2021
Merged

feat(lsp): support for completions#306
baszalmstra merged 1 commit intomun-lang:masterfrom
baszalmstra:feature/completion

Conversation

@baszalmstra
Copy link
Collaborator

Adds initial support for completions for IDEs. This is far from finished, there is a lot more to add but I didn't want to make this too big. Currently supports two types of completion:

  • Completion of names in scope
  • Completion of struct fields

I used the same design as Rust Analyzer.

image

This PR depends on #298

@baszalmstra baszalmstra added the type: feat New feature or request label Jan 30, 2021
@baszalmstra baszalmstra requested a review from Wodann January 30, 2021 15:02
@baszalmstra baszalmstra self-assigned this Jan 30, 2021
@codecov
Copy link

codecov bot commented Jan 30, 2021

Codecov Report

Merging #306 (b1f50b2) into master (09ded01) will decrease coverage by 0.06%.
The diff coverage is 73.85%.

❗ Current head b1f50b2 differs from pull request most recent head 012fa9e. Consider uploading reports for the commit 012fa9e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
- Coverage   80.86%   80.80%   -0.07%     
==========================================
  Files         245      258      +13     
  Lines       14937    15480     +543     
==========================================
+ Hits        12079    12508     +429     
- Misses       2858     2972     +114     
Impacted Files Coverage Δ
crates/mun_hir/src/code_model.rs 11.11% <0.00%> (ø)
crates/mun_hir/src/code_model/src.rs 43.33% <ø> (ø)
crates/mun_hir/src/item_scope.rs 49.36% <ø> (ø)
crates/mun_language_server/src/analysis.rs 82.60% <0.00%> (-17.40%) ⬇️
crates/mun_language_server/src/capabilities.rs 0.00% <0.00%> (ø)
crates/mun_language_server/src/from_lsp.rs 76.19% <0.00%> (-23.81%) ⬇️
crates/mun_language_server/src/handlers.rs 75.60% <0.00%> (-24.40%) ⬇️
crates/mun_language_server/src/lib.rs 11.11% <ø> (ø)
crates/mun_language_server/src/to_lsp.rs 37.50% <0.00%> (-26.14%) ⬇️
crates/mun_language_server/src/completion/item.rs 67.74% <67.74%> (ø)
... and 47 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09ded01...012fa9e. Read the comment docs.

@baszalmstra baszalmstra force-pushed the feature/completion branch 2 times, most recently from 2f7cbb0 to 90f1a79 Compare February 28, 2021 19:39
Copy link
Collaborator

@Wodann Wodann left a comment

Choose a reason for hiding this comment

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

Generally looks good. It's a lot of complex code though, so I didn't comprehend it all. I noticed that quite a lot of code was untested. As this is (seemingly) complex code, it'd be good to add a broader suite of tests (as we keep expanding on our LSP.

// context. The actual original_file will be used for completion.
let file_with_fake_ident = {
let parse = db.parse(position.file_id);
let edit = Indel::insert(position.offset, String::from("intellijRulezz"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Mun Rulezz!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

"intellijRulezz" is a standard string used for this purpose

@baszalmstra baszalmstra added this to the Mun v0.3.0 milestone Apr 10, 2021
@Wodann Wodann changed the title feature(lsp): support for completions feat(lsp): support for completions Apr 10, 2021
@baszalmstra baszalmstra force-pushed the feature/completion branch 2 times, most recently from 8993d02 to b1f50b2 Compare April 10, 2021 15:16
@baszalmstra baszalmstra merged commit aece59e into mun-lang:master Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: feat New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants