Commit Graph

203 Commits

Author SHA1 Message Date
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
bors
125d43cb2c Auto merge of #13227 - Veykril:core-pref, r=Veykril
Restructure `find_path` into a separate functions for modules and non-module items

Follow up to https://github.com/rust-lang/rust-analyzer/pull/13212
Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc

This PR turned into a slight rewrite, so it unfortunately does a few more things that I initially planned to (including a bug fix for enum variant paths)
2022-09-13 13:16:57 +00:00
Lukas Wirth
a8ecaa1979 Restructure find_path into a separate functions for modules and non-module items
Also renames `prefer_core` imports config to `prefer_no_std` and changes the behavior of no_std path searching by preferring `core` paths `over` alloc
2022-09-13 15:15:27 +02:00
bors
f64c95600c Auto merge of #13216 - DesmondWillowbrook:move_format_string_arg, r=DesmondWillowbrook
New assist: move_format_string_arg

The name might need some improving.

```rust
fn main() {
    print!("{x + 1}");
}
```
to
```rust
fn main() {
    print!("{}"$0, x + 1);
}
```

fixes #13180

ref to #5988 for similar work

* extracted `format_like`'s parser to it's own module in `ide-db`
* reworked the parser's API to be more direct
* added assist to extract expressions in format args
2022-09-12 15:50:42 +00:00
bors
352a5b8625 Auto merge of #13212 - Veykril:no-std-config, r=Veykril
Add config to unconditionally prefer core imports over std

Fixes https://github.com/rust-lang/rust-analyzer/issues/12979
2022-09-12 11:51:31 +00:00
Kartavya Vashishtha
cc7200891b
new lint: move_format_string_arg
The name might need some improving.

extract format_like's parser to it's own module in ide-db

reworked the parser's API to be more direct

added assist to extract expressions in format args
2022-09-10 20:13:46 +05:30
Kartavya Vashishtha
2584d48508
wip 2022-09-10 20:13:46 +05:30
Lukas Wirth
7d19971666 Add config to unconditionally prefer core imports over std
Fixes https://github.com/rust-lang/rust-analyzer/issues/12979
2022-09-09 20:04:56 +02:00
Peh
bd3feea8bc fix: removed swap file 2022-09-08 22:44:10 +01:00
Peh
c7fefd5223 fix: add semicolon completion to mod 2022-09-08 22:37:31 +01:00
austaras
748567cba5 complete full struct in enum varaint 2022-09-05 03:36:14 +08:00
Aleksey Kladov
d7ef3f51ec fix: correct broken logic for return complition
It seems that we've accidentally deleted the tests here couple of years
ago, and then fairly recently made a typo during refactor as well.

Reinstall tests, with coverage marks this time :-)
2022-09-04 18:12:55 +01:00
Lukas Wirth
6c5d15800e fix: Fix reference autocompletions using incorrect offsets in macro inputs
Fixes https://github.com/rust-lang/rust-analyzer/issues/13035
2022-08-23 14:29:59 +02:00
bors
1da9156b0d Auto merge of #12982 - jridgewell:into_future, r=Veykril
Implement IntoFuture type inference

One of my projects is using [IntoFuture](https://doc.rust-lang.org/std/future/trait.IntoFuture.html) to make our async code a little less verbose. However, rust-analyzer can't infer the output type of an await expression if the value uses `IntoFuture` to convert into another type. So we're getting `{unknown}` types everywhere since switching.

`foo.await` itself [desugars](e4417cf020/compiler/rustc_ast_lowering/src/expr.rs (L644-L658)) into a `match into_future(foo) {}`, with every `Future` impl getting a [default](e4417cf020/library/core/src/future/into_future.rs (L131-L139)) `IntoFuture` implementation. I'm not sure if we want to disable the old `future_trait` paths, since this only recently [stabilize](https://github.com/rust-lang/rust/pull/98718).
2022-08-18 07:37:47 +00:00
Dezhi Wu
23747419ca fix: a bunch of typos
This PR will fix some typos detected by [typos].

There are also some other typos in the function names, variable names, and file
names, which I leave as they are. I'm more certain that typos in comments
should be fixed.

[typos]: https://github.com/crate-ci/typos
2022-08-17 21:44:58 +08:00
Justin Ridgewell
cebf95718c Find IntoFuture::IntoFuture's poll method 2022-08-16 17:53:10 -04:00
yue4u
91358bd937 fix: format literal lookup 2022-08-16 01:24:21 +09:00