Commit Graph

242 Commits

Author SHA1 Message Date
Ryo Yoshida
e6e48728da
Add tests for stability check in completion 2023-04-11 21:21:15 +09:00
Ryo Yoshida
0ce71dd76f
completion: check stability 2023-04-11 21:21:13 +09:00
bors
265f83031f Auto merge of #14433 - hecatia-elegua:alias-based-completion, r=Veykril
Add doc-alias based completion

Closes #14406.

I adapted the parsing code from the CfgExpr parsing code, maybe there's a better abstraction for both, or attribute parsing in general. It also includes `doc(hidden)`-parsing, which means it could replace the other function.
There are a few tests for parsing.

`process_all_names` changed the most, I added some docs there to explain what happens.

Many call sites just pass an empy vec to `add_path_resolution`'s `doc_aliases`, since either it doesn't make sense to pass anything (e.g. visibility completion) or I don't know where to get them from. Shouldn't really matter, as it will just not show aliases if the vec is empty and we can extend alias completion in these cases later.

I added two tests in `special.rs` for struct name completion (which was the main thing I wanted). I also tried function and field names, but these don't work yet. I want to add those in a follow-up PR.
2023-04-05 13:44:51 +00:00
hecatia-elegua
c469936aac Address review comments part 1 2023-03-30 17:35:57 +02:00
Lukas Wirth
e244942209 internal: Set Durability to HIGH for enable_proc_attr_macros input 2023-03-30 15:11:22 +02:00
hecatia-elegua
ba2b48d1b8 Fix3 2023-03-29 14:58:33 +02:00
hecatia-elegua
53afac72d2 Fix2 2023-03-29 14:34:06 +02:00
hecatia-elegua
0863389dd1 Add doc-alias based completion 2023-03-29 14:08:25 +02:00
bors
7c05f55f0c Auto merge of #13789 - feniljain:fix_enum_completion, r=Veykril
feat: show only missing variant suggestion for enums in patterns completion and bump them in list too

Fixes #12438

### Points to help in review:

- This PR can be reviewed commit wise, first commit is about bumping enum variant completions up in the list of completions and second commit is about only showing enum variants which are not complete
- I am calculating missing variants in analysis.rs by firstly locating the enum and then comparing each of it's variant's name and checking if arm string already contains that name, this is kinda hacky but I didn't want to implement complete missing_arms assist here as that would have been too bulky to run on each completion cycle ( if we can improve this somehow would appreciate some inputs on it )

### Output:

https://user-images.githubusercontent.com/49019259/208245540-57d7321b-b275-477e-bef0-b3a1ff8b7040.mov

Relevant Zulip Discussion: https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/Issue.20.2312438
2023-03-18 07:06:27 +00:00
feniljain
a79a76a942 refactor: pass is_variant_missing as args to build_completion 2023-03-18 11:46:22 +05:30
feniljain
f7113685b5 fix: make tests valid rust code 2023-03-18 11:43:45 +05:30
feniljain
6778d1a6eb feat: do not remove other variants, just push them down in list 2023-03-16 22:54:12 +05:30
bors
e611fbe6ab Auto merge of #14355 - Veykril:completion-ref-strip, r=Veykril
fix: Fix reference completions being emitted in places other than argument lists

Fixes https://github.com/rust-lang/rust-analyzer/issues/14331
2023-03-15 09:47:20 +00:00
Lukas Wirth
82ed68c95e fix: Fix reference completions being emitted in places other than argument lists 2023-03-15 10:41:17 +01:00
feniljain
d03c789798 chore: change casing for variants in tests 2023-03-15 10:11:43 +05:30
Lukas Wirth
2c364f6e5a Fix tests 2023-03-14 19:55:20 +01:00
feniljain
a10372dac6 fix: use compute_type_match correctly and update tests accordingly 2023-03-14 11:41:25 +05:30
bors
544b4cfe4d Auto merge of #109069 - lnicola:rust-analyzer-2023-03-13, r=lnicola
⬆️ `rust-analyzer`

r? `@ghost`
2023-03-13 16:54:43 +00:00
Laurențiu Nicola
b2f6fd4f96 ⬆️ rust-analyzer 2023-03-13 10:42:24 +02:00
clubby789
c6da2f9d96 Remove uses of box_syntax in rustc and tools 2023-03-12 13:19:46 +00:00
Laurențiu Nicola
7e711da2f0 ⬆️ rust-analyzer 2023-02-20 10:14:12 +02:00
Laurențiu Nicola
bc45c7659a ⬆️ rust-analyzer 2023-02-13 13:55:14 +02:00
arcnmx
25242fe93f ⬆️ rust-analyzer
Merge commit '368e0bb32f1178cf162c2ce5f7e10b7ae211eb26'
2023-01-09 10:36:22 -08:00
feniljain
794988c53b feat: filter already present enum variants in match arms 2022-12-17 19:21:21 +05:30
feniljain
68fd1ce313 feat: bump variant suggestion for enums in patterns completion 2022-12-17 19:21:21 +05:30
bors
15ff8a5a9f Auto merge of #13715 - feniljain:fix_completions, r=jonas-schievink
fix: breaking snippets on typed incomplete suggestions

Possible fix for #7929

Fix the case where if a user types `&&42.o`, snippet completion was still applying &&Ok(42). Note this was fixed previously on `&&42.` but this still remained a problem for this case

Previous relevant PR: #13517

### Points to help in review:

- The main problem why everything broke on adding an extra `o` was, earlier `dot_receiver` was `42.` which was a `LITERAL` but now `42.o` becomes a `FIELD_EXPR`

- Till now `include_references` was just checking for parent of `LITERAL` and if it was a `REF_EXPR`, but now we consider `FIELD_EXPR` and traverse all of them, finally to reach `REF_EXPR`. If `REF_EXPR` is not found we  just return the original `initial_element`

- We are constructing a new node during `include_references` because if we rely on `dot_receiver` solely we would get `&&42.o` to be replaced with, but we want `&&42` to be replaced with

### Output Video:

https://user-images.githubusercontent.com/49019259/205420166-efbdef78-5b3a-4aef-ab4b-d892dac056a0.mov

Hope everything I wrote makes sense 😅

Also interestingly previous PR's number was `13517` and this PR's number is `13715`, nicee
2022-12-12 14:37:45 +00:00
feniljain
ec268c0d6c fix: breaking snippets on typed incomplete suggestions
Fix the case where if a user types `&&42.o`, snippet completion
was still applying &&Ok(42). Note this was fixed previously
on `&&42.` but this still remained a problem for this case
2022-12-03 08:43:13 +05:30
bors
34e2bc6a54 Auto merge of #13611 - yue4u:fix/completion-after-colon, r=yue4u
fix: filter unnecessary completions after colon

close #13597
related: #10173

This PR also happens to fix two extra issues:

1. The test case in https://github.com/rust-lang/rust-analyzer/blob/master/crates/ide-completion/src/tests/attribute.rs#L778-L801 was never triggered in previous behavior.

after:

https://user-images.githubusercontent.com/26110087/201476995-56adf955-0fa7-4f75-ab32-28a8e6cb9504.mp4

<del>
2. completions were triggered even in invalid paths, like

```rust
fn main() {
    core:::::$0
}
```

```rust
#[:::::$0]
struct X;
```

</del>

only `:::` is excluded as discussed in https://github.com/rust-lang/rust-analyzer/pull/13611#discussion_r1031845205
2022-11-26 17:55:00 +00:00
yue4u
1ca5cb7ed9 fix: also exclude 2 coloncolon in a row 2022-11-27 02:39:38 +09:00
yue4u
e1de04d60c fix: only special casing 3 colon in a row 2022-11-27 01:53:45 +09:00
Laurențiu Nicola
a2a1d99545 ⬆️ rust-analyzer 2022-11-23 17:24:03 +02:00
yue4u
7a568f7f95 fix: remove insufficient check for coloncolon 2022-11-20 01:29:02 +09:00
yue
a6d0e342a3
Update crates/ide-completion/src/context.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-11-20 00:58:59 +09:00
Jonas Schievink
7e77d4e310 Strip comments and attributes off of all trait item completions 2022-11-15 12:41:39 +01:00
Jonas Schievink
15dfeabb96 Fix GAT completion not including generic parameters 2022-11-15 12:05:11 +01:00
yue4u
f26d5484d8 fix: filter unnecessary completions after colon 2022-11-12 22:33:40 +09:00
Laurențiu Nicola
79923c382a ⬆️ rust-analyzer 2022-11-09 21:49:10 +02:00
Lukas Wirth
90e2db8126 fix: Fix item completions not working properly after unit structs and outline modules 2022-11-08 08:37:45 +01:00
Lukas Wirth
ffd7bf8bf9 Bump Cargo rust-version fields to latest stable 2022-11-07 12:59:51 +01:00
feniljain
98125b9f95 fix: make custom expr prefix completions to understand refs 2022-10-30 15:02:17 +05:30
Laurențiu Nicola
a99a48e786 ⬆️ rust-analyzer 2022-10-18 09:12:49 +03:00
bors
855cd5c280 Auto merge of #13418 - lnicola:bump-deps, r=lnicola
Bump deps
2022-10-15 11:27:12 +00:00
Laurențiu Nicola
50f990c46f Bump smallvec 2022-10-15 12:52:34 +03:00
Laurențiu Nicola
cbce0cda08 Bump anyhow, arbitrary, itertools, semver, serde 2022-10-15 12:52:34 +03:00
bors
a0ab61fb6c Auto merge of #13358 - btwotwo:feature/env-vars-autocompletion, r=Veykril
feat: Autocomplete Cargo-defined env vars in `env!` and `option_env!` (#12448)

Closes #12448

Important to know:

- Variables are taken from https://doc.rust-lang.org/cargo/reference/environment-variables.html and hardcoded as a const array.
- For the sake of simplicity I didn't include the autocompletion of `CARGO_BIN_EXE_<name>` and `OUT_DIR` since it would require information about build.rs and binary name. If somebody knows an easy way of obtaining them I can add those vars as well :)
2022-10-11 18:45:31 +00:00
btwotwo
2b2b9f8c73
Formatting 2022-10-11 19:53:22 +02:00
btwotwo
b5e87ac111
Fix formatting for cargo vars list 2022-10-11 19:29:09 +02:00
btwotwo
a807cc3afb
Rename get_outer_macro to macro_call_for_string_token 2022-10-11 19:28:42 +02:00
btwotwo
3c39668ca4
Remove extra parameter, access Db through semantics 2022-10-11 19:23:41 +02:00
Laurențiu Nicola
4f55ebbd4f ⬆️ rust-analyzer 2022-10-11 10:37:35 +03:00