Commit graph

9554 commits

Author SHA1 Message Date
Aleksey Kladov
7623db1106 minor clenup 2020-04-25 19:30:00 +02:00
bors[bot]
5671bacfa6
Merge #4139
4139: Add check for rules that no repetition which could match an empty token r=matklad a=edwin0cheng

Fix #4103

for `/ui/issues/issue-57597.rs`

This is `ParseError` of the macro rules , because it is how rustc handle it : 

a58b1ed44f/src/librustc_expand/mbe/macro_rules.rs (L558)


Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-25 16:26:51 +00:00
bors[bot]
67afeebaf5
Merge #4137
4137: Prefer core/alloc paths on #![no_std] r=matklad a=jonas-schievink



Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-04-25 16:19:21 +00:00
Edwin Cheng
d5eb43f246 Checks no repetition for an empty token 2020-04-25 23:30:10 +08:00
bors[bot]
fc57358efd
Merge #4133
4133: main: eagerly prime goto-definition caches r=matklad a=BurntSushi

This commit eagerly primes the caches used by goto-definition by
submitting a "phantom" goto-definition request. This is perhaps a bit
circuitous, but it does actually get the job done. The result of this
change is that once RA is finished its initial loading of a project,
goto-definition requests are instant. There don't appear to be any more
surprise latency spikes.

This _partially_ addresses #1650 in that it front-loads the latency of the
first goto-definition request, which in turn makes it more predictable and
less surprising. In particular, this addresses the use case where one opens
the text editor, starts reading code for a while, and only later issues the
first goto-definition request. Before this PR, that first goto-definition request
is guaranteed to have high latency in any reasonably sized project. But
after this PR, there's a good chance that it will now be instant.

What this _doesn't_ address is that initial loading time. In fact, it makes it
longer by adding a phantom goto-definition request to the initial startup
sequence. However, I observed that while this did make initial loading
slower, it was overall a somewhat small (but not insignificant) fraction
of initial loading time.

-----

At least, the above is what I _want_ to do. The actual change in this PR is just a proof-of-concept. I came up with after an evening of printf-debugging. Once I found the spot where this cache priming should go, I was unsure of how to generate a phantom input. So I just took an input I knew worked from my printf-debugging and hacked it in. Obviously, what I'd like to do is make this more general such that it will always work.

I don't know whether this is the "right" approach or not. My guess is that there is perhaps a cleaner solution that more directly primes whatever cache is being lazily populated rather than fudging the issue with a phantom goto-definition request.

I created this as a draft PR because I'd really like help making this general. I think whether y'all want to accept this patch is perhaps a separate question. IMO, it seems like a good idea, but to be honest, I'm happy to maintain this patch on my own since it's so trivial. But I would like to generalize it so that it will work in any project.

My thinking is that all I really need to do is find a file and a token somewhere in the loaded project, and then use that as input. But I don't quite know how to connect all the data structures to do that. Any help would be appreciated!

cc @matklad since I've been a worm in your ear about this problem. :-)

Co-authored-by: Andrew Gallant <jamslam@gmail.com>
2020-04-25 14:30:10 +00:00
Jonas Schievink
3cf2c3b943 Prefer core/alloc paths on #![no_std] 2020-04-25 16:27:34 +02:00
Andrew Gallant
0c12b7e8c8
main: fix bug where thread pool isn't joined
Pointed out here:
https://github.com/rust-analyzer/rust-analyzer/pull/4133#issuecomment-619386272
2020-04-25 10:26:33 -04:00
Benjamin Coenen
b87b335e68 add support for cfg feature attributes on expression #4063
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
2020-04-25 15:48:04 +02:00
Andrew Gallant
c1a31d4261
main: eagerly prime goto-definition caches
This commit makes RA more aggressive about eagerly priming the caches.
In particular, this fixes an issue where even after RA was done priming
its caches, an initial goto-definition request would have very high
latency. This fixes that issue by requesting syntax highlighting for
everything. It is presumed that this is a tad wasteful, but not overly
so.

This commit also tweaks the logic that determines when the cache is
primed. Namely, instead of just priming it when the state is loaded
initially, we attempt to prime it whenever some state changes. This
fixes an issue where if a modification notification is seen before cache
priming is done, it would stop the cache priming early.
2020-04-25 09:28:34 -04:00
bors[bot]
05981823ba
Merge #4135
4135: Rename StructField -> Field r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-25 12:25:28 +00:00
Aleksey Kladov
970dbf8717 Rename StructField -> Field 2020-04-25 14:23:34 +02:00
bors[bot]
7bc7173230
Merge #4134
4134: Special case for empty comments in doc comment kind  r=matklad a=edwin0cheng

Part of #4103

Fix `ui/empty/empty-comment.rs macros`

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-25 10:53:40 +00:00
Edwin Cheng
f0fece4be0 Fix whitespaces 2020-04-25 18:49:46 +08:00
bors[bot]
f654f49435
Merge #4125
4125: Avoid lossy OsString conversions r=matklad a=lnicola

This is a bit invasive, and perhaps for not much benefit since non-UTF-8 environment variables don't work anyway.

Co-authored-by: Laurențiu Nicola <lnicola@dend.ro>
2020-04-25 10:35:14 +00:00
bors[bot]
29fc409e7f
Merge #4131
4131: Switch to text-size r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-25 10:16:02 +00:00
Aleksey Kladov
e873469500 text-size 1.0.0 2020-04-25 12:15:32 +02:00
Aleksey Kladov
63a462f37c Switch to TryFrom 2020-04-25 11:59:18 +02:00
Aleksey Kladov
dc2151085e Cleanups 2020-04-25 11:59:18 +02:00
Aleksey Kladov
8843588fca Convert tests to text-size 2020-04-25 11:59:18 +02:00
Aleksey Kladov
b1d5817dd1 Convert code to text-size 2020-04-25 11:59:18 +02:00
Edwin Cheng
d20eea073e Special case for empty comments 2020-04-25 17:37:34 +08:00
Laurențiu Nicola
58dde891f8 Avoid lossy OsString conversions 2020-04-25 12:19:23 +03:00
bors[bot]
27a7718880
Merge #4128
4128: Include correct item path for variant completions r=matklad a=jonas-schievink

The test would previously suggest `E::V`, which is not enough to name the variant as the enum is in a module. Now it correctly suggests the full path `m::E::V`.

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-04-24 21:11:19 +00:00
bors[bot]
57b3dda980
Merge #4129
4129: Don't print cargo version to stdout, breaking everything r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-24 21:03:46 +00:00
Aleksey Kladov
aa669c5ba5 Don't print cargo version to stdout, breaking everything 2020-04-24 23:02:10 +02:00
Jonas Schievink
e131763fb8 Include correct item path for variant completions 2020-04-24 22:18:59 +02:00
bors[bot]
51a0058d4c
Merge #3998 #4006
3998: Make add_function generate functions in other modules via qualified path r=matklad a=TimoFreiberg

Additional feature for #3639 

- [x] Add tests for paths with more segments
- [x] Make generating the function in another file work
- [x] Add `pub` or `pub(crate)` to the generated function if it's generated in a different module
- [x] Make the assist jump to the edited file
- [x] Enable file support in the `check_assist` helper

4006: Syntax highlighting for format strings r=matklad a=ltentrup

I have an implementation for syntax highlighting for format string modifiers `{}`.
The first commit refactors the changes in #3826 into a separate struct.
The second commit implements the highlighting: first we check in a macro call whether the macro is a format macro from `std`. In this case, we remember the format string node. If we encounter this node during syntax highlighting, we check for the format modifiers `{}` using regular expressions.

There are a few places which I am not quite sure:
- Is the way I extract the macro names correct?
- Is the `HighlightTag::Attribute` suitable for highlighting the `{}`?

Let me know what you think, any feedback is welcome!

Co-authored-by: Timo Freiberg <timo.freiberg@gmail.com>
Co-authored-by: Leander Tentrup <leander.tentrup@gmail.com>
Co-authored-by: Leander Tentrup <ltentrup@users.noreply.github.com>
2020-04-24 20:10:54 +00:00
bors[bot]
e55b1833ff
Merge #4127
4127: More helpful error message if toolchain is not in PATH r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-24 20:03:33 +00:00
Aleksey Kladov
6c400b3e33 More helpful error message if toolchain is not in PATH 2020-04-24 22:01:32 +02:00
bors[bot]
bdd22eb8bd
Merge #4126
4126: Don't omit methods with self from path completion r=matklad a=jonas-schievink

It's sometimes useful to create a reference to these items (eg. for use as a function pointer). Perhaps these should be given lower score though, if that's possible?

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
2020-04-24 19:57:24 +00:00
Jonas Schievink
7b9553a703 Don't omit methods with self from path completion 2020-04-24 21:46:18 +02:00
bors[bot]
5d97667f8d
Merge #4105
4105: Adds attribute completions (#3941) r=matklad a=jrvidal

I've hacked together some basic completions for a few builtin attributes.

* I have no idea what `CompletionItemKind` we should set for them.
* There's plenty of fancy stuff we could do by detecting the item the attribute is being added to. Nothing of that here.
* Maybe we could complete as soon as you type `#` or `#!`?

I'm not sure what info exactly we can dump on `CompletionContext` and what we should query during the completion calculation itself. I've assumed adding an `is_attribute` field is OK, since it allows to discard the completion quickly if it doesn't apply. Later we inspect the AST to find out whether it is an inner attribute or not.

Co-authored-by: Roberto Vidal <vidal.roberto.j@gmail.com>
2020-04-24 16:05:16 +00:00
Roberto Vidal
0dab5d5879 Adds attribute completions (#3941) 2020-04-24 17:54:52 +02:00
kjeremy
0619c67ac6 Support returning non-hierarchical symbols
If `hierarchicalDocumentSymbolSupport` is not true in the client capabilites
then it does not support the `DocumentSymbol[]` return type from the
`textDocument/documentSymbol` request and we must fall back to `SymbolInformation[]`.

This is one of the few requests that use the client capabilities to
differentiate between return types and could cause problems for clients.

See https://github.com/microsoft/language-server-protocol/pull/538#issuecomment-442510767 for more context.

Found while looking at #144
2020-04-24 10:11:57 -04:00
kjeremy
ae1f77e5e9 Add hierarchical symbols client capability 2020-04-24 10:08:45 -04:00
bors[bot]
edd6f91cab
Merge #4121
4121: Better label for macros completion r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-24 11:29:44 +00:00
Aleksey Kladov
62e08fa53d Better label for macros completion 2020-04-24 13:25:37 +02:00
bors[bot]
44e6c2cb54
Merge #4101
4101: Panic proc macro srv if read request failed r=matklad a=edwin0cheng

This PR fixed a bug when the rust-analyzer is killed suddenly, the `rust-analyzer proc-macro` will become stale.

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-04-24 01:28:53 +00:00
Edwin Cheng
a83d1743a5 Refactor a bit 2020-04-24 09:27:37 +08:00
bors[bot]
ffba39aca0
Merge #4118
4118: ⬆️ crates (to bust the caches) r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-24 00:58:44 +00:00
Aleksey Kladov
aa9a9d7ac5 ⬆️ crates (to bust the caches) 2020-04-24 02:58:21 +02:00
bors[bot]
7410cfad21
Merge #4117
4117: Honor snippet capability r=matklad a=matklad

closes #2518



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-24 00:45:34 +00:00
Aleksey Kladov
440cd05edb Honor snippet capability
closes #2518
2020-04-24 02:41:07 +02:00
bors[bot]
3a0a7081f4
Merge #4116
4116: Make sure that adding a snippet requires corresponding capability r=matklad a=matklad



bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-24 00:27:38 +00:00
Aleksey Kladov
5fd5de4061 Make sure that adding a snippet requires corresponding capability 2020-04-24 02:26:38 +02:00
Aleksey Kladov
b3050bded1 Introduce internal snippet cap 2020-04-24 02:06:12 +02:00
Aleksey Kladov
bd3b239390 Move CompletionConfig to a separate module 2020-04-24 02:01:23 +02:00
bors[bot]
601f89f2cb
Merge #4114
4114: Refactor completion sorting r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-04-23 23:54:21 +00:00
Aleksey Kladov
88d243c742 Don't set sortText
I might be reading this wrong, but it looks like we are setting it to
essentially arbitrary string at the moment, as there are no defined
order on the items in the *set* of completions.
2020-04-24 01:53:37 +02:00
Aleksey Kladov
647683b9bb Add test marks 2020-04-24 01:48:32 +02:00