Commit Graph

14551 Commits

Author SHA1 Message Date
Morgan Thomas
f922b805fe - clean up match in ide_completion::completions::record::complete_record_literal
- use original instead of adjusted type in ide_completion::completions::record::complete_record
- don't even bother checking if we can complete union literals to Default or to struct update syntax
2022-03-12 07:35:13 -08:00
Morgan Thomas
6519b0a009 Suggest union literals, suggest union fields within an empty union literal 2022-03-12 06:58:43 -08:00
Morgan Thomas
f27c0ef1cf Reduce intermediate string allocations in render::compound::render_record and ::render_tuple 2022-03-12 05:01:25 -08:00
Morgan Thomas
d430ddd809 Extract the code for formatting struct and enum-variant literal labels out into a common function 2022-03-12 04:40:05 -08:00
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
bors[bot]
224a255c5a
Merge #11680
11680: fix: Show what file paths were expected for unresolved modules r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-11 16:17:59 +00:00
Lukas Wirth
a9dd606387 fix: Show what file paths were expected for unresolved modules 2022-03-11 17:08:30 +01:00
bors[bot]
69e5bd5a25
Merge #11676
11676: internal: Expand into pseudo-derive attribute expansions in completions r=Veykril a=Veykril

With this we now properly handle qualified path completions in derives
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-10 21:24:11 +00: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
Dario Nieuwenhuis
49d1207775 Add support for new where clause location in associated types.
A recent Rust nightly changed it: https://github.com/rust-lang/rust/issues/89122

This allows both the old and new location.
2022-03-10 18:21:29 +01:00
Lukas Wirth
533f178a52 minor: Access parser internals through ide_db for ide crates 2022-03-10 17:07:28 +01:00
bors[bot]
a7d440e368
Merge #11662
11662: fix: extract_module selection inside impl r=Veykril a=feniljain

Should close: #11508 

From issue:
Concern 1: Seems to be fixed in latest `rust-analyzer` build
Concern 2 and 3: Should be fixed by this PR
Concern 4: Got fixed in #11472 

Points to note:

- Here I have seperated use items and other items, this is becuase the new `impl` block which we will be creating cannot contain use items as immediate children. As they are the only one item that can be generated by our assist, so seperating them helps in handling their inclusion in new `impl` block inside new `module`

- There's also a new method added which helps in removing remaning left over indentation after removing `impl` or other `item`

Co-authored-by: vi_mi <fkjainco@gmail.com>
2022-03-10 15:49:03 +00:00
bors[bot]
5b51cb835a
Merge #11664
11664: fix: Properly handle proc-macro crate types for nameres r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-09 21:45:42 +00:00
Lukas Wirth
fdde10ba6f Update project_model test outputs 2022-03-09 22:34:42 +01:00
Lukas Wirth
1f1185dcbb Specific proc-macro crate type for other test fixture where needed 2022-03-09 22:18:09 +01:00
bors[bot]
4fcaefa62a
Merge #11660
11660: Insert dummy values for const generics in subst r=flodiebold a=HKalbasi

fix #11659 

This is a band-aid until proper const generic support.

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-03-09 17:18:03 +00:00
Lukas Wirth
5b9799bba4 Specify proc-macro crate type for proc-macro hir_def test fixtures 2022-03-09 15:36:05 +01:00
Lukas Wirth
3edc5dcea8 fix: Properly handle proc-macro crate types for nameres 2022-03-09 14:33:39 +01:00
bors[bot]
d70ea759b3
Merge #11663
11663: Internal: Add hir_def::MacroId, add Macro{Id} to ModuleDef{Id} r=Veykril a=Veykril

With this we can now handle macros like we handle ModuleDefs making them work more like other definitions and allowing us to remove a bunch of special cases. This also enables us to track the modules these macros are defined in, instead of only recording the crate they come from.

Introduces a new class of `MacroId`s (for each of the 3 macro kinds) into `hir_def`. We can't reuse `MacroDefId` as that is defined in `hir_expand` which doesn't know of modules, so now we have two different macro ids, this unfortunately requires some back and forth mapping between the two via database accesses which I hope won't be too expensive.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-09 10:26:34 +00:00
Lukas Wirth
2537ad0d9e Simplify 2022-03-09 11:26:06 +01:00
Lukas Wirth
054ab5fd9c Disable one of the failing SSR test cases 2022-03-09 02:08:44 +01:00
Lukas Wirth
f9c8646d89 fix symbol index collection not collecting legacy macros 2022-03-09 01:44:20 +01:00
Lukas Wirth
4e94fb7028 Fix ProcMacroData recording wrong name for derives 2022-03-09 01:13:38 +01:00
Lukas Wirth
c37fe779c6 Add data queries for macros 2022-03-09 00:41:54 +01:00
Lukas Wirth
55ec93a337 Remove unnecessary macro_declarations from ItemScope 2022-03-09 00:19:53 +01:00
Lukas Wirth
dbada38b61 Only store derive<->derive-helper mapping in DefMap 2022-03-09 00:01:19 +01:00
Lukas Wirth
eba90936c1 Move ide crates to new hir::Macro 2022-03-08 23:52:26 +01:00
Lukas Wirth
c04b0f435b Move hir to new MacroId 2022-03-08 23:51:48 +01:00
Lukas Wirth
ad54ee2939 Rename MacroDef to Macro 2022-03-08 23:51:19 +01:00
hkalbasi
1282178783 insert dummy values for const generics in subst 2022-03-09 02:02:42 +03:30
Lukas Wirth
42d46325a1 Add MacroId to hir_def in attempt to unify Macros with ModuleDefId 2022-03-08 21:50:00 +01:00
vi_mi
5789caf60e fix: extract_module selection inside impl 2022-03-09 01:38:53 +05:30
Laurențiu Nicola
4a6ee4517a Add back colons around inlay hints 2022-03-08 12:01:02 +02:00
Laurențiu Nicola
8e3057d0a7 Improve inlay hint padding 2022-03-07 19:18:36 +02:00
bors[bot]
49646b71d4
Merge #11445
11445: Upstream inlay hints r=lnicola a=lnicola

Closes https://github.com/rust-analyzer/rust-analyzer/issues/2797
Closes https://github.com/rust-analyzer/rust-analyzer/issues/3394 (since now resolve the hints for the range given only, not for the whole document. We don't actually resolve anything due to [hard requirement](https://github.com/rust-analyzer/rust-analyzer/pull/11445#issuecomment-1035227434) on label being immutable. Any further heavy actions could go to the `resolve` method that's now available via the official Code API for hints)

Based on `@SomeoneToIgnore's` branch, with a couple of updates:

 - I squashed, more or less successfully, the commits on that branch
 - downloading the `.d.ts` no longer works, but you can get it manually from https://raw.githubusercontent.com/microsoft/vscode/release/1.64/src/vscode-dts/vscode.proposed.inlayHints.d.ts
 - you might need to pass `--enable-proposed-api matklad.rust-analyzer`
 - if I'm reading the definition right, `InlayHintKind` needs to be serialized as a number, not string
 - this doesn't work anyway -- the client-side gets the hints, but they don't display

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-03-07 16:49:12 +00:00
Laurențiu Nicola
88a2141b77 Add inlayHints cap 2022-03-07 18:48:27 +02:00
Laurențiu Nicola
26d2e88b04 Fix parameter hint position 2022-03-07 15:24:54 +02:00
Laurențiu Nicola
b9d74fe2ed Update LSP docs 2022-03-07 15:09:31 +02:00
Luna Razzaghipour
6da1228898
Emit more detailed highlighting for %, >>, << 2022-03-07 20:16:03 +11:00
bors[bot]
5fae65dd28
Merge #11639
11639: internal: Re-arrange ide_db modules r=Veykril a=Veykril

Thins out the `helpers` module by giving some items more appropriate places to live
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-06 18:31:30 +00:00
Lukas Wirth
93b09ca067 Update tidy ignore list 2022-03-06 19:18:40 +01:00
Lukas Wirth
ab21cf2f4f internal: Re-arrange ide_db modules 2022-03-06 19:04:04 +01:00
bors[bot]
b9538122f2
Merge #11637
11637: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-03-06 16:56:29 +00:00
Lukas Wirth
c1f91c93b2 minor: Simplify 2022-03-06 17:56:02 +01:00