Commit Graph

219 Commits

Author SHA1 Message Date
unvalley
9eabc2cde8 fix: add_format_like_completions to handle no exprs 2023-01-09 12:23:59 +01:00
bors
f77b68a3cb Auto merge of #13860 - danieleades:clippy, r=lnicola
fix a bunch of clippy lints

fixes a bunch of clippy lints for fun and profit

i'm aware of this repo's position on clippy. The changes are split into separate commits so they can be reviewed separately
2023-01-08 17:29:57 +00:00
Brent Westbrook
150da92b5c return immediately from render_record_lit if snippet_cap is None
this is the record literal version of #13805, which handled the same issue for
tuple literals
2023-01-04 12:55:05 -05:00
Daniel Eades
efd2c20e96 remove useless conversions 2023-01-02 15:02:54 +00:00
Daniel Eades
cc80c5bd07 remove unnecessary lazy evaluations 2023-01-02 15:02:54 +00:00
Daniel Eades
ed128872eb remove needless borrows 2023-01-02 14:52:32 +00:00
Daniel Eades
77051679d7 use inline format args 2023-01-02 14:52:32 +00:00
Laurențiu Nicola
3aae785693 Avoid useless format 2022-12-30 16:10:07 +02:00
Yuri Astrakhan
e16c76e3c3 Inline all format arguments where possible
This makes code more readale and concise,
moving all format arguments like `format!("{}", foo)`
into the more compact `format!("{foo}")` form.

The change was automatically created with, so there are far less change
of an accidental typo.

```
cargo clippy --fix -- -A clippy::all -W clippy::uninlined_format_args
```
2022-12-24 14:36:10 -05:00
bors
fb0db2a420 Auto merge of #13831 - bvanjoi:fix_bound_type_in_trait_insert, r=Veykril
fix(completion): remove bound insert of type in trait

Fixed https://github.com/rust-lang/rust-analyzer/issues/13819
2022-12-23 12:27:44 +00:00
bvanjoi
67cbd8f7c1 fix(completion): remove bound insert of type in trait 2022-12-23 18:45:25 +08:00
Yuri Astrakhan
1d59c7b667 Remove non-needed clones
I am not certain if this will improve performance,
but it seems having a .clone() without any need should be removed.

This was done with clippy, and manually reviewed:

```
cargo clippy --fix -- -A clippy::all -D clippy::redundant_clone
```
2022-12-23 02:20:03 -05:00
Brent Westbrook
694ae77bf6 pass snippet_cap to format_literal_label, return early if None 2022-12-20 11:27:19 -05:00
Brent Westbrook
1116cc93ec return immediately from render_tuple_lit if snippet_cap is None
partially addresses #13767
2022-12-20 11:07:37 -05:00
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
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
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
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
bors
d23537394e Auto merge of #13386 - Veykril:completions-ref, r=Veykril
Refactor completions expansion

Depends on https://github.com/rust-lang/rust-analyzer/pull/13384
Diff is unfortunately massive as I changed the functions in the analysis module from associated ones to standalone (unfortunately without an extra commit)
2022-10-10 14:05:38 +00:00
Lukas Wirth
f3ae5e56fb Refactor completions expansion 2022-10-10 15:45:24 +02:00
Lukas Wirth
63ed71bd30 Honor cfg attributes on params when lowering their patterns 2022-10-10 09:47:09 +02:00
Laurențiu Nicola
df7d39b2ed Bump once_cell 2022-10-08 21:25:11 +03:00
btwotwo
3732d159b2
Pass context to env vars completion 2022-10-06 21:35:12 +02:00
btwotwo
e2d3c1506f
Restrict auto-completion for only built-in macros 2022-10-06 21:35:01 +02:00
btwotwo
8a92910f97
Formatting 2022-10-06 16:53:17 +02:00
btwotwo
c660a5ce34
Remove unnecessary dereference 2022-10-06 16:42:31 +02:00
btwotwo
55c5014b76
Replace if with option, add detail for each env variable completion 2022-10-06 16:32:21 +02:00
btwotwo
bc7080884c
Add tests for env var completion 2022-10-06 16:32:20 +02:00
btwotwo
ddf68ea7c3
Add const list of cargo-defined env variables with descriptions 2022-10-06 16:32:20 +02:00
btwotwo
07621ce096
Use expanded version of text for env var completion 2022-10-06 16:32:19 +02:00
btwotwo
75f4c54d8c
Add stub for cargo environment variables auto completion 2022-10-06 16:32:19 +02:00
Lukas Wirth
bfd5f00bfc Fix trait impl item completions using macro file text ranges 2022-10-01 15:34:45 +02:00
Lukas Wirth
ad17ba12d1 Complete variants and assoc items in path pattern through type aliases 2022-09-16 16:11:58 +02:00