Commit graph

551 commits

Author SHA1 Message Date
Aleksey Kladov
eec68e6f45
Merge pull request #2297 from kiljacken/master
Add fancy truncation of type hints.
2019-11-20 08:38:25 +03:00
Emil Lauridsen
dadad36bb9 Move type inlay hint truncation to language server
This commit implements a general truncation framework for HirFormatter
that keeps track of how much has been output so far. This information
can then be used to perform truncation inside the language server,
instead of relying on the client.

Initial support is implemented for truncating types hints using the
maxInlayHintLength server config option. The existing solution in the
VSCode extension has been removed in favor of letting the server
truncate type hints.
2019-11-19 17:23:50 +01:00
Edwin Cheng
4012da07fd Change return type of expand_macro 2019-11-19 22:56:48 +08:00
Edwin Cheng
3ccd05fedc Add recursive expand in vscode 2019-11-19 21:49:06 +08:00
Aleksey Kladov
7e2f4b30db Disable doctests 2019-11-17 18:35:05 +03:00
kjeremy
91b154fa05 Update crates
Removes nodrop and extra arrayvec

We have an extra crossbeam-queue and crossbeam-utils left but those should
drop once rayon accepts https://github.com/rayon-rs/rayon/pull/704
2019-11-07 13:05:12 -05:00
Martin Asquino
ccf8817d18 Use bool instead of Option<bool> and print it's value only when true 2019-11-02 19:33:34 -03:00
Martin Asquino
dc3848a6a3 Set deprecated field on CompletionItems 2019-11-02 17:37:47 -03:00
kjeremy
b441b4e8ef Some clippy fixes 2019-10-30 13:36:37 -04:00
kjeremy
3c140050ff Profile all request handlers 2019-10-29 16:08:36 -04:00
Aleksey Kladov
d5cd8b5be2 disable the new typing handler for ->
It doesn't actually work with LSP
2019-10-25 13:03:57 +03:00
Aleksey Kladov
53e3bee0cf insert space after -> 2019-10-25 12:41:34 +03:00
Aleksey Kladov
8d2fd59cfb make typing infra slightly more extensible 2019-10-25 11:30:46 +03:00
Aleksey Kladov
dc65219ae1 document feature flags 2019-10-25 09:00:30 +03:00
Aleksey Kladov
4529da906d for highlighting, search only the current file 2019-10-24 14:16:36 +03:00
Aleksey Kladov
418fbc8662 don't die if a sync task panics 2019-10-24 09:56:30 +03:00
Aleksey Kladov
f5bf7f29b5 add couple of profiling calls 2019-10-23 18:26:43 +03:00
Ekaterina Babshukova
93c179531b fix highlighting 2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
d26d0ada50 restructure a bit 2019-10-22 23:47:31 +03:00
Ekaterina Babshukova
79e6b3b0d1 make handle_references accept refs from other files 2019-10-22 23:47:31 +03:00
Alex Zatelepin
6d105ccd93 add test #2033 2019-10-21 22:34:44 +03:00
Alex Zatelepin
9d5e932626 fixup folding ranges for "lineFoldingOnly" clients #2033 2019-10-21 21:35:42 +03:00
kjeremy
c3045c68a9 relative-path 1.0 2019-10-17 13:08:33 -04:00
bors[bot]
84d9fd1864
Merge #1998
1998: No need to make config pub r=matklad a=kjeremy

Just a drive by

Co-authored-by: kjeremy <kjeremy@gmail.com>
2019-10-17 11:10:25 +00:00
Shotaro Yamada
5ca6281164 Remove unused dependencies 2019-10-12 08:00:54 +09:00
kjeremy
04963fa14d No need to make config pub 2019-10-11 15:13:15 -04:00
Aleksey Kladov
355419d404 use slightly more idiomatic api for cfg 2019-10-08 14:22:49 +03:00
oxalica
c6303d9fee
Use raw cfgs in json project and fix typo 2019-10-05 20:55:27 +08:00
uHOOCCOOHu
1067a1c5f6
Read default cfgs from rustc 2019-10-03 02:28:03 +08:00
Alexander Andreev
fdbd6bb11a Added test for check doc strings in crates.
#1856
2019-09-30 11:58:53 +03:00
Aleksey Kladov
d847d53e36 Start simplifying editing API 2019-09-26 22:22:08 +03:00
Aleksey Kladov
36732a42bd move fold conversino to conv.rs 2019-09-19 18:27:47 +03:00
Aleksey Kladov
184e80007b fix typo 2019-09-19 18:18:58 +03:00
Aleksey Kladov
ef2b84ddf1 introduce hir debugging infra
This is to make debugging rust-analyzer easier.

The idea is that `dbg!(krate.debug(db))` will print the actual, fuzzy
crate name, instead of precise ID. Debug printing infra is a separate
thing, to make sure that the actual hir doesn't have access to global
information.

Do not use `.debug` for `log::` logging: debugging executes queries,
and might introduce unneded dependencies to the crate graph
2019-09-09 12:32:16 +03:00
Aleksey Kladov
219287a14c don't deadlock on shutdown
Specifically, when we tear down IO threads, we should take care to
dispose connection.

closes #1775
2019-09-06 20:58:21 +03:00
Aleksey Kladov
28df377759 add option to disable notify 2019-09-06 17:21:29 +03:00
Aleksey Kladov
33965f0f3e fix renaming of modules 2019-09-05 21:36:40 +03:00
kjeremy
cb063a9b30 lsp-types 0.61.0 2019-09-03 10:50:39 -04:00
Aleksey Kladov
4e3f5cc729 cleanup main loop 2019-08-31 14:47:37 +03:00
Aleksey Kladov
983de30a56 inline thread-worker 2019-08-30 20:32:59 +03:00
Aleksey Kladov
7cc14a7596 ⬆️ lsp-server 2019-08-30 20:18:57 +03:00
Aleksey Kladov
72a3722470 move lsp-server to a separate repository 2019-08-30 17:24:11 +03:00
Aleksey Kladov
ee932d464b ⬆️ vfs 2019-08-25 13:13:08 +03:00
Aleksey Kladov
5b18a4eef9 rename struct -> record, pos -> tuple 2019-08-23 16:59:50 +03:00
Aleksey Kladov
69bbe79c50 implement feature flags 2019-08-22 15:07:31 +03:00
Aleksey Kladov
4dd5afb7fe show error to the user when deserializing config 2019-08-22 11:08:22 +03:00
Aleksey Kladov
6ab85cc192 fix default for the exlude key 2019-08-21 17:30:58 +03:00
Aleksey Kladov
77751cfe01 remove debug-print 2019-08-20 19:55:34 +03:00
Aleksey Kladov
bbeb07e5ca switch to upstream ra_vfs 2019-08-20 19:53:05 +03:00
Aleksey Kladov
188c9967c0 Drop unnecessary &'_ from impls 2019-08-20 19:53:05 +03:00
Aleksey Kladov
4753409f86 refactor TryConvWith similar to ConvWith 2019-08-20 19:53:05 +03:00
Aleksey Kladov
6ea4184fd1 translate \n -> \r\n on the way out 2019-08-20 19:53:05 +03:00
Aleksey Kladov
80a6e61446 make CTX type param instead of assoc type
that way, we can implement ConvWith<&'_ CTX> for different lifetimes
2019-08-20 19:53:05 +03:00
Aleksey Kladov
de3f2948ea add tests for crlf 2019-08-20 19:53:05 +03:00
Aleksey Kladov
ccca427ce4 minor 2019-08-20 19:53:05 +03:00
Aleksey Kladov
7cd9b1dd7a don't load sysroot in most heavy tests 2019-08-19 15:41:18 +03:00
Aleksey Kladov
64ecba4f15 update lsp 2019-08-17 22:21:59 +03:00
Aleksey Kladov
343463c824 implement durability 2019-08-15 15:27:00 +03:00
Aleksey Kladov
13eddd7c49 Drop support for old extendSelection API
Emacs now handles this via native LSP request

dc86bbb227
2019-08-12 13:49:28 +03:00
Kirill Bulatov
2c5c35bdae Always set the runnable name 2019-08-09 23:34:14 +03:00
Kirill Bulatov
726535a44e Extract common logic 2019-08-09 22:19:34 +03:00
Kirill Bulatov
918addee23 Show backtraces in lens runnables 2019-08-09 21:42:04 +03:00
bors[bot]
7e12422fa2 Merge #1652
1652: Improve type hints behavior r=matklad a=SomeoneToIgnore

This PR fixed the following type hints issues:

* Restructures the `InlayKind` enum contents based on the discussion here: https://github.com/rust-analyzer/rust-analyzer/pull/1606#issuecomment-515968055
* Races described in #1639 
* Caches the latest decorations received for each file to show them the next time the file is opened (instead of a new server request)

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2019-08-06 16:50:49 +00:00
Aleksey Kladov
3d45da9bca fix tests 2019-08-06 14:41:22 +02:00
Aleksey Kladov
deea8f52d9 allow to exclude certain files and directories 2019-08-06 14:28:31 +02:00
Aleksey Kladov
f70b7e1f07 rename config 2019-08-06 14:28:31 +02:00
Aleksey Kladov
34203256bf introduce ra_vfs_glob crate
It manages exclusion rules for the vfs crate
2019-08-06 14:28:31 +02:00
Aleksey Kladov
d751bd08bf cleanup 2019-08-06 10:57:16 +02:00
Aleksey Kladov
0e4a542cfb rename 2019-08-06 10:50:32 +02:00
Aleksey Kladov
27303da419 use Conv for severity 2019-08-06 09:50:00 +02:00
Kirill Bulatov
15411d4474 Use proper inlay kinds 2019-08-05 00:28:36 +03:00
Jeremy Kolb
e99d3da6c2 Add test for #1540 2019-08-03 18:01:48 -04:00
kjeremy
8da8c147ee remove-comment 2019-07-31 11:53:47 -04:00
kjeremy
4fccad9b2c Add explicit newline preserving tests 2019-07-31 10:46:15 -04:00
Roman Stoliar
facc7a35a5 Fixed review comments 2019-07-30 21:25:51 +03:00
Roman Stoliar
1c11d7b1d8 Hide comments in rust section of doc comments 2019-07-30 03:46:38 +03:00
Kirill Bulatov
b8f95f42e1 Support destructuring patterns 2019-07-29 00:33:10 +03:00
Kirill Bulatov
5169a9d498 Improve inlay hinting for types
Add hints for types in for loop expressions.
Resolve types for every tuple parameter.
Refactor the code.
2019-07-26 18:06:31 +03:00
Kirill Bulatov
dbbb0beb3e Make Analysis api cancellable 2019-07-25 20:22:41 +03:00
bors[bot]
5f3ff157e3 Merge #1549
1549: Show type lenses for the resolved let bindings r=matklad a=SomeoneToIgnore

Types that are fully unresolved are not displayed:

<img width="279" alt="image" src="https://user-images.githubusercontent.com/2690773/61518122-8e4ba980-aa11-11e9-9249-6d9f9b202e6a.png">

A few concerns that I have about the current implementation:

* I've adjusted the `file_structure` API method to return the information about the `let` bindings.
Although it works fine, I have a feeling that adding a new API method would be the better way.
But this requires some prior discussion, so I've decided to go for an easy way with an MVP. 
Would be nice to hear your suggestions.

* There's a hardcoded `{undersolved}` check that I was forced to use, since the method that resolves types returns a `String`. 
Is there a better typed API I can use? This will help, for instance, to add an action to the type lenses that will allow us to navigate to the type.

Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
2019-07-23 09:51:40 +00:00
Kirill Bulatov
8f3377d9f9 Code review fixes 2019-07-22 23:25:13 +03:00
kjeremy
ce77291ca4 flexi_logger 0.14 2019-07-22 13:13:55 -04:00
Kirill Bulatov
ba76017d2e Do not show the lens with type hints 2019-07-21 23:48:54 +03:00
Kirill Bulatov
09c7c86696 Resolve types on the server 2019-07-21 23:44:37 +03:00
Kirill Bulatov
201b344f2b Refactor server api 2019-07-20 23:45:26 +03:00
Kirill Bulatov
b6c662c573 If possible, show type lenses for the let bindings 2019-07-20 21:39:04 +03:00
Kirill Bulatov
1037242e6e Add "Run" lens for binary runnables 2019-07-16 15:02:11 +03:00
kjeremy
1fcc002677 cargo update 2019-07-15 15:07:11 -04:00
Michael Bolin
e81a47b8eb Remove executeCommandProvider: apply_code_action.
This appears to have been introduced ages ago in
be742a5877
but has since been removed.

As it stands, it is problematic if multiple instances of the
rust-analyzer LSP are launched during the same VS Code session because
VS Code complains about multiple LSP servers trying to register the
same command.

Most LSP servers workaround this by parameterizing the command by the
process id. For example, this is where `rls` does this:

ff0b9057c8/rls/src/server/mod.rs (L413-L421)

Though `apply_code_action` does not seems to be used, so it seems better
to delete it than to parameterize it.
2019-07-10 22:49:35 -07:00
Michael Bolin
a814883cd4 Ignore workspace/didChangeConfiguration notifications. 2019-07-10 20:56:16 -07:00
Shotaro Yamada
a426de60ad Remove unused dependencies 2019-07-09 00:28:00 +09:00
Aleksey Kladov
e075e096cf don't send LocationLink unless the client opts-in
closes #1474
2019-07-08 14:09:38 +03:00
Aleksey Kladov
b042faeb64 simplify 2019-07-08 13:47:02 +03:00
Aleksey Kladov
227bc0b6d4 add try_conv_with_to_vec 2019-07-08 13:39:16 +03:00
Jeremy Kolb
9c6e93cd6c Simplify responses by using into() 2019-07-07 17:28:21 -04:00
Jeremy Kolb
3f44aaf363 use flatten branch of lsp-types 2019-07-07 14:13:13 -04:00
Jeremy Kolb
9438bbc75a Formatting again 2019-07-04 19:31:06 -04:00
Jeremy Kolb
b4c0c7f79c Symplify by using into() 2019-07-04 19:08:08 -04:00
Jeremy Kolb
e7fb6c83cc Formatting 2019-07-04 17:43:19 -04:00
Jeremy Kolb
4ad9e986ad Some clippy fixes for 1.36 2019-07-04 17:43:00 -04:00
Jeremy Kolb
a394c04bca Fix formatting 2019-07-04 16:58:52 -04:00
Jeremy Kolb
ad4276ac05 Change default() 2019-07-04 16:57:52 -04:00
Jeremy Kolb
9bfdab7089 Update to lsp-types 0.58.0 2019-07-04 16:57:52 -04:00
Aleksey Kladov
1834bae5b8 allow rustfmt to reorder imports
This wasn't a right decision in the first place, the feature flag was
broken in the last rustfmt release, and syntax highlighting of imports
is more important anyway
2019-07-04 23:09:09 +03:00
Aleksey Kladov
18a1e092e9 Move memory usage statistics to ra_prof 2019-06-30 13:30:17 +03:00
Ryan Cumming
e052ca9d61 Swallow expected rustfmt errors
My workflow in Visual Studio Code + Rust Analyzer has become:

1. Make a change to Rust source code using all the analysis magic

2. Save the file to trigger `cargo watch`. I have format on save enabled
   for all file types so this also runs `rustfmt`

3. Fix any diagnostics that `cargo watch` finds

Unfortunately if the Rust source has any syntax errors the act of saving
will pop up a scary "command has failed" message and will switch to the
"Output" tab to show the `rustfmt` error and exit code.

I did a quick survey of what other Language Servers do in this case.
Both the JSON and TypeScript servers will swallow the error and return
success. This is consistent with how I remember my workflow in those
languages. The syntax error will show up as a diagnostic so it should
be clear why the file isn't formatting.

I checked the `rustfmt` source code and while it does distinguish "parse
errors" from "operational errors" internally they both result in exit
status of 1. However, more catastrophic errors (missing `rustfmt`,
SIGSEGV, etc) will return 127+ error codes which we can distinguish from
a normal failure.

This changes our handler to log an info message and feign success if
`rustfmt` exits with status 1.

Another option I considered was only swallowing the error if the
formatting request came from format-on-save. However, the Language
Server Protocol doesn't seem to distinguish those cases.
2019-06-27 08:08:26 +10:00
kjeremy
f8f136e990 Bump cargo_metadata, ena, flexi_logger 2019-06-20 15:09:39 -04:00
Aleksey Kladov
b0be4207d0 reuse AnalysisHost in batch analysis 2019-06-15 16:29:23 +03:00
Aleksey Kladov
24703acf26 re-enable backtraces on panic 2019-06-15 12:58:17 +03:00
Muhammad Mominul Huque
ebb40c7f87
cargo format 2019-06-15 13:37:15 +06:00
Muhammad Mominul Huque
9709bd39ca
Get rid of failure: ra_lsp_server & ra_project_model 2019-06-15 02:42:56 +06:00
Aleksey Kladov
d32e15cae6 Temp fix for slow onEnter issue
The issue was windows specific -- cancellation caused collection of
bracktraces at some point, and that was slow on windows.

The proper fix here is to make sure that we don't collect bracktraces
unnecessary (which we currently do due to failure), but, as a
temporary fix, let's just not force their collection in the first
place!
2019-06-13 21:29:44 +03:00
Aleksey Kladov
fed52706de make LRU cache configurable 2019-06-12 13:36:24 +03:00
Aleksey Kladov
33026c654e make Docs handing more ideomatic 2019-06-08 14:16:05 +03:00
Alan Du
b28ca32db2 Fix clippy::or_fun_call 2019-06-04 18:05:07 -04:00
Alan Du
40424d4222 Fix clippy::identity_conversion 2019-06-04 18:05:07 -04:00
Alan Du
7bcd8d6290 Fix clippy::unused_mut 2019-06-04 18:05:07 -04:00
Alan Du
6095e3fe19 Fix clippy::unnecessary_mut_passed 2019-06-04 18:05:07 -04:00
Alan Du
ecd420636e Fix clippy::single_match 2019-06-04 18:05:07 -04:00
Aleksey Kladov
bf801953a3 rename 2019-06-01 10:31:40 +03:00
Aleksey Kladov
678a458543 move subs inside 2019-06-01 10:24:43 +03:00
Aleksey Kladov
78e17f65cf use sync queries for join lines and friends 2019-05-31 20:53:00 +03:00
Aleksey Kladov
c6537c3280 add sync requests 2019-05-31 20:50:16 +03:00
Aleksey Kladov
9697d8afad cleanup 2019-05-31 20:42:53 +03:00
Aleksey Kladov
15efd58274 cleanup 2019-05-31 20:30:14 +03:00
Aleksey Kladov
2d773a46c9 simplify 2019-05-31 20:23:56 +03:00
Aleksey Kladov
e1bda6aeda move completed requests to a separate file 2019-05-31 20:14:54 +03:00
Aleksey Kladov
838915c9a2 simplify 2019-05-31 19:24:33 +03:00
Aleksey Kladov
8bb02859e8 introduce constant 2019-05-31 19:20:22 +03:00
Aleksey Kladov
0e542936be minor 2019-05-31 19:17:46 +03:00
Aleksey Kladov
b6a854e161 update ra_ide_api to use builtins 2019-05-30 16:10:07 +03:00
Aleksey Kladov
18ed351747 ⬆️ parking_lot 2019-05-30 12:02:30 +03:00
Aleksey Kladov
9304cb0263 bump timeout for CI 2019-05-29 22:14:06 +03:00
Aleksey Kladov
a9373c4220 less noisy status 2019-05-29 21:07:38 +03:00
Aleksey Kladov
5c410385fc optimization: cancel backlog in onEnter 2019-05-29 16:05:14 +03:00
Aleksey Kladov
2c9a1cb3dd add latest requests to status page 2019-05-29 15:47:46 +03:00
Aleksey Kladov
e45c350a3b log the actual time of requests 2019-05-29 14:59:01 +03:00
Aleksey Kladov
118a2113c1 trigger garbage collection *after* requests, not before 2019-05-29 14:37:04 +03:00
Aleksey Kladov
6a1e3e59cb more perf logging 2019-05-29 14:34:21 +03:00
Aleksey Kladov
a6f1b171bc silnce profiling in tests 2019-05-29 10:33:47 +03:00
bors[bot]
b2bf41b2ba Merge #1334
1334: check for cancellation during macro expansion r=matklad a=matklad

closes #1331

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2019-05-27 11:45:41 +00:00
Aleksey Kladov
a2845bb1f5 check cancellation when expanding macros 2019-05-27 14:41:14 +03:00
Aleksey Kladov
cf214ac4e7 enable profiling in tests 2019-05-27 14:20:11 +03:00
Pascal Hertleif
4ac338b608
rename stray id field 2019-05-27 11:26:35 +02:00
Pascal Hertleif
5abcca516d
make it build again 2019-05-27 11:26:35 +02:00
Pascal Hertleif
5bf3e949e8
Semantic highlighting spike
Very simple approach: For each identifier, set the hash of the range
where it's defined as its 'id' and use it in the VSCode extension to
generate unique colors.

Thus, the generated colors are per-file. They are also quite fragile,
and I'm not entirely sure why. Looks like we need to make sure the
same ranges aren't overwritten by a later request?
2019-05-27 11:26:33 +02:00
Aleksey Kladov
ce040aa907 add profile calls to real-time requests 2019-05-27 11:48:23 +03:00
Lenard Pratt
8198e13c26 Added local macro goto 2019-05-04 17:39:51 +01:00
kjeremy
7125192c1e Basic resolution for ADT 2019-04-23 14:32:47 -04:00
Aleksey Kladov
47672726d8 ⬆️ lsp 2019-04-21 15:17:22 +03:00