Commit Graph

1483 Commits

Author SHA1 Message Date
Lukas Wirth
0d3cd90d08 Move fn to proc-macro conversion to name classification 2022-02-21 17:56:11 +01:00
bors[bot]
24255e5b3d
Merge #11481
11481: Display parameter names when hovering over a function pointer r=Veykril a=Vannevelj

Implements #11474

The idea is pretty straightforward: previously we constructed the hover based on just the parameter types, now we pass in the parameter names as well. I went for a quick-hit approach here but I expect someone will be able to point me to a better way of resolving the identifier.

I haven't figured out yet how to actually run my rust-analyzer locally so I can see it in action but the unit test indicates it should work.

Co-authored-by: Jeroen Vannevel <jer_vannevel@outlook.com>
2022-02-21 13:08:31 +00: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
KarlWithK
5f3327a6b8
Correctly fix formatting doc tests with generics
Before the doc_test would be outputted like this:
"Foo<T, U>::t"
However, this would cause shells with shell redirection. I've changed it
so when generics are involved we simply wrap the expression under escape
chanters as so:
"\"Foo<T, U>::t\""

Note:
At the cost of adding this, I had to allocate a new string via
format!{}. However, I argue this is alright as this for just for
outputting the name of the doc test.

The following tests have been changed:
runnables::tests::doc_test_type_params
runnables::tests::test_doc_runnables_impl_mod
runnables::tests::test_runnables_doc_test_in_impl
2022-02-17 20:27:37 -06:00
Jeroen Vannevel
842ffde43d
test names 2022-02-15 19:22:36 +00:00
Jeroen Vannevel
d985394ce2
add test for function pointer without identifier 2022-02-15 19:20:50 +00:00
Jeroen Vannevel
c450d0ce41
cleanup 2022-02-15 14:47:23 +00:00
Jeroen Vannevel
73e49493bd
rough, but appears to work 2022-02-15 14:39:22 +00:00
Lukas Wirth
95db3c1476 fix: keyword hover works on non-keyword tokens if expanded to keyword 2022-02-15 10:09:19 +01:00
bors[bot]
aafa40cebd
Merge #11369
11369: feat: Add type hint for keyword expression hovers r=Veykril a=danii

Adds the return type of keywords to tool-tips where it makes sense. This applies to: `if`, `else`, `match`, `loop`, `unsafe` and `await`. Thanks to `@Veykril` for sharing the idea of putting return type highlighting on other keywords!
![image](https://user-images.githubusercontent.com/39541871/151611737-12325c23-a1f9-4fca-ae48-279b374bdcdf.png)

Closes #11359

Co-authored-by: Daniel Conley <himself@danii.dev>
2022-02-14 21:07:41 +00:00
Daniel Conley
768804f11d
Hide Keyword Expression Hover For Units ()
Cleaned up the code for keyword expression hovers.

Added a check to hide units `()` in keyword expression hovers.
2022-02-14 15:26:40 -05:00
Lukas Wirth
cef8a17ea5 Handle proc-macro functions as the proc-macro they resolve to 2022-02-11 22:06:03 +01:00
Tianyi Song
e62e926a8a Use text range of name after macro expansion 2022-02-11 14:17:12 +08:00
TheDoctor314
add80bccfc Add test
The rename function should not change any path segments that refer to a
module by super.
2022-02-08 21:19:14 +05:30
Moritz Vetter
ba2ef69c79 Bump pulldown-cmark-to-cmark, adjust usages and fix test 2022-02-06 09:04:06 +01: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
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
Lukas Wirth
ddf7b70a0f Fix cfg_attr invalidating derive identifier IDE functionality 2022-01-30 22:47:16 +01:00
Daniel Conley
261abbf45e
Add Keyword Return Type Highlighting 2022-01-28 14:44:17 -05:00
bors[bot]
2cb85c14b6
Merge #11281
11281: ide: parallel prime caches r=jonas-schievink a=jhgg

cache priming goes brrrr... the successor to #10149

---

this PR implements a parallel cache priming strategy that uses a topological work queue to feed a pool of worker threads the crates to index in parallel.

## todo
- [x] should we keep the old prime caches?
- [x] we should use num_cpus to detect how many cpus to use to prime caches. should we also expose a config for # of worker CPU threads to use?
- [x] something is wonky with cancellation, need to figure it out before this can merge. 

Co-authored-by: Jake Heinz <jh@discordapp.com>
2022-01-25 16:03:35 +00:00
Laurențiu Nicola
e3e6133ff4 Bump pulldown-cmark and pulldown-cmark-to-cmark 2022-01-21 19:49:57 +02:00
Jonas Schievink
a3d06f824b status: output all crates a file belongs to 2022-01-17 18:10:01 +01:00
bors[bot]
7a52f83700
Merge #11294
11294: internal: Move format specifier lexing from syntax to ide_db r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-15 12:18:46 +00:00
Lukas Wirth
91279db2b4 Move format specifier lexing from syntax to ide_db 2022-01-15 13:14:59 +01:00
bors[bot]
4c34909308
Merge #11293
11293: feat: Add very simplistic ident completion for format_args! macro input r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-15 11:24:21 +00:00
Lukas Wirth
82fccb971e feat: Add very simplistic ident completion for format_args! macro input 2022-01-15 12:23:26 +01:00
Jake Heinz
25f67b6939 make it a config 2022-01-15 02:47:47 +00:00
bors[bot]
9ba6cfa9c7
Merge #11283
11283: fix: Adjust `.` typing auto indentation r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-14 11:16:18 +00:00
Lukas Wirth
ba3efafc0d fix: Adjust . typing auto indentation 2022-01-14 12:15:43 +01:00
Jake Heinz
bcc99091f3 hacky fix for cancelling 2022-01-14 10:30:51 +00:00
Jake Heinz
6c5504a617 one last bit of cleanup 2022-01-14 10:10:47 +00:00
Jake Heinz
c3f30ae4f0 removed scoped threads, cleanup 2022-01-14 10:06:28 +00:00
Jake Heinz
f83c0166be cleanup + detect num cpus 2022-01-14 09:48:59 +00:00
Jake Heinz
0b0bfc6fdd cleanup 2022-01-14 09:36:03 +00:00
Jake Heinz
c8aa2f6a61 use index map 2022-01-14 09:35:41 +00:00
Jake Heinz
5f0c1aa2de make progress callback dyn 2022-01-14 09:33:40 +00:00
Jake Heinz
2b0d8a86a2 fix warnings 2022-01-14 09:25:45 +00:00
Jake Heinz
343b0ccfb9 simplify 2022-01-14 09:21:25 +00:00
Jake Heinz
3168148cc6 ide: parallel prime caches 2022-01-14 09:16:35 +00:00
Jonas Schievink
09219e10f1 Mostly restore hir API boundary 2022-01-12 19:56:47 +01:00
Lukas Wirth
b32f611b6e fix: Fix outline modules spilling inner doc injections into their parent 2022-01-08 14:54:31 +01:00
Lukas Wirth
6746ba5839 Record attribute calls on assoc items in TraitData and ImplData 2022-01-08 10:45:12 +01:00
bors[bot]
40009e07d0
Merge #11145
11145: feat: add config to use reasonable default expression instead of todo! when filling missing fields r=Veykril a=bnjjj

Use `Default::default()` in struct fields when we ask to fill it instead of putting `todo!()` for every fields

before:

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {<|>};
}
``` 

after: 

```rust
pub enum Other {
    One,
    Two,
}

pub struct Test {
    text: String,
    num: usize,
    other: Other,
}

fn t_test() {
    let test = Test {
        text: String::new(),
        num: 0,
        other: todo!(),
    };
}
``` 



Co-authored-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
Co-authored-by: Coenen Benjamin <benjamin.coenen@hotmail.com>
2022-01-07 14:10:11 +00:00
Lukas Wirth
ca4baa6e55 Use FileAstId<ast::Adt> in nameres where appropriate instead 2022-01-07 14:20:27 +01:00
Laurențiu Nicola
e14d9208f5 Move pretty-printing test out of assist 2022-01-06 16:38:25 +02:00
Lukas Wirth
dc135cc076 internal: Support registered tools and attributes in ide layer 2022-01-06 14:56:50 +01:00
Jonas Platte
c90c88b083
Always put a space after impl in macro pretty-printing
… regardless of whether the next symbol is punctuation or not.
2022-01-06 11:33:08 +01:00
bors[bot]
ac3ea3e81c
Merge #11112
11112: Evaluate constants in array repeat expression r=HKalbasi a=HKalbasi

cc #8655 

Co-authored-by: hkalbasi <hamidrezakalbasi@protonmail.com>
2022-01-04 21:51:37 +00:00
hkalbasi
75c2acae6e Evaluate constants in array repeat expression 2022-01-05 01:17:01 +03:30
Lukas Wirth
c5a9985fc5 Remove lossy Definition::from_token/Definition::from_node methods 2022-01-04 18:29:53 +01:00
bors[bot]
68bc12c3b8
Merge #11157
11157: internal: Remove `SemanticScope::speculative_resolve_as_mac` r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-01-04 16:49:47 +00:00
Lukas Wirth
19f1ff5c70 give resolve_derive_ident a more robust api 2022-01-03 16:00:45 +01:00
bors[bot]
8e9ccbf97a
Merge #11177
11177: internal: dont descend into comments r=Veykril a=jhgg

fixes #11176

Co-authored-by: Jake Heinz <jh@discordapp.com>
2022-01-03 02:03:03 +00:00
Jake Heinz
04decd5e6b internal: dont descend into comments 2022-01-03 01:53:58 +00:00
bors[bot]
abbc7e3a0e
Merge #11088
11088: closes #10446 hide type inlay hints r=Veykril a=Heinenen

Passes tests as described in #10446
Works for all happy cases, there may be some cases that I forgot as I am not that familiar with Rust and r-a (yet).

Co-authored-by: Heinenen <th.m.heinen@gmail.com>
2022-01-03 00:51:08 +00:00
Lukas Wirth
087122ad1a fix: Fix highlighting hack for self-params 2022-01-03 01:32:03 +01:00
Lukas Wirth
6b7b09d329 internal: Record unresolved derive invocations in hir 2022-01-02 23:44:23 +01:00
Lukas Wirth
762a3b3030 Fix tool module classification not working correctly 2022-01-02 23:14:18 +01:00
Lukas Wirth
19d894cdec minor: Cleanup syntax highlighting 2022-01-02 22:23:05 +01:00
Lukas Wirth
22160c418b fix NameRefClass misclassifying proc-macros 2022-01-02 19:20:10 +01:00
Lukas Wirth
9eed85b171 fix syntactic highlighting for macros 2022-01-02 19:10:23 +01:00
Lukas Wirth
3a525c831f internal: Handle macro calls better in highlighting 2022-01-02 19:10:10 +01:00
Aleksey Kladov
d846afdeef check top level entry point invariants 2022-01-02 18:41:32 +03:00
Benjamin Coenen
df6fa50f92 feat(diagnostics): add new config to fill default expression
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2021-12-31 16:29:08 +01:00
hkalbasi
e6139cf47b show values of constants in hover 2021-12-23 17:53:46 +03:30
Heinenen
05abfc77f5 hide type inlay hints 2021-12-23 12:56:38 +01:00
Heinenen
d7dfe93fc3 hide type inlay hints for enum variant constructors and tuple struct constructors 2021-12-23 12:56:38 +01:00
Lukas Wirth
85ed5a3182 Make hover test not relient on minicore structure 2021-12-22 02:36:31 +01:00
Lukas Wirth
40d5c58a80 Fully render const item completions from hir 2021-12-21 16:35:51 +01:00
bors[bot]
d3aa2579cc
Merge #11069
11069: fix: Partially fix `ide_db::search` for crate roots r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-20 16:50:35 +00:00
Lukas Wirth
5206946674 fix: Partially fix ide_db::search for crate roots 2021-12-20 17:48:47 +01:00
bors[bot]
f46731a230
Merge #11028
11028: Bump MSRV (1.57) r=Veykril a=iDawer

This bumps MSRV on all crates to 1.57 except `la-arena`

#10986 requires >=1.57 

Co-authored-by: iDawer <ilnur.iskhakov.oss@outlook.com>
2021-12-20 13:45:35 +00:00
rainy-me
67cc6c1e16 feat: treat fn keyword inside function pointer type as primitive 2021-12-19 01:51:51 +09:00
Laurențiu Nicola
8ad7c0439c Remove needless clones 2021-12-17 17:35:10 +02:00
Lukas Wirth
d3e538638a fix: Don't duplicate attribute completions 2021-12-17 15:22:53 +01:00
iDawer
676744be6e Bump MSRV (1.57) 2021-12-16 01:56:12 +05:00
Lukas Wirth
04a7fbbddb Move out doc-links tests into a separate module 2021-12-14 12:10:43 +01:00
zhoufan
c3ad945d9b fixes broken tests 2021-12-14 15:57:58 +08:00
bors[bot]
3f550d2e38
Merge #11000
11000: fix: insert whitespaces into assoc items for assist when macro generated r=Veykril a=Veykril

This is obviously only a temporary hack which still produces ugly looking items, but as long as the syntax is valid one can at least have rustfmt fix the formatting again. 
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/6588
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-13 15:43:12 +00:00
Lukas Wirth
749eeef3e7 fix: insert whitespaces into assoc items for assist when macro generated 2021-12-13 16:35:32 +01:00
Lukas Wirth
328419534d Move ws insert rendering for macro expansion into ide_db 2021-12-13 15:55:13 +01:00
bors[bot]
4f04d8477a
Merge #10965
10965: minor: Remove dead assists-related function r=Veykril a=lnicola

Unless I'm missing something, `assists_with_fixes` seems to be always used and ends up in the same code path.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-12-11 15:06:52 +00:00
bors[bot]
d03397fe11
Merge #10978
10978: internal: Only prime direct dependencies of the workspace crates r=jonas-schievink a=lnicola

This reduces the number of primed crates on `self` from 177 to 105.

```text
# baseline
  86521 me   20   0 2939M  562M 14320 S  0.0  0.9  0:07.10   37 rust-analyzer

# pr
  99947 me   20   0 2935M  549M 14424 S  0.0  0.9  0:07.10   37 rust-analyzer
```

The RAM usage seems to vary a lot, so I'm not sure the improvement shown above is real.

We also drop the topological sorting, although it might still make sense to do the dependencies before the workspace crates. But since it's only used to make the progress reporting a bit more fine, it probably doesn't matter too much.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2021-12-10 22:31:55 +00:00
Lukas Wirth
c81aa68afe Don't show trait flyimports for impl trait and placeholders 2021-12-10 19:18:21 +01:00
Laurențiu Nicola
d012a20f25 Only prime direct dependencies of the workspace crates 2021-12-10 16:24:07 +02:00
Laurențiu Nicola
f5968cfc84 Remove dead assists-related function 2021-12-08 16:55:25 +02:00
bors[bot]
b7afb6fc6c
Merge #10958
10958: internal: add "Shuffle Crate Graph" command r=jonas-schievink a=jonas-schievink

May be useful for debugging issues like https://github.com/rust-analyzer/rust-analyzer/issues/10084

bors r+

Co-authored-by: Jonas Schievink <jonas.schievink@ferrous-systems.com>
2021-12-07 15:44:05 +00:00
Jonas Schievink
deb5c1426d internal: add "Shuffle Crate Graph" command 2021-12-07 16:37:19 +01:00
Lukas Wirth
f781e599cc Adjust incorrect runnable tests 2021-12-07 15:42:54 +01:00
Lukas Wirth
e09d410dcd Simplify 2021-12-07 15:06:56 +01:00
Lukas Wirth
b66f181bc0 Fix some TryToNav impls not upmapping ranges out of macros 2021-12-07 15:02:22 +01:00
Lukas Wirth
9b4ca77572 fix: Add highlighting hack back for unresolved attributes 2021-12-05 11:59:07 +01:00
bors[bot]
6434ada19e
Merge #10930
10930: fix: Fix self keyword not being tagged as such in highlighting properly r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-04 18:08:11 +00:00
Lukas Wirth
b35a50cb10 fix: Fix self keyword not being tagged as such in highlighting properly 2021-12-04 19:07:18 +01:00
bors[bot]
372a7cf981
Merge #10929
10929: internal: Split up macro/attribute semantic tokens a bit more r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-12-04 17:33:16 +00:00
Lukas Wirth
3472105ad9 Update semantic token docs 2021-12-04 18:23:25 +01:00
Lukas Wirth
e4f2d0e3a8 Introduce SymbolKind::Derive 2021-12-04 18:18:09 +01:00
Lukas Wirth
642c1eb720 Introduce SymbolKind::Attribute 2021-12-04 18:01:22 +01:00
Laurențiu Nicola
b7368d34a6 Bump pulldown-cmark-to-cmark 2021-12-04 15:21:04 +02:00