Commit Graph

537 Commits

Author SHA1 Message Date
Morgan Thomas
b3640ce424 make the doc comment on render::compound::visible_fields a little better 2022-03-11 19:23:04 -08:00
Morgan Thomas
6a1c151159 visibility tweak for CI 2022-03-11 19:10:43 -08:00
Morgan Thomas
2a22cf8efc Complete enum variants identically to structures.
In particular:
 - unit variants now display in the menu as "Variant", complete to "Variant", and display a detail of "Variant" (was "()")
 - tuple variants now display in the menu as "Variant(…)", complete to "Variant(${1:()})$0" (was "Variant($0)"), and display a detail of "Variant(type)" (was "(type)")
 - record variants now display in the menu as "Variant {…}", complete to "Variant { x: ${1:()} }$0" (was "Variant"), and display a detail of "Variant { x: type }" (was "{x: type}")

This behavior is identical to that of struct completions. In addition, tuple variants no longer set triggers_call_info, as to my understanding it's unnecessary now that we're emitting placeholders.

Tests have been updated to match, and the render::enum_variant::tests::inserts_parens_for_tuple_enums test has been removed entirely as it's covered by other tests (render::enum_detail_includes_{record, tuple}_fields, render::enum_detail_just_name_for_unit, render::pattern::enum_qualified).
2022-03-11 18:26:01 -08:00
Morgan Thomas
1c5b2c7d03 - Break out functionality related to rendering struct completions into crates/ide_completion/src/render/compound.rs
- Add support for placeholder completions in tuple structs
- Denote tuple struct completions with `(…)` instead of ` {…}`
- Show struct completions as their type (`Struct { field: Type }`) in the completion menu instead of raw snippet text (`Struct { field: ${1:()} }$0`)
2022-03-11 17:55:25 -08:00
Lukas Wirth
6c8c02f625 Don't parse source files to generate macro completion details 2022-03-10 22:21:58 +01:00
Lukas Wirth
b1ab5770c9 Enable qualifier completions for derives 2022-03-10 21:56:19 +01:00
Lukas Wirth
2abe19e46a Don't offer qualified path completions for buitlin derives 2022-03-10 21:22:13 +01:00
Lukas Wirth
a8b76b632c Expand into pseudo-derive attribute expansions in completions 2022-03-10 20:53:50 +01:00
Lukas Wirth
c37fe779c6 Add data queries for macros 2022-03-09 00:41:54 +01:00
Lukas Wirth
eba90936c1 Move ide crates to new hir::Macro 2022-03-08 23:52:26 +01:00
Lukas Wirth
ab21cf2f4f internal: Re-arrange ide_db modules 2022-03-06 19:04:04 +01:00
Lukas Wirth
5c0aee013e Fix highlighting of Self 2022-03-05 23:34:37 +01:00
hkalbasi
4fa8749c44 Preserve order of generic args 2022-03-04 11:46:14 +03:30
bors[bot]
a2cc1d6b7b
Merge #11538
11538: feat: Make private editable completions configurable, disable by default r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10253
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9885

This does disable these completions by default, as it seems that people find this behaviour surprising(due to other IDEs usually not doing this).

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-25 21:17:24 +00:00
Lukas Wirth
2a7793d912 feat: Make private editable completions configurable, disable by default 2022-02-25 22:16:40 +01:00
Florian Diebold
6fb5abbc03 Refactor autoderef and method resolution
- don't return the receiver type from method resolution; instead just
 return the autorefs/autoderefs that happened and repeat them. This
 ensures all the effects like trait obligations and whatever we learned
 about type variables from derefing them are actually applied. Also, it
 allows us to get rid of `decanonicalize_ty`, which was just wrong in
 principle.

 - Autoderef itself now directly works with an inference table. Sadly
 this has the effect of making it harder to use as an iterator, often
 requiring manual `while let` loops. (rustc works around this by using
 inner mutability in the inference context, so that things like unifying
 types don't require a unique reference.)

 - We now record the adjustments (autoref/deref) for method receivers
 and index expressions, which we didn't before.

 - Removed the redundant crate parameter from method resolution, since
 the trait_env contains the crate as well.

 - in the HIR API, the methods now take a scope to determine the trait env.
 `Type` carries a trait env, but I think that's probably a bad decision
 because it's easy to create it with the wrong env, e.g. by using
 `Adt::ty`. This mostly didn't matter so far because
 `iterate_method_candidates` took a crate parameter and ignored
 `self.krate`, but the trait env would still have been wrong in those
 cases, which I think would give some wrong results in some edge cases.

Fixes #10058.
2022-02-25 11:47:14 +01:00
Lukas Wirth
94e59c9c56 Simplify 2022-02-22 10:20:45 +01:00
Lukas Wirth
7b89d5ede2 internal: Expand the derive attribute into a pseudo expansion 2022-02-22 10:20:40 +01:00
bors[bot]
8c718a47c1
Merge #11517
11517: fix: Fix qualfiied record literal completion triggering too eagerly r=Veykril a=Veykril

Supercedes https://github.com/rust-analyzer/rust-analyzer/pull/10909
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10889
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 12:52:11 +00:00
Lukas Wirth
50458e350f fix: Fix qualfiied record literal completion triggering too eagerly 2022-02-21 13:50:16 +01:00
Chayim Refael Friedman
13ac5c3491 Fix various IDE features
As a side benefit, we got `let` guard support for `move_guard` for free.
2022-02-21 08:34:35 +02:00
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