Commit Graph

21118 Commits

Author SHA1 Message Date
Lukas Wirth
2310908df7 fix: Fix vis restriction path completions always using the parent module 2022-02-03 17:02:12 +01:00
bors[bot]
d6329f2171
Merge #11401
11401: Sort completion calls lexicographically r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-03 15:38:45 +00:00
Lukas Wirth
c83081879f Add abi string completions 2022-02-03 16:33:42 +01:00
Lukas Wirth
d3f3b6a87f Sort completion calls lexicographically 2022-02-03 16:05:21 +01:00
bors[bot]
5a7e11f5fb
Merge #11397
11397: internal: Refactor completion module split r=Veykril a=Veykril

Currently our completion infra is split into several modules, each trying to do completions for something specific. This "something" is rather unstructured as it stands now, we have a module for `flyimporting path` completions, `unqualified` and `qualified path` completions, modules for `pattern position` completions that only try to complete extra things for patterns that aren't done in the path modules, `attribute` completions that again only try to add builtin attribute completions without adding the normal path completions and a bunch of other special "entity" completions like lifetimes, method call/field access, function param cloning, ... which serve a more specific purpose than the previous listed ones.

As is evident, the former mentioned ones have some decent overlap which requires extra filtering in them so that they don't collide with each other duplicating a bunch of completions(which we had happen in the past at times).

Now this overlap mostly happens with path completions(and keyword completions as well in some sense) which gives me the feeling that having `qualified` and `unqualified` path completions be separate from the rest gives us more troubles than benefits in the long run.
So this is an attempt at changing this structure to instead still go by rough entity for special cases, but when it comes to paths we instead do the module split on the "path kinds"/"locations"(think pattern, type, expr position etc) that exist. This goes hand in hand with the test refactoring I have done that moved tests to "location oriented" modules as well as the `CompletionContext` refactoring that actually already started splitting the context up for path kinds.

This PR moves some path completions out of the `qualified` and `unqualified` path modules namely attribute, visibility, use and pattern paths.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-03 15:01:08 +00:00
Lukas Wirth
7619c2afea Simplify 2022-02-03 16:00:49 +01:00
Lukas Wirth
9f5ee155c1 Move path completions for patterns into pattern module 2022-02-03 15:52:03 +01:00
Lukas Wirth
33fd2d7aef Cleanup PathCompletionContext qualifier handling 2022-02-03 15:52:03 +01:00
Lukas Wirth
a3ad99649f Add missing test for use completions 2022-02-03 15:52:03 +01:00
Lukas Wirth
136dadac9a Add completion module tailored towards visibility modifiers 2022-02-03 15:52:03 +01:00
Lukas Wirth
661d721e20 Add completion module tailored towards use trees 2022-02-03 15:51:57 +01:00
Lukas Wirth
6940cca760 Move attribute path completions into attribute completion module 2022-02-03 15:50:14 +01:00
bors[bot]
46b5089bfa
Merge #11399
11399: Fix assoc type shorthand from method bounds r=flodiebold a=flodiebold

In code like this:
```rust
impl<T> Option<T> {
    fn as_deref(&self) -> T::Target where T: Deref {}
}
```

when trying to resolve the associated type `T::Target`, we were only
looking at the bounds on the impl (where the type parameter is defined),
but the method can add additional bounds that can also be used to refer
to associated types. Hence, when resolving such an associated type, it's
not enough to just know the type parameter T, we also need to know
exactly where we are currently.

This fixes #11364 (beta apparently switched some bounds around).

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-02-03 12:21:18 +00:00
Florian Diebold
4ed5fe1554 Fix assoc type shorthand from method bounds
In code like this:
```rust
impl<T> Option<T> {
    fn as_deref(&self) -> T::Target where T: Deref {}
}
```

when trying to resolve the associated type `T::Target`, we were only
looking at the bounds on the impl (where the type parameter is defined),
but the method can add additional bounds that can also be used to refer
to associated types. Hence, when resolving such an associated type, it's
not enough to just know the type parameter T, we also need to know
exactly where we are currently.

This fixes #11364 (beta apparently switched some bounds around).
2022-02-03 13:15:02 +01:00
bors[bot]
9cb6e3a190
Merge #11394
11394: feat: Deprioritize completions of private but editable definitions r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-02 11:42:40 +00:00
Lukas Wirth
2d77eb1e12 Fix test fixture 2022-02-02 12:42:13 +01:00
bors[bot]
d20ff92747
Merge #11395
11395: fix: Fix and re-enable format string completions r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-02 11:20:38 +00:00
Lukas Wirth
6f974cf477 fix: Fix and re-enable format string completions 2022-02-02 12:20:10 +01:00
Lukas Wirth
7267749f6b Cleanup Completions api a bit 2022-02-02 12:19:43 +01:00
Lukas Wirth
70650897d8 Fix generate_function assist trying to use name-ref like keywords for names 2022-02-02 11:37:24 +01:00
Lukas Wirth
5c41f5d165 feat: Deprioritize completions of private but editable definitions 2022-02-02 02:05:49 +01:00
bors[bot]
34138379b5
Merge #11322
11322: Extract function also extracts comments r=Vannevelj a=Vannevelj

Fixes #9011

The difficulty I came across is that the original assist works from the concept of a `ast::StmtList`, a node, but that does not allow me to (easily) represent comments, which are tokens. To combat this, I do a whole bunch of roundtrips: from the `ast::StmtList` I retrieve the `NodeOrToken`s it encompasses. 

I then cast all `Node` ones back to a `Stmt` so I can apply indentation to it, after which it is again parsed as a `NodeOrToken`.

Lastly, I add a new `make::` api that accepts `NodeOrToken` rather than `StmtList` so we can write the comment tokens.

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-02-01 23:05:28 +00:00
bors[bot]
498224af18
Merge #11393
11393: fix: Complete functions and methods from block level impls r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/11372

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 22:48:34 +00:00
Jeroen Vannevel
493642ab3a
rollup match 2022-02-01 22:38:37 +00:00
Lukas Wirth
d7a544e69a fix: Complete functions and methods from block level impls 2022-02-01 23:29:40 +01:00
bors[bot]
5ee21fee9c
Merge #11391
11391: minor: Add some debug traces for cfg fetching r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 12:35:52 +00:00
Lukas Wirth
dbd5a70ea3 minor: Add some debug traces for cfg fetching 2022-02-01 13:35:34 +01:00
bors[bot]
9b88956bd5
Merge #11390
11390: fix: Deprioritize ops function completions for non-method calls r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10593
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 11:34:40 +00:00
Lukas Wirth
fcdced115e Deprioritize ops function completions for non-method calls 2022-02-01 12:33:55 +01:00
Jeroen Vannevel
1811f6330b
better comparison 2022-02-01 09:00:30 +00:00
Jeroen Vannevel
b290285dd8
removed redundant test 2022-02-01 00:38:33 +00:00
Jeroen Vannevel
269153388a
added FIXME 2022-02-01 00:37:48 +00:00
Jeroen Vannevel
51c50dd5ac
don't tear body 2022-02-01 00:36:50 +00:00
Jeroen Vannevel
e72ed9230a
no longer support comments on their own 2022-02-01 00:21:35 +00:00
bors[bot]
4800c05a20
Merge #11388
11388: fix: Fix proc-macro server not using the supplied span in Ident::new r=Veykril a=Veykril

This makes the hack introduced by https://github.com/rust-analyzer/rust-analyzer/pull/10899 obsolete.

For async-trait specifically, (unfortunately, but technically correct) due to how async-trait works, the self local now renders white, as it now resolves to the `__self` local introduced by the attribute.

![Code_0Ezw6PJAbh](https://user-images.githubusercontent.com/3757771/151827812-c03b8fc7-7ecf-4959-804a-2680d8e61e8b.png)
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-31 16:03:23 +00:00
Lukas Wirth
f6def3ccdf fix: Fix proc-macro server not using the supplied span in Ident::new 2022-01-31 17:02:57 +01:00
bors[bot]
1cc125fdd8
Merge #11291
11291: internal: Make more precise range macro upmapping r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-31 15:22:42 +00:00
Lukas Wirth
45ff51ba22 Make more precise range macro upmapping 2022-01-31 15:53:44 +01:00
Lukas Wirth
5fd3688018 Fix token ascension single token check being inverted 2022-01-31 13:26:09 +01:00
bors[bot]
0808ade4e4
Merge #11182
11182: fix: don't panic on seeing an unexpected offset r=Veykril a=dimbleby

Intended as a fix, or at least a sticking plaster, for #11081.

I have arranged that [offset()](1ba9a924d7/crates/ide_db/src/line_index.rs (L105-L107)) returns `Option<TextSize>` instead of going out of bounds; other changes are the result of following the compiler after doing this.

Perhaps there's still an issue here - I suppose the server and client have gotten out of sync and that probably shouldn't happen in the first place?  I see that https://github.com/rust-analyzer/rust-analyzer/issues/10138#issuecomment-913727554 suggests what sounds like a more substantial fix which I think might be aimed in this direction.  So perhaps that one should be left open to cover such things?

Meanwhile, I hope that not-crashing is a good improvement: and I can confirm that it works out just fine in the repro I have at #11081.

Co-authored-by: David Hotham <david.hotham@metaswitch.com>
2022-01-31 11:16:22 +00:00
bors[bot]
66870ca0ed
Merge #11384
11384: feat: Complete local fn and closure params from surrounding locals scope r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-31 11:05:40 +00:00
Lukas Wirth
6194092086 Complete local fn and closure params from surrounding locals scope 2022-01-31 11:56:42 +01:00
bors[bot]
fd3942eb62
Merge #11382
11382: fix: Fix `cfg_attr` invalidating derive identifier IDE functionalities r=Veykril a=Veykril

Proper fix for https://github.com/rust-analyzer/rust-analyzer/issues/11298
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-30 22:08:25 +00:00
Lukas Wirth
ddf7b70a0f Fix cfg_attr invalidating derive identifier IDE functionality 2022-01-30 22:47:16 +01:00
Lukas Wirth
cc04cfc982 Reduce allocations in attribute collection 2022-01-30 22:18:32 +01:00
bors[bot]
c08df0f1f5
Merge #11377
11377: Update README.md r=flodiebold a=flodiebold

I'm not currently sponsored anymore.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-01-30 13:23:47 +00:00
Florian Diebold
b36c83032b Update README.md
I'm not currently sponsored anymore.
2022-01-30 14:21:52 +01:00
bors[bot]
6010431a0b
Merge #11356
11356: Rollback env vars changed by a proc macro r=vlad20012 a=vlad20012

Fixes #11355

Co-authored-by: vlad20012 <beskvlad@gmail.com>
2022-01-30 08:05:55 +00:00
Daniel Conley
261abbf45e
Add Keyword Return Type Highlighting 2022-01-28 14:44:17 -05:00
bors[bot]
6634eaf13a
Merge #11367
11367: minor: Use `compare_exchange_weak` in `limit::Limit::check` r=lnicola a=WaffleLapkin

Not a big deal, but generally loops should use `_weak` version of `compare_exchange`.

Co-authored-by: Maybe Waffle <waffle.lapkin@gmail.com>
2022-01-28 15:31:52 +00:00