Commit graph

4815 commits

Author SHA1 Message Date
Aleksey Kladov
16cfc8d50c Cache source for generics 2020-01-16 16:44:25 +01:00
Aleksey Kladov
7aa627fe58 Move more stuff to SourceBinder 2020-01-16 16:37:51 +01:00
Edwin Cheng
ed8d5c86e3 Fix array element attribute position 2020-01-16 23:37:43 +08:00
Aleksey Kladov
a3d6ddbe69 More natural trait setup 2020-01-16 16:27:21 +01:00
Aleksey Kladov
8691ae8ac0 Removed FromSource 2020-01-16 16:16:31 +01:00
Aleksey Kladov
81a45ca1b3 Make FromSource private 2020-01-16 16:08:46 +01:00
Aleksey Kladov
272f6dfd9e Micro-optimize type hints to avoid allocations 2020-01-16 14:31:34 +01:00
Aleksey Kladov
bd96d0b258 Minimize visibility 2020-01-16 11:58:31 +01:00
Joshua Nelson
c78e34968f
shrink inline tes 2020-01-15 19:12:56 -05:00
Veetaha
a24dcd7bab fix(ra_parser.typo): amend 'format language' to 'formal language' 2020-01-15 23:29:55 +02:00
bors[bot]
c78d269b66
Merge #2837
2837: Accidentally quadratic r=matklad a=matklad

Our syntax highlighting is accdentally quadratic. Current state of the PR fixes it in a pretty crude way, looks like for the proper fix we need to redo how source-analyzer works. 

**NB:** don't be scared by diff stats, that's mostly a test-data file

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-15 19:38:10 +00:00
Kirill Bulatov
79b77403b6 Reduce visibility 2020-01-15 20:21:05 +02:00
Kirill Bulatov
d51cf7794d itertools::Either -> either::Either 2020-01-15 20:20:20 +02:00
Kirill Bulatov
78a21253b4 Apply the api design suggestions 2020-01-15 20:17:17 +02:00
Kirill Bulatov
73dc8b6f06 Another attempt to add multiple edits 2020-01-15 20:16:27 +02:00
Aleksey Kladov
ef1326ee19 More orthogonal path editing 2020-01-15 18:48:28 +01:00
Aleksey Kladov
7d2d3ac3db More fluent API 2020-01-15 18:30:23 +01:00
Aleksey Kladov
c84010e246 Slightly more fluent API 2020-01-15 18:14:49 +01:00
Aleksey Kladov
8296d3208d Simplify 2020-01-15 18:01:05 +01:00
Aleksey Kladov
448575aa4a Simplify 2020-01-15 18:01:05 +01:00
Aleksey Kladov
263401bf75 Rename 2020-01-15 17:44:12 +01:00
Aleksey Kladov
aaef88db0e Typos 2020-01-15 16:53:01 +01:00
Aleksey Kladov
5b255b4e6b ⬆️ once_cell 2020-01-15 16:52:28 +01:00
Aleksey Kladov
787d1aba63 Add comment 2020-01-15 16:52:28 +01:00
Aleksey Kladov
4194e5c88c Optimize inlay hints 2020-01-15 16:52:28 +01:00
Aleksey Kladov
11d6b9dadd Only new-style classification 2020-01-15 16:52:28 +01:00
Aleksey Kladov
35bfeaf4af Add a test 2020-01-15 16:52:28 +01:00
Aleksey Kladov
c640c2ea11 Make syntax highlighting linear 2020-01-15 16:52:28 +01:00
Aleksey Kladov
7e70fc22a7 Flip generics 2020-01-15 16:52:28 +01:00
Aleksey Kladov
a71bb70f0a Store DB in SourceBinder 2020-01-15 16:52:28 +01:00
Aleksey Kladov
ccfe53376a Introduce SourceBinder 2020-01-15 16:52:28 +01:00
Emil Lauridsen
7a8c6351bf Extract check task handling into function 2020-01-15 16:33:58 +01:00
Emil Lauridsen
ade657cb66 Tweak naming slightly 2020-01-15 15:53:08 +01:00
Emil Lauridsen
478ba65f8d Manage check state updates in main_loop to reduce lock contention 2020-01-15 15:50:49 +01:00
Aleksey Kladov
21ea62d292 Don't parse child modules when doing diagnostics 2020-01-15 14:42:57 +01:00
Jeremy Kolb
e1688be1bb lsp-types 0.69.0
Stabilizes most proposed features
2020-01-15 08:05:42 -05:00
bors[bot]
876f92d547
Merge #2843
2843: Add inlay parameter name hints for call expr r=matklad a=imtsuki

This patch adds Intellij-like parameter name hints for literal values in function calls.

<img width="624" alt="Screenshot" src="https://user-images.githubusercontent.com/8423594/72366533-68d7f800-3735-11ea-9279-cf193ca8ca2f.png">

Signed-off-by: imtsuki <me@qjx.app>

Co-authored-by: imtsuki <me@qjx.app>
2020-01-15 10:24:51 +00:00
imtsuki
d854ad8f27 FnSignature: use unwrap_or_default for parameter_name_list
Signed-off-by: imtsuki <me@qjx.app>
2020-01-15 09:30:19 +08:00
kjeremy
e89ade3809 Cleanup assert 2020-01-14 13:55:32 -05:00
bors[bot]
b2ed130ffd
Merge #2841
2841: More UI friendly labels r=kjeremy a=kjeremy



Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-01-14 18:16:11 +00:00
Jeremy Kolb
864434137a unwrap 2020-01-14 13:15:41 -05:00
bors[bot]
767ff2c13c
Merge #2844
2844: Use dummy value for line! and column! macro r=matklad a=edwin0cheng

Use dummy value `0` for line! and column! macro. 

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-14 17:59:24 +00:00
bors[bot]
6a5100f4d5
Merge #2834
2834: refactor(ra_syntax.validation): removed code duplication from validate_literal() r=kiljacken a=Veetaha

Hi! This is my first ever contribution to this project.
I've taken some dirty job from issue #223

This is a simple atomic PR to remove code duplication according to FIXME comment in the function that is the main focus of the further development.

I just didn't want to mix refactoring with the implementation of new features...

I am not sure whether you prefer such atomic PRs here or you'd rather have a single PR that contains all atomic commits inside of it?

So if you want me to add all that validation in one PR I'll mark this one as WIP and update it when the work is finished, otherwise, I'll go with the option of creating separate PRs per each feature of validation of strings, numbers, and comments respectively.

### Comments about refactoring
Yeah, reducing the duplication is quite hard here, extracting into stateless functions could be another option but the number of their arguments would be very big and repeated across char and string implementations so that just writing their types and names would become cumbersome.
I tried the option of having everything captured implicitly in the closure but failed since rust doesn't have templated (or generic) closures as C++ does, this is needed because `unescape_byte*()` and `unescape_char|str()` have different return types...
Maybe I am missing something here? I may be wrong because I am not enough experienced in Rust...
Well, I am awaiting any kind of feedback!

Co-authored-by: Veetaha <gerzoh1@gmail.com>
2020-01-14 17:49:18 +00:00
Edwin Cheng
6ebb1edf21 Use dummy value for line! and column! macro 2020-01-15 01:47:01 +08:00
Jeremy Kolb
9042bb7892 Assert that first letter is capitalized 2020-01-14 12:32:46 -05:00
Jeremy Kolb
e04661e495 Fix casing 2020-01-14 12:32:26 -05:00
imtsuki
d78a3cb638 Update test snapshot
Signed-off-by: imtsuki <me@qjx.app>
2020-01-15 01:32:03 +08:00
imtsuki
c390e92fdd Add inlay parameter name hints for function calls
Signed-off-by: imtsuki <me@qjx.app>
2020-01-15 01:18:52 +08:00
Jeremy Kolb
4cb82c334d More UI friendly labels 2020-01-14 11:49:14 -05:00
bors[bot]
e406f2bed6
Merge #2839
2839: Tweak add_custom_impl r=matklad a=kjeremy

Display a nicer label and categorize

Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-01-14 14:27:58 +00:00
Jeremy Kolb
325912f01e Tweak add_custom_impl 2020-01-14 09:08:45 -05:00
Aleksey Kladov
a38540771f Move Type API to type 2020-01-14 14:42:52 +01:00
Aleksey Kladov
21c5fd8b1b Push resolver further up 2020-01-14 14:24:03 +01:00
Aleksey Kladov
7ec62ea5e6 Push resolver up 2020-01-14 14:11:07 +01:00
Aleksey Kladov
52e7f67128 Move impls_future to Type, where it belongs 2020-01-14 11:29:43 +01:00
Aleksey Kladov
0358f5fdeb Use lang-items to resolve future trait 2020-01-14 11:29:43 +01:00
Aleksey Kladov
aedff7cdcf Move utility functions down 2020-01-14 11:29:43 +01:00
Aleksey Kladov
eb8989f9e4 Rename file 2020-01-14 11:29:43 +01:00
Veetaha
60251da204 refactor(ra_syntax.validation): removed code duplication from validate_literal() function 2020-01-14 04:09:03 +02:00
kjeremy
170c7bd7e3 Log client info if present 2020-01-13 16:20:47 -05:00
Aleksey Kladov
5654387e77 Don't panic if chalk panics 2020-01-13 19:00:42 +01:00
bors[bot]
7ea7de338f
Merge #2825
2825: Some clippy lints r=matklad a=kjeremy



Co-authored-by: kjeremy <kjeremy@gmail.com>
2020-01-13 17:06:19 +00:00
kjeremy
c5c5f4260b Readability 2020-01-13 11:38:53 -05:00
kjeremy
a82c679c97 Some clippy lints 2020-01-13 11:27:06 -05:00
Emil Lauridsen
c774850fd8 Schedule check update regardless of notification setting 2020-01-13 17:22:21 +01:00
Emil Lauridsen
daca5a3711 Defer cargo check until after workspace load 2020-01-13 17:12:14 +01:00
kjeremy
0610444407 Dropping a reference does nothing.
Allows clippy to continue compilation
2020-01-13 10:51:39 -05:00
bors[bot]
96e759413d
Merge #2815
2815: Report macro calls as functions r=matklad a=kjeremy



Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-01-13 10:34:43 +00:00
memoryruins
5575588387 Add macro_rules item snippet 2020-01-12 18:47:15 -05:00
Jeremy Kolb
9e71ff9636 Report macro calls as functions 2020-01-12 17:22:09 -05:00
Roland Ruckerbauer
20b8d283ae Remove hir usage from macro_rules! detection in structure_node() 2020-01-12 17:34:57 +01:00
Roland Ruckerbauer
15c5426b54 Use hir .path() and .name() to differentiate
macro call and macro definition
2020-01-12 17:34:57 +01:00
Roland Ruckerbauer
c6655c67d2 Added test for file_structure unidentified macro definition 2020-01-12 17:34:57 +01:00
Roland Ruckerbauer
db151763d4 Fix file_structure() to recognize macro_rules!
where first token != "macro_rules"
2020-01-12 17:34:57 +01:00
Joshua Nelson
c3ac2c93fb
Allow attributes before function arguments
This adds support for function calls of the form:

```rust
  (
    #[attr(...)] 1.2,
    #[attr_one(...)]
    #[attr_two(...)]
    1.5,
    ... etc ...
  )
```

Closes https://github.com/rust-analyzer/rust-analyzer/issues/2801
2020-01-12 10:25:41 -05:00
Edwin Cheng
0593da9a36 Fix format 2020-01-12 20:25:58 +08:00
Edwin Cheng
384e1ced88 Use prev_token and next_token 2020-01-12 20:25:58 +08:00
Edwin Cheng
b7ab079211 Use indices first and last instead of min-max 2020-01-12 20:25:58 +08:00
Edwin Cheng
caed836e41 Use first and last token only 2020-01-12 20:25:58 +08:00
Edwin Cheng
b30e6a7b56 Handle extend selection in recursive macro 2020-01-12 20:25:58 +08:00
Edwin Cheng
07f4171b18 Minor fix 2020-01-12 20:25:58 +08:00
Edwin Cheng
4c4416543a Fix formatting 2020-01-12 20:25:58 +08:00
Edwin Cheng
83b2d78bbb Supporting extend selection inside macro calls 2020-01-12 20:25:58 +08:00
bors[bot]
8bb2a50ce6
Merge #2807
2807: Use attr location for builtin derive in goto-implementation r=matklad a=edwin0cheng

This PR is use attribute location for builtin derive in `ImplBlock`'s NavigationTarget such that the goto-implementation will goto to a correct position. 

Related to #2531

Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-12 11:33:31 +00:00
Edwin Cheng
db5f73d261 Add test 2020-01-12 19:24:34 +08:00
Florian Diebold
2c11a9b42d Qualify paths in 'fill match arms' assist 2020-01-12 11:34:52 +01:00
Edwin Cheng
d7be1a4372 Use attr location for builtin macro goto-imp 2020-01-12 18:08:53 +08:00
bors[bot]
86d2af9f7b
Merge #2803
2803: Fix various names, e.g. Iterator not resolving in core prelude r=matklad a=flodiebold

Basically, `Iterator` is re-exported via several steps, which happened to not be
resolved yet when we got to the prelude import, but since the name resolved to
the reexport from `core::iter` (just to no actual items), we gave up trying to
resolve it further.

Maybe part of the problem is that we can have
`PartialResolvedImport::Unresolved` or `PartialResolvedImport::Indeterminate`
with `None` in all namespaces, and handle them differently.

Fixes #2683.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-01-11 23:00:37 +00:00
Florian Diebold
9dc1826cfa Fix various names, e.g. Iterator not resolving in core prelude
Basically, `Iterator` is re-exported via several steps, which happened to not be
resolved yet when we got to the prelude import, but since the name resolved to
the reexport from `core::iter` (just to no actual items), we gave up trying to
resolve it further.

Maybe part of the problem is that we can have
`PartialResolvedImport::Unresolved` or `PartialResolvedImport::Indeterminate`
with `None` in all namespaces, and handle them differently.

Fixes #2683.
2020-01-11 23:37:58 +01:00
Florian Diebold
ccb75f7c97 Use FxHashMap 2020-01-11 23:33:04 +01:00
Florian Diebold
4496e2a06a Apply review suggestions 2020-01-11 23:33:04 +01:00
Florian Diebold
15fc643e05 Fix ordering problem between qualifying paths and substituting params 2020-01-11 23:33:04 +01:00
Florian Diebold
12905e5b58 Some more refactoring 2020-01-11 23:33:04 +01:00
Florian Diebold
def124e932 Fix file ID when qualifying paths; add another failing test 2020-01-11 23:33:04 +01:00
Florian Diebold
4545f289a9 Handle type args 2020-01-11 23:33:04 +01:00
Florian Diebold
5cb1f71322 More failing tests 2020-01-11 23:33:04 +01:00
Florian Diebold
4d75430e91 Qualify some paths in 'add missing impl members' 2020-01-11 23:33:04 +01:00
Florian Diebold
460fa71c55 Use self 2020-01-11 23:33:04 +01:00
Florian Diebold
2906d188c2 Cleanup 2020-01-11 23:33:04 +01:00
Florian Diebold
38cd9f0c94 Handle cycles 2020-01-11 23:33:04 +01:00
Florian Diebold
b1325488ec Use query for importable locations 2020-01-11 23:33:04 +01:00
Florian Diebold
947eec7b87 Use super, don't use private imports 2020-01-11 23:33:04 +01:00
Florian Diebold
df9d3bd25e Use shortest path 2020-01-11 23:33:04 +01:00
Florian Diebold
1ea2b475a9 handle most cases 2020-01-11 23:33:04 +01:00
Florian Diebold
b62292e8f9 basics working 2020-01-11 23:33:04 +01:00
Florian Diebold
2c50f996b6 more WIP 2020-01-11 23:33:04 +01:00
Florian Diebold
22b412f1a9 find_path WIP 2020-01-11 23:33:04 +01:00
Florian Diebold
877fda04c5 Add test 2020-01-11 23:33:04 +01:00
bors[bot]
3924c7de50
Merge #2791
2791: Slightly more robust cargo watcher root search r=kiljacken a=kiljacken

Fixes #2780 (hopefully).

Use the already painstakingly found `workspaces` instead of naively using `folder_roots` from editor.

Co-authored-by: Emil Lauridsen <mine809@gmail.com>
2020-01-11 20:41:41 +00:00
Emil Lauridsen
8e778f9842 Clean up straggling mut 2020-01-11 21:37:01 +01:00
Emil Lauridsen
480c44918c Disable cargo checking in workspaces with no cargo projects 2020-01-11 21:32:40 +01:00
bors[bot]
7c1af25b22
Merge #2795
2795: Use dummy value for macro file in bulitin macros r=matklad a=edwin0cheng

This PR skip the actual line and column computation for `MacroFile` and return a dummy value instead.

Related to #2794



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-11 20:13:48 +00:00
Edwin Cheng
9f65ae20c2 Use dummy value for macro file in bulitin macros 2020-01-11 16:37:42 +08:00
bors[bot]
991b62a4f9
Merge #2790
2790: Add test for macro expansion in various expressions r=edwin0cheng a=flodiebold

cc @edwin0cheng 

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
2020-01-11 03:51:04 +00:00
Emil Lauridsen
d6da18e99d Address nit 2020-01-10 22:41:52 +01:00
Emil Lauridsen
1d1eea217d Slightly more robust cargo watcher root search 2020-01-10 22:10:26 +01:00
Florian Diebold
dd6ec81d65 Add test for macro expansion in various expressions 2020-01-10 22:08:02 +01:00
kjeremy
a633a6275a Fix Write being sent down the wire.
Not sure what the deal is here but it wasn't sending Write.
2020-01-10 15:30:17 -05:00
kjeremy
32540abcb3 Add AccessMode to decls 2020-01-10 15:14:19 -05:00
kjeremy
49fd6a5228 Split Declaration out into it's own type 2020-01-10 15:14:19 -05:00
kjeremy
cc96ddfe69 Simplify and update tests to account for access 2020-01-10 15:14:19 -05:00
Jeremy Kolb
6c89d86ade Tweaks 2020-01-10 15:14:19 -05:00
Jeremy Kolb
d993f329a0 Basic DocumentHighlightKind support for assignments 2020-01-10 15:14:19 -05:00
Edwin Cheng
dca9195f75 Add missing expr cases for expand macro 2020-01-11 03:11:23 +08:00
bors[bot]
029c02982b
Merge #2786
2786: Proper handling local in hover r=flodiebold a=edwin0cheng

This PR implement back the `Local` hover information generation, which is fall back to a general case catch previously :

9a44f627be/crates/ra_ide/src/hover.rs (L173-L182)



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-10 17:58:14 +00:00
Edwin Cheng
19094abd41 Proper handling local in hover 2020-01-11 01:51:08 +08:00
bors[bot]
9a44f627be
Merge #2785
2785: Expand PAREN_EXPR as expression r=matklad a=edwin0cheng



Co-authored-by: Edwin Cheng <edwin0cheng@gmail.com>
2020-01-10 16:31:02 +00:00
Edwin Cheng
ca62d98781 Expand PAREN_EXPR as expression 2020-01-11 00:29:00 +08:00
Emil Lauridsen
aa433c67d8 Parse trait aliases 2020-01-09 18:40:01 +01:00
bors[bot]
c2bbfb9a5f
Merge #2778
2778: ⬆️ rowan r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-09 15:33:37 +00:00
Aleksey Kladov
47785b0cd4 ⬆️ rowan 2020-01-09 16:33:02 +01:00
Aleksey Kladov
cf5bdf464c
Merge pull request #2732 from detrumi/cargo-toml-not-found-message-toggle
Flag to hide cargo.toml not found error
2020-01-09 15:16:39 +01:00
bors[bot]
3263c70766
Merge #2772
2772: Actually test references r=kjeremy a=kjeremy

This will be a little more work when `ReferenceSearchResults` change but I think it's easier to maintain in the end. It also follows a similar pattern to navigation targets and call hierarchy.

Co-authored-by: kjeremy <kjeremy@gmail.com>
Co-authored-by: Jeremy Kolb <kjeremy@gmail.com>
2020-01-09 12:26:59 +00:00
Jeremy Kolb
6fc80efe77 visibility tweak 2020-01-09 07:26:04 -05:00
bors[bot]
0d6e5a986c
Merge #2771
2771: Remove the Default impl for SourceRoot r=matklad a=michalt

Let's be always explicit whether we create a library (i.e., an immutable
dependency) or a local `SourceRoot`, since it can have a large impact on
the validation performance in salsa. (we found it the hard way recently,
where the `Default` instance made it quite tricky to spot a bug)

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Co-authored-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-09 10:35:17 +00:00
bors[bot]
5ced6f4be3
Merge #2777
2777: Better error message r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-09 10:26:22 +00:00
Aleksey Kladov
4223760a7b Better error message
closes #2775
2020-01-09 11:25:44 +01:00
kjeremy
9791b9c36a Actually test references 2020-01-08 16:35:58 -05:00
Michal Terepeta
d761435ba0 Remove the Default impl for SourceRoot
Let's be always explicit whether we create a library (i.e., an immutable
dependency) or a local `SourceRoot`, since it can have a large impact on
the validation performance in salsa. (we found it the hard way recently,
where the `Default` instance made it quite tricky to spot a bug)

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>
2020-01-08 19:42:27 +01:00
kjeremy
c7b2bc1363 Move private API down 2020-01-08 11:33:04 -05:00
Wilco Kusee
11caebe6ce
Remove unneeded Box::new
Co-Authored-By: Aleksey Kladov <aleksey.kladov@gmail.com>
2020-01-08 17:22:08 +01:00
Wilco Kusee
738d5a7ec2
Derive debug 2020-01-08 17:21:19 +01:00
Jeremy Kolb
1b19a8aa5e Implement proposed CallHierarchy feature
See: https://github.com/microsoft/vscode-languageserver-node/blob/master/protocol/src/protocol.callHierarchy.proposed.ts
2020-01-08 10:15:49 -05:00
Mikhail Modin
fb25c91979 Adds a way to limits reference search by StructLiteral 2020-01-08 15:21:54 +01:00
Wilco Kusee
003620f0d6
Use downcasting for CargoTomlNotFoundError 2020-01-08 14:06:08 +01:00
Aleksey Kladov
5d8f2bd822
Merge pull request #2762 from edwin0cheng/fix-2759
Reject tuple index for missing fields assist
2020-01-08 12:49:54 +01:00
Edwin Cheng
a4c9babedb Proper emit diagnostic without fix 2020-01-08 02:18:43 +08:00
Edwin Cheng
e55e6da13a Reject tuple index for missing fields assist 2020-01-08 02:08:17 +08:00
Aleksey Kladov
8317efa191
Merge pull request #2760 from edwin0cheng/fix-descend-into-macros
Use src node for analyze source in `descend_into_macros`
2020-01-07 18:08:43 +01:00
Edwin Cheng
1fdee24608 Use src node for analyze source 2020-01-08 00:23:53 +08:00