Commit graph

20888 commits

Author SHA1 Message Date
Jake Heinz 1c1d900d0b [ide_completion] render if a function is async/const/unsafe in completion details 2022-02-08 22:48:34 +00:00
bors[bot] 9b1978a3ed
Merge #11427
11427: add missing snake case attribute, update hash r=lnicola a=HansAuger

Fix for #11414 

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2022-02-07 07:51:13 +00:00
Moritz Vetter 482533ea9a add missing snake case attribute, update hash 2022-02-07 04:57:20 +01:00
bors[bot] ba33054802
Merge #11416
11416: Fix eslint language server not working r=Veykril a=jackos

Allows the language server for eslint to work inside VS Code.

Before change:
![image](https://user-images.githubusercontent.com/77730378/152661637-c5d90678-39dc-4018-b884-fc4b6135368e.png)

After change:
![image](https://user-images.githubusercontent.com/77730378/152661647-164c0655-aa6a-4c50-b49d-49cda112d149.png)

Co-authored-by: Jack Clayton <jackclayto@gmail.com>
2022-02-06 14:42:01 +00:00
bors[bot] 1dee488a68
Merge #11420
11420: fix two vulneabilities (moderate: 1, high: 1) by running npm audit r=lnicola a=HansAuger

Again me getting familiar with the code base :D

I noticed npm warning about two vulnerabilities
```
markdown-it  <12.3.2
Severity: moderate
Uncontrolled Resource Consumption in markdown-it - https://github.com/advisories/GHSA-6vfc-qv3f-vr6c
fix available via `npm audit fix`
node_modules/markdown-it
  vsce  1.26.0 - 2.6.3
  Depends on vulnerable versions of markdown-it
  node_modules/vsce

simple-get  3.0.0 - 3.1.0
Severity: high
Exposure of Sensitive Information in simple-get - https://github.com/advisories/GHSA-wpg7-2c88-r8xv
fix available via `npm audit fix`
node_modules/simple-get
```

So I thought why not run `npm audit fix` 

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2022-02-06 14:28:27 +00:00
Moritz Vetter 9f6c206ea0 fix two vulneabilities (moderate: 1, high: 1) by running npm audit 2022-02-06 15:23:48 +01:00
bors[bot] d2d137addd
Merge #11418
11418: fix: Update dependency, fix Markdown references r=Veykril a=HansAuger

Stumbled across this accidentally while familiarizing myself with the code base.

Update `pulldown-cmark-to-cmark` Fix for #11008  

Co-authored-by: Moritz Vetter <mv@3yourmind.com>
2022-02-06 08:54:34 +00:00
Moritz Vetter ba2ef69c79 Bump pulldown-cmark-to-cmark, adjust usages and fix test 2022-02-06 09:04:06 +01:00
Jack Clayton 76ecf9a17d Fix eslint errors 2022-02-06 06:52:51 +08:00
bors[bot] 668947056a
Merge #11415
11415: Downgrade `dashmap` and bump `thread_local` r=lnicola a=lnicola

Closes #11341

bors r+

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-02-05 14:21:40 +00:00
Laurențiu Nicola d0f371c80b Bump thread_local 2022-02-05 16:19:08 +02:00
Laurențiu Nicola 145e88ddfe Update lockfile 2022-02-05 16:17:12 +02:00
Laurențiu Nicola 39674cd350 Revert "Bump dashmap"
This reverts commit 485f318b70.
2022-02-05 16:15:56 +02:00
bors[bot] dd05d12055
Merge #11412
11412: fix: Include `fn`/`type`/`const` keyword in trait impl completion item source ranges r=Veykril a=The0x539

Fixes #11301

If the user has typed, say, `fn de` while implementing `Default`, or `type Ta` when implementing `Deref`, then the resulting completion suggestion will replace the entire "line", which, on its own, is fine.
However, the use of `ctx.source_range()` in this code was meant that `source_range` field of the `CompletionItem` covers only the identifier and not the preceding keyword.

Over in `rust_analyzer::to_proto::completion_item`, this caused the LSP completion response to be broken up into a text edit that replaces `de` with `fn default() -> Self {` and then an entry in `additional_text_edits` to remove the extra `fn`.
I'm pretty sure that using the field like that is (slightly) out of [spec](https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#completionItem):
> Edits must not overlap [...] with the main edit
> Additional text edits should be used to change text **unrelated to the current cursor position**

VS Code supports `additionalTextEdits` in such a way that this doesn't seem like a problem, so has gone largely unnoticed.
The various LSP clients I've tried, however, do not, and as a result this bug has been haunting me for ages.

Co-authored-by: The0x539 <the0x539@gmail.com>
2022-02-05 11:54:07 +00:00
The0x539 1536fc040a Fix trait impl completion ranges 2022-02-04 19:55:55 -06:00
bors[bot] 0feafe8185
Merge #11411
11411: minor: Simplify r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-04 13:36:34 +00:00
Lukas Wirth ec677e35d0 Simplify 2022-02-04 02:50:33 +01:00
bors[bot] 9597e55e9b
Merge #11406
11406: Update install notes for bundled servers r=stanciuadrian a=lnicola

r? `@stanciuadrian` 

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2022-02-03 20:11:18 +00:00
Laurențiu Nicola befaa874ac Update install notes 2022-02-03 21:54:23 +02:00
bors[bot] 6162d12890
Merge #11403
11403: internal: Shrink `mbe::ExpandError` and `mbe::ParseError` r=Veykril a=Veykril

Also fixes https://github.com/rust-analyzer/rust-analyzer/issues/10051, as we no longer emit an empty diagnostic in some expansion cases which seems to trip up vscode for some reason. Using `compile_error!("")` will still trigger the vscode bug.
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-03 16:30:01 +00:00
Lukas Wirth 2ad71f1350 Shrink mbe::ExpandError and mbe::ParseError 2022-02-03 17:25:24 +01:00
bors[bot] 6ef6fa019c
Merge #11402
11402: fix: Fix vis restriction path completions always using the parent module r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-03 16:02:51 +00:00
Lukas Wirth 2310908df7 fix: Fix vis restriction path completions always using the parent module 2022-02-03 17:02:12 +01:00
bors[bot] d6329f2171
Merge #11401
11401: Sort completion calls lexicographically r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-03 15:38:45 +00: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
bors[bot] 5a7e11f5fb
Merge #11397
11397: internal: Refactor completion module split r=Veykril a=Veykril

Currently our completion infra is split into several modules, each trying to do completions for something specific. This "something" is rather unstructured as it stands now, we have a module for `flyimporting path` completions, `unqualified` and `qualified path` completions, modules for `pattern position` completions that only try to complete extra things for patterns that aren't done in the path modules, `attribute` completions that again only try to add builtin attribute completions without adding the normal path completions and a bunch of other special "entity" completions like lifetimes, method call/field access, function param cloning, ... which serve a more specific purpose than the previous listed ones.

As is evident, the former mentioned ones have some decent overlap which requires extra filtering in them so that they don't collide with each other duplicating a bunch of completions(which we had happen in the past at times).

Now this overlap mostly happens with path completions(and keyword completions as well in some sense) which gives me the feeling that having `qualified` and `unqualified` path completions be separate from the rest gives us more troubles than benefits in the long run.
So this is an attempt at changing this structure to instead still go by rough entity for special cases, but when it comes to paths we instead do the module split on the "path kinds"/"locations"(think pattern, type, expr position etc) that exist. This goes hand in hand with the test refactoring I have done that moved tests to "location oriented" modules as well as the `CompletionContext` refactoring that actually already started splitting the context up for path kinds.

This PR moves some path completions out of the `qualified` and `unqualified` path modules namely attribute, visibility, use and pattern paths.

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-03 15:01:08 +00: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
bors[bot] 46b5089bfa
Merge #11399
11399: Fix assoc type shorthand from method bounds r=flodiebold a=flodiebold

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).

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2022-02-03 12:21:18 +00: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
bors[bot] 498224af18
Merge #11393
11393: fix: Complete functions and methods from block level impls r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 22:48:34 +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
bors[bot] 5ee21fee9c
Merge #11391
11391: minor: Add some debug traces for cfg fetching r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 12:35:52 +00:00
Lukas Wirth dbd5a70ea3 minor: Add some debug traces for cfg fetching 2022-02-01 13:35:34 +01:00
bors[bot] 9b88956bd5
Merge #11390
11390: fix: Deprioritize ops function completions for non-method calls r=Veykril a=Veykril

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2022-02-01 11:34:40 +00:00