Commit Graph

516 Commits

Author SHA1 Message Date
bors[bot]
7a17fb9c43
Merge #11444
11444: feat: Fix up syntax errors in attribute macro inputs to make completion work more often r=flodiebold a=flodiebold

This implements the "fix up syntax nodes" workaround mentioned in #11014. It isn't much more than a proof of concept; I have only implemented a few cases, but it already helps quite a bit.

Some notes:
 - I'm not super happy about how much the fixup procedure needs to interact with the syntax node -> token tree conversion code (e.g. needing to share the token map). This could maybe be simplified with some refactoring of that code.
 - It would maybe be nice to have the fixup procedure reuse or share information with the parser, though I'm not really sure how much that would actually help.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-02-12 12:48:46 +00:00
Jake Heinz
1c1d900d0b [ide_completion] render if a function is async/const/unsafe in completion details 2022-02-08 22:48:34 +00:00
Florian Diebold
30287e6051 Fix test 2022-02-08 20:44:46 +01:00
The0x539
1536fc040a Fix trait impl completion ranges 2022-02-04 19:55:55 -06:00
Lukas Wirth
2310908df7 fix: Fix vis restriction path completions always using the parent module 2022-02-03 17:02:12 +01: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
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
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
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
5c41f5d165 feat: Deprioritize completions of private but editable definitions 2022-02-02 02:05:49 +01:00
Lukas Wirth
d7a544e69a fix: Complete functions and methods from block level impls 2022-02-01 23:29:40 +01:00
Lukas Wirth
fcdced115e Deprioritize ops function completions for non-method calls 2022-02-01 12:33:55 +01:00
Lukas Wirth
6194092086 Complete local fn and closure params from surrounding locals scope 2022-01-31 11:56:42 +01:00
Laurențiu Nicola
c504518775 Temporarily disable format string completions 2022-01-17 09:30:35 +02:00
Lukas Wirth
82fccb971e feat: Add very simplistic ident completion for format_args! macro input 2022-01-15 12:23:26 +01:00
Lukas Wirth
2c36102722 internal: Decrease PartialOrd and PartialEq trait methods completion relevance 2022-01-15 11:05:13 +01:00
bors[bot]
fc331fe831
Merge #11282
11282: fix: Properly cache files in Semantics when ascending macros r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-14 10:08:27 +00:00
Lukas Wirth
2f8dd64830 Replace HasSource usages with Semantics equivalent 2022-01-14 10:59:27 +01:00
Laurențiu Nicola
84c59a1f9f Reformat code 2022-01-13 21:07:17 +02:00
bors[bot]
4fe10b7bfe
Merge #11265
11265: fix: Fix postfix completion panic r=lnicola a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-12 12:30:41 +00:00
Lukas Wirth
09ce5d81d0 fix: Fix postfix completion panic 2022-01-12 13:07:16 +01:00
bors[bot]
de50ef4bea
Merge #11263
11263: fix: Fix don't drop param completions when fully typing out a pattern r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-12 11:37:18 +00:00
Lukas Wirth
314b199e3c fix: Fix don't drop param completions when fully typing out a pattern 2022-01-12 12:36:46 +01:00
Lukas Wirth
51419c1931 Don't complete attributes with existing expressions 2022-01-11 19:03:21 +01:00
Lukas Wirth
4901ea3eef Lookup lang attribute on assoc item trait directly 2022-01-11 10:28:38 +01:00
Lukas Wirth
94b369faa3 Update tests 2022-01-11 09:26:53 +01:00
Lukas Wirth
ca0633c808 feat: Deprioritize ops methods in completion 2022-01-11 09:26:53 +01:00
bors[bot]
2fb6f5e46a
Merge #11218
11218: fix: Correct has_ref detection, avoiding duplicate &mut insertion on parameter completion r=Veykril a=weirane

The original code fails to detect there's a ref in scenarios such as `&mut s` and `& s` because `WHITESPACE` and `IDENT` got reversed.

Closes #11199.

Co-authored-by: Wang Ruochen <wrc@ruo-chen.wang>
2022-01-06 23:17:51 +00:00
Wang Ruochen
3a57f700d8
Correct has_ref detection 2022-01-06 11:46:28 -08:00
bors[bot]
735b542146
Merge #11201
11201: fix: Fix completions not considering ancestor items for attribute search r=Veykril a=Veykril

Turns out we never filled the `CompletionContext` with the attribute expansion of attributed impls and traits when typing in the assoc items, as we were only considering the assoc item to have an attribute to expand.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-05 20:45:27 +00:00
Lukas Wirth
bd91327079 fix: Fix completions not considering ancestor items for attribute search 2022-01-05 21:44:56 +01:00
Eduardo Canellas
a973e5a9db refactor: apply review suggestions 2022-01-04 19:30:57 -03:00
Eduardo Canellas
30b7e92afa remove forgotten dbg macro 2022-01-04 15:37:10 -03:00
Eduardo Canellas
838944b387 improve logic for trailing comma addition 2022-01-04 15:30:30 -03:00
Eduardo Canellas
a9612666f8 fix(completions): improve fn_param
- insert commas around when necessary
- only suggest `self` completions when param list is empty
- stop suggesting completions for identifiers which are already on the param list
2022-01-04 15:03:46 -03:00
Lukas Wirth
5fbdf20765 minor: Simplify 2022-01-04 10:56:28 +01:00
Lukas Wirth
809461cc42 fix: Enable completions for <_>::$0 2022-01-01 22:20:03 +01:00
Lukas Wirth
44d61766b5 internal: Record unresolved derive invocations in hir 2022-01-01 20:43:25 +01:00
Aleksey Kladov
bfc263f1f9 introduce hacks module 2021-12-28 18:57:13 +03:00
Aleksey Kladov
726da9884b avoid speculation when completing macros 2021-12-28 16:52:15 +03:00