Commit graph

14567 commits

Author SHA1 Message Date
Lukas Wirth
41b6b372a7 fix: Resolve private fields in type inference 2022-02-23 16:45:58 +01:00
Lukas Wirth
de0941301e Simplify 2022-02-23 16:29:33 +01:00
Lukas Wirth
ffeec9dec9 Simplify 2022-02-23 15:55:06 +01:00
Lukas Wirth
d3d054f574 Reduce visibility of proc-macros to pub(crate) 2022-02-23 12:00:04 +01:00
Lukas Wirth
e759db361e Resolve functions as proc-macros via FileAstId 2022-02-23 11:21:46 +01:00
Ole Strohm
5cdbfa5b70 Added test 2022-02-22 22:48:44 +00:00
Ole Strohm
94a221ae8d Dedup code 2022-02-22 22:41:03 +00:00
bors[bot]
0b53744f2d
Merge #11461
11461: Extract struct from enum variant filters generics r=jo-goro a=jo-goro

Fixes #11452.

This PR updates extract_struct_from_enum_variant. Extracting a struct `A` form an enum like
```rust
enum X<'a, 'b> {
    A { a: &'a () },
    B { b: &'b () },
}
```
will now be correctly generated as
```rust
struct A<'a> { a: &'a () }

enum X<'a, 'b> {
    A(A<'a>),
    B { b: &'b () },
}
```
instead of the previous
```rust
struct A<'a, 'b>{ a: &'a () } // <- should not have 'b

enum X<'a, 'b> {
    A(A<'a, 'b>),
    B { b: &'b () },
}
```

This also works for generic type parameters and const generics.

Bounds are also copied, however I have not yet implemented a filter for unneeded bounds. Extracting `B` from the following enum
```rust
enum X<'a, 'b: 'a> {
    A { a: &'a () },
    B { b: &'b () },
}
```
will be generated as 
```rust
struct B<'b: 'a> { b: &'b () } // <- should be `struct B<'b> { b: &'b () }`

enum X<'a, 'b: 'a> {
    A { a: &'a () },
    B(B<'b>),
}
```

Extracting bounds with where clauses is also still not implemented.

Co-authored-by: Jonas Goronczy <goronczy.jonas@gmail.com>
2022-02-22 18:46:12 +00:00
Jonas Goronczy
0db0dec999 Replaced fold with for loop 2022-02-22 19:38:34 +01:00
bors[bot]
033f91e75d
Merge #11472
11472: fix: visibility in impl items and pub(crate) to pub in extract_module r=feniljain a=feniljain

Should fix #11007 and #11443

Makes following changes:

- Removes visiblity modifiers from trait items
- Respect user given visibility
- Updated tests for the same

Co-authored-by: vi_mi <fkjainco@gmail.com>
Co-authored-by: vi_mi <49019259+feniljain@users.noreply.github.com>
2022-02-22 18:12:27 +00:00
vi_mi
7abd7b80f3
chore: reposition comment
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-22 19:46:50 +05:30
Ole Strohm
43a4c45ede fix: Make match_arms assist handle doc(hidden) and non_exhaustive 2022-02-22 13:59:30 +00:00
vi_mi
192b6f5a78 fix: visibility in impl items and pub(crate) to pub in extract_module 2022-02-22 18:35:45 +05:30
Lukas Wirth
2e124d15fb fix: Fix expand_macro always expanding the first listed derive 2022-02-22 12:32:27 +01:00
Lukas Wirth
b494795a42 update references::derive test output 2022-02-22 10:52:35 +01:00
Lukas Wirth
8db88df758 simplify and document 2022-02-22 10:45:29 +01:00
Lukas Wirth
94e59c9c56 Simplify 2022-02-22 10:20:45 +01:00
Lukas Wirth
1bbef5af85 Fix syntax highlighting not highlighting derives anymore 2022-02-22 10:20:44 +01:00
Lukas Wirth
f13c98034b Make replace_derive_with_manual_impl work again 2022-02-22 10:20:44 +01:00
Lukas Wirth
be3168dabe Fix expand_macro not working for derive attributes 2022-02-22 10:20:44 +01:00
Lukas Wirth
7b89d5ede2 internal: Expand the derive attribute into a pseudo expansion 2022-02-22 10:20:40 +01:00
bors[bot]
1fe3b2edd6
Merge #11527
11527: internal: Split unresolve proc-macro error out of mbe r=Veykril a=Veykril



Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-22 09:08:22 +00:00
Lukas Wirth
1505b6a9b4 internal: Split unresolve proc-macro error out of mbe 2022-02-22 10:08:00 +01:00
Tianyi Song
1c3d6725e2 Drop generic args in path before insert use 2022-02-22 15:41:26 +08:00
Jonas Goronczy
f721456c4a Removes ExtractedGenerics struct 2022-02-21 23:00:16 +01:00
bors[bot]
c0ee2f23ff
Merge #11490
11490: Correctly fix formatting doc tests with generics r=Veykril a=KarlWithK

Before the doc_test would be outputted like this:
```zsh
"Foo<T, U>::t"
```
However, this would cause problems with shell redirection. I've changed it
so when generics are involved we simply wrap the expression under quotes as so:
```zsh
"\"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
```

Closes  https://github.com/rust-analyzer/rust-analyzer/issues/11489

Co-authored-by: KarlWithK <jocelinc60@outlook.com>
Co-authored-by: SeniorMars <jocelinc60@outlook.com>
2022-02-21 21:57:44 +00:00
SeniorMars
bf47acf1d3
Update crates/ide/src/runnables.rs
Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 15:23:09 -06:00
Jonas Goronczy
f5f3921fab Cleanup 2022-02-21 19:51:09 +01:00
bors[bot]
b663b733d9
Merge #11522
11522: fix: Make code lenses work on attributed items r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 17:08:19 +00:00
Lukas Wirth
c6645f2eb6 fix: Make code lenses work on attributed items 2022-02-21 18:07:47 +01:00
bors[bot]
979b5b32bc
Merge #11455
11455: Handle proc-macro functions as the proc-macro they resolve to r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 16:56:37 +00:00
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
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
bors[bot]
36f302355b
Merge #11516
11516: fix: Don't count commas when looking for the derive attribute in diagnostics r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-21 12:44:10 +00:00
Lukas Wirth
8cdef2ffcf fix: Don't count commas when looking for the derive attribute in diagnostics 2022-02-21 13:43:42 +01:00
Jeroen Vannevel
9c6542f209
parameters.split_last() 2022-02-21 10:29:38 +00:00
bors[bot]
b0e293bf69
Merge #11424
11424: Pass required features to cargo when using run action r=Veykril a=WaffleLapkin

When using `F1`->`Rust Analyzer: Run` action on an `example`, pass its `required-features` to `cargo run`. This allows to run examples that were otherwise impossible to run with RA.

Co-authored-by: Maybe Waffle <waffle.lapkin@gmail.com>
2022-02-21 10:21:39 +00:00
Chayim Refael Friedman
f70512cc17 Change single_let() and is_pattern_cond() to free functions 2022-02-21 08:34:36 +02:00
Chayim Refael Friedman
9881614db1 Upgrade ungrammar to 1.15.0 2022-02-21 08:34:36 +02:00
Chayim Refael Friedman
821b791b6d Validate let expressions
Emit an error if they're found in an invalid position.
2022-02-21 08:34:35 +02:00
Chayim Refael Friedman
a1b7169b48 Update tests
Unfortunately, we lost some recovery for expressions.
2022-02-21 08:34:35 +02: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
Chayim Refael Friedman
fe1e324694 Type-inference for let expressions 2022-02-21 08:34:35 +02:00
Chayim Refael Friedman
6bf6f4ff1d Lower let expressions 2022-02-21 08:34:34 +02:00
Chayim Refael Friedman
de8633f15f Parse let expressions in order to support let chains
We still need to reject freestanding `let` expressions: see https://github.com/rust-analyzer/rust-analyzer/issues/11320#issuecomment-1018212465.
2022-02-21 08:34:34 +02:00
Lukas Wirth
035bedc28b internal: Remove name fields from MacroCallKind 2022-02-21 00:02:10 +01:00
Lukas Wirth
fbe787ee10 internal: Wrap MacroCallKind::Attr attr_args field in an Arc 2022-02-20 22:53:04 +01:00
Felicián Németh
2bcde5953a Fix a typo in server_capabilities.experimental 2022-02-19 10:58:10 +01:00
Jeroen Vannevel
d1fc208c9c
re-added FIXME 2022-02-18 09:12:52 +00: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
Chayim Refael Friedman
4b2985a23e Infer the array size for slice patterns 2022-02-16 12:19:26 +00:00
Jeroen Vannevel
794105c18b
removed double map 2022-02-15 19:37:24 +00:00
Jeroen Vannevel
f083c86890
simplified write 2022-02-15 19:27:56 +00: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
c8cd7a68b3
use Name instead of String 2022-02-15 19:12:23 +00:00
Jeroen Vannevel
e1df78820e
removed unwrap 2022-02-15 14:58:06 +00:00
Jeroen Vannevel
0a80cc82b1
cleaning 2022-02-15 14:55:21 +00:00
Jeroen Vannevel
3bba811e92
fmt 2022-02-15 14:47:51 +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
bors[bot]
f0210f8a43
Merge #11475
11475: Impr mbe: remove unecessary temporary vec r=bellau a=bellau

It's a micro optimization. I don't know if it's really necessary (less alloc is always better).

Co-authored-by: bellau <laurent.belmonte@gmail.com>
2022-02-15 09:36:22 +00:00
bellau
ff4024eebd Impr mbe: remove unecessary temporary vec 2022-02-15 10:21:14 +01: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]
9bc2ee34b0
Merge #11477
11477: fix: Fix cases where `Merge Imports` would drop imports. r=DropDemBits a=DropDemBits

Fixes #11466 

Co-authored-by: DropDemBits <r3usrlnd@gmail.com>
2022-02-15 01:50:25 +00:00
DropDemBits
a1a23d343a
Apply review fixes 2022-02-14 20:41:01 -05:00
DropDemBits
86c1251afb
fix: Don't drop glob with nested self 2022-02-14 19:45:31 -05:00
DropDemBits
df2eb3c7cb
fix: Don't drop tree when the other has self 2022-02-14 19:37:01 -05: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
bors[bot]
014d3ef1a4
Merge #11458
11458: Fix  Immovable generator syntax (static ||) not recognized #11448 r=Veykril a=bellau



Co-authored-by: bellau <laurent.belmonte@gmail.com>
2022-02-14 17:35:12 +00:00
doki
94b6038657
correct the description of Struct GlobalState 2022-02-14 19:30:21 +08:00
bellau
06452cd102 Fix style 2022-02-14 07:41:50 +01:00
bors[bot]
59c49a9c81
Merge #11442 #11460
11442: fix(rename): Use text range of a mod name after macro expansion r=Veykril a=tysg

Fixes #11417. 

11460: fix: documentation of SsrParams r=Veykril a=nemethf

Fix #11429 by extending the documentation of SsrParms with the
mandatory field 'selections'.  Copy its description from lsp_ext.rs.

Co-authored-by: Tianyi Song <42670338+tysg@users.noreply.github.com>
Co-authored-by: Felicián Németh <felician.nemeth@gmail.com>
2022-02-13 12:43:16 +00:00
Tianyi Song
aa8c982c3a Address PR comments 2022-02-13 18:14:39 +08:00
bellau
dc68b89469 oops, remove println 2022-02-13 09:11:35 +01:00
bellau
0a18a050b5 fix handle static async and static async move 2022-02-13 09:09:44 +01:00
Jonas Goronczy
c203cd4cb7 Extract struct from enum variant filters generics
Extracting a struct from an enum variant now filters out only the
generic parameters necessary for the new struct.
Bounds will be copied to the new struct, but unneeded ones are not
filtered out.
Extracting bounds in a where clause are still not implemented.
2022-02-12 23:21:41 +01:00
bellau
3ed19d54db Fix style 2022-02-12 17:31:17 +01:00
bellau
2008607946 support static move too 2022-02-12 16:07:58 +01:00
Felicián Németh
27c4be6b4f fix: add missing experimental capabilities
Fix #11389 by extending server_capabilities.experimental with
matchingBrace, externalDocs, moveItems.  Also, sort entries
alphabetically.
2022-02-12 15:37:13 +01:00
bellau
1284bc0af3 Fix styles 2022-02-12 15:35:06 +01:00
bellau
ccab6afabc Fix Immovable generator syntax (static ||) not recognized #11448 2022-02-12 15:17:10 +01: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
bors[bot]
4449a336f6
Merge #11453
11453: internal: Make `ascend_call_token` iterative instead of recursive r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-11 21:21:57 +00:00
Lukas Wirth
1c77f36311 internal: Make ascend_call_token iterative instead of recursive 2022-02-11 22:21:35 +01: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
Florian Diebold
ccb789b94a Format again 2022-02-09 17:52:15 +01:00
Florian Diebold
577f70cc9c Reduce visibility 2022-02-09 17:43:37 +01:00
Florian Diebold
dfd2cef0d0 Add back an assertion 2022-02-09 16:36:45 +01:00
Florian Diebold
63fd643d72 Various fixes 2022-02-09 16:30:10 +01:00
Florian Diebold
bdb7ae5dd0 Rename syntax_node_to_token_tree_censored 2022-02-09 13:45:31 +01:00
Florian Diebold
ecf3cff4a6 Replace expressions with errors in them 2022-02-09 11:58:52 +01:00
Laurențiu Nicola
50a1319f46 Bump lsp-types 2022-02-09 09:22:25 +02:00
Laurențiu Nicola
c8f056a6db Revert "Revert "Bump dashmap""
This reverts commit 39674cd350.
2022-02-09 09:19:57 +02:00
bors[bot]
7c2d7035a6
Merge #11437
11437: [ide_completion] render if a function is async/const/unsafe in completion details r=Veykril a=jhgg

this change renders in the autocomplete detail, whether a function is async/const/unsafe.

i found myself wanting to know this information at a glance, so now it renders here:

![image](https://user-images.githubusercontent.com/5489149/153089518-5419afe4-b2c6-4be8-80f7-585f5c514ff2.png)


Co-authored-by: Jake Heinz <jh@discordapp.com>
2022-02-08 23:30:50 +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
Florian Diebold
1a5aa84e9f Track synthetic tokens, to be able to remove them again later 2022-02-08 18:13:18 +01:00
TheDoctor314
10e7e18dc6 Fix renaming super keyword 2022-02-08 21:56:39 +05:30
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
Florian Diebold
1b5cd03a37 Actually check in fixup.rs 2022-02-07 20:30:28 +01:00
Florian Diebold
c3601e9860 Reverse fixups 2022-02-07 19:53:39 +01:00
Florian Diebold
79ebf618ec Simplify 2022-02-07 18:21:31 +01:00
Florian Diebold
86b968ba94 Add a check 2022-02-07 18:19:00 +01:00
Florian Diebold
b9c5d23f69 Simplify a bit 2022-02-07 18:17:28 +01:00
Florian Diebold
cff209f152 WIP: Actually fix up syntax errors in attribute macro input 2022-02-07 18:12:51 +01:00
Florian Diebold
212e82fd41 Add test for giving attribute proc macros valid syntax 2022-02-07 12:54:08 +01:00
Moritz Vetter
482533ea9a add missing snake case attribute, update hash 2022-02-07 04:57:20 +01:00
Maybe Waffle
662dd7c27d Pass required features to cargo when using run action
When using `F1`->`Rust Analyzer: Run` action on an `example`, pass its
`required-features` to `cargo run`. This allows to run examples that
were otherwise impossible to run with RA.
2022-02-06 19:02:25 +03:00
Moritz Vetter
ba2ef69c79 Bump pulldown-cmark-to-cmark, adjust usages and fix test 2022-02-06 09:04:06 +01:00
Laurențiu Nicola
39674cd350 Revert "Bump dashmap"
This reverts commit 485f318b70.
2022-02-05 16:15:56 +02:00
The0x539
1536fc040a Fix trait impl completion ranges 2022-02-04 19:55:55 -06:00
Lukas Wirth
ec677e35d0 Simplify 2022-02-04 02:50:33 +01:00
Lukas Wirth
2ad71f1350 Shrink mbe::ExpandError and mbe::ParseError 2022-02-03 17:25:24 +01: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
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
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
Lukas Wirth
dbd5a70ea3 minor: Add some debug traces for cfg fetching 2022-02-01 13:35:34 +01: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
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
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
Lukas Wirth
6194092086 Complete local fn and closure params from surrounding locals scope 2022-01-31 11:56:42 +01: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]
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
Maybe Waffle
78a3cefc45 Use compare_exchange_weak in limit::Limit::check 2022-01-28 18:19:35 +03:00
vlad20012
e277d5d64e
Add a way to disable dll copying for users of proc_macro_srv library 2022-01-28 16:18:25 +03:00
vlad20012
e93386f6ce
Rollback env vars changed by a proc macro 2022-01-28 13:43:29 +03:00
Maybe Waffle
6d18c5b69d feat: Honor recursion limit configuration
This patch makes RA understand `#![recursion_limit = "N"]` annotations.

- `crate_limits` query is moved to `DefDatabase`
- `DefMap` now has `recursion_limit: Option<u32>` field
2022-01-28 11:31:59 +03:00
Maybe Waffle
81211f538c Use crate_limits query in macro expansion 2022-01-28 11:31:59 +03:00
Maybe Waffle
c932ca5f1c Add crate_limits query to SourceDatabase
This allows fetching crate limits like `recursion_limit`. The
implementation is currently dummy and just returns the defaults.

Future work: Use this query instead of the hardcoded constant.

Future work: Actually implement this query by parsing
`#![recursion_limit = N]` attribute.
2022-01-28 11:31:59 +03:00
bors[bot]
b55a1c561a
Merge #11353
11353: Set current working directory for procedural macros r=vlad20012 a=vlad20012

Fixes #11079

Co-authored-by: vlad20012 <beskvlad@gmail.com>
2022-01-27 18:09:08 +00:00
Jonas Schievink
6c0fcb5b5d More correct $crate handling in eager macros 2022-01-27 16:57:53 +01:00
vlad20012
6051318744
Set current working directory for procedural macros 2022-01-27 16:18:12 +03:00
Jonas Schievink
3c51aaf065 Fix merge commit check for git 2.35 2022-01-26 19:10:39 +01:00
Jonas Schievink
35e5c3b3f9 Fix resolution of eager macro contents 2022-01-26 18:31:07 +01: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
Jonas Schievink
5088926ec3 Make syntax bridge fully infallible 2022-01-24 17:27:39 +01:00
Lukas Wirth
ebd723995a fix: don't panic in semantics due to cfg_attr disrupting offsets 2022-01-23 17:42:38 +01:00
Jeroen Vannevel
8f09e13c06 fixed whitespace 2022-01-22 13:28:23 +00:00
Jeroen Vannevel
8e8e1951e2 whitespace 2022-01-22 12:25:33 +00:00
Jeroen Vannevel
9725eaa21c generated docs 2022-01-22 12:17:24 +00:00
Jeroen Vannevel
61ab31f709 clarify doc 2022-01-22 12:10:48 +00:00
Jeroen Vannevel
4972cb759e Support standalone comments 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
8d61216957 redundant type specified 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
a1c246b1c4 shorter arms 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4ab7c4d99b removed prints 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
96ab4c6e6c hacky_block_expr_with_comments 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
5d35e5882c removed unwrapping from indent 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
ee862cec10 simplified tail_expr 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4896ffb65c removing unwraps 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
50c913c733 don't remove the comment token if it's last 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
4f3dd5bc08 very rough but comments get extracted 2022-01-22 12:08:32 +00:00
Jeroen Vannevel
f662d8bf38 repro 2022-01-22 12:08:32 +00:00
Laurențiu Nicola
bdfdb525bb Bump chalk 2022-01-21 19:51:21 +02:00
Laurențiu Nicola
e3e6133ff4 Bump pulldown-cmark and pulldown-cmark-to-cmark 2022-01-21 19:49:57 +02:00
Laurențiu Nicola
09fb755432 Bump hashbrown 2022-01-21 19:44:03 +02:00
Laurențiu Nicola
485f318b70 Bump dashmap 2022-01-21 19:42:04 +02:00
Jonas Schievink
e5ed43b1dc Remove redundant Option from eager macro fns 2022-01-21 12:58:06 +01:00
Schuyler Cohen
11cb203daf Remove spurious format 2022-01-19 13:37:25 -06:00
Jonas Schievink
c714c139a4 Update tests
We're now omitting the libc crate's build script and const_fn test
2022-01-18 18:27:29 +01:00
Jonas Schievink
22ea5595a8 Don't load auxiliary crates outside the workspace 2022-01-18 18:17:43 +01:00
Wesley Norris
ba82cc7722 Add test for comments not directly next to items 2022-01-17 18:44:43 -05:00
Wesley Norris
7d10752299 Add a test for multi-single-line comments as well 2022-01-17 17:12:32 -05:00
Wesley Norris
1c866573cb fix: insert auto-imports after header comments
Fixes #8607.

This commit changes the auto-import functionality and causes it to add
imports after any leading comments, which are commonly license headers.
This does not affect comments on items as they're considered part of the
item itself and not separate.
2022-01-17 17:06:10 -05:00
Jonas Schievink
a3d06f824b status: output all crates a file belongs to 2022-01-17 18:10:01 +01:00
Jonas Schievink
8a7f0d920e Allow macros to expand to or-patterns 2022-01-17 16:52:53 +01:00
Laurențiu Nicola
c504518775 Temporarily disable format string completions 2022-01-17 09:30:35 +02:00
bors[bot]
e6e72809e3
Merge #11287
11287: fix: rust-analyzer spamming overly error message when workspace not being loaded r=lnicola a=Milo123459

Fixes #10120

Co-authored-by: Milo <50248166+Milo123459@users.noreply.github.com>
2022-01-16 15:13:52 +00: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