Commit graph

812 commits

Author SHA1 Message Date
bors[bot]
5a1fd05760
Merge #9003
9003: minor: Document semantic token modifiers r=Veykril a=Veykril

Part of #6457

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-26 12:08:56 +00:00
Lukas Wirth
887dd2d5bb Document semantic token modifiers 2021-05-26 13:37:54 +02:00
bors[bot]
5701c553cb
Merge #9002
9002: Move annotations below item attributes r=Veykril a=Veykril

This moves annotations/code lenses below attributes in items, bringing them inline with functions where this is already the case. This is done by changing the annotations covering range to just the name node's range which is also more inline with what the lsp expects which is that the range should ideally only cover a single line. 

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

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-26 10:26:19 +00:00
Lukas Wirth
dfa47eaadb Move annotations below item attributes 2021-05-26 12:23:51 +02:00
bors[bot]
8483fb0f26
Merge #8996
8996: Fix bug where library functions were not highlighted as such r=arzg a=arzg

Sorry about forgetting to test this in my last PR.

Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-05-25 23:28:02 +00:00
Aramis Razzaghipour
8960a08951
Fix bug where library functions were not highlighted as such 2021-05-26 09:26:13 +10:00
bors[bot]
5587d0a3e3
Merge #8973
8973: internal: move diagnostics to hir r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2021-05-25 20:33:21 +00:00
Aleksey Kladov
5c9f31d4c2 internal: move diagnostics to hir
The idea here is to eventually get rid of `dyn Diagnostic` and
`DiagnosticSink` infrastructure altogether, and just have a `enum
hir::Diagnostic` instead.

The problem with `dyn Diagnostic` is that it is defined in the lowest
level of the stack (hir_expand), but is used by the highest level (ide).

As a first step, we free hir_expand and hir_def from `dyn Diagnostic`
and kick the can up to `hir_ty`, as an intermediate state. The plan is
then to move DiagnosticSink similarly to the hir crate, and, as final
third step, remove its usage from the ide.

One currently unsolved problem is testing. You can notice that the test
which checks precise diagnostic ranges, unresolved_import_in_use_tree,
was moved to the ide layer. Logically, only IDE should have the infra to
render a specific range.

At the same time, the range is determined with the data produced in
hir_def and hir crates, so this layering is rather unfortunate. Working
on hir_def shouldn't require compiling `ide` for testing.
2021-05-25 17:49:59 +03:00
Jade
0292efd363 Also do goto implementation on assoc consts
I forgot to put this into #8988, sorry.

Goto implementation on a const on the trait will go to the
implementations with their respective definitions of the const, if
present.
2021-05-25 06:27:41 -07:00
Jade
3e4dfaf97a feat: go to implementation on trait functions
Fix #8537.

GIF:
https://user-images.githubusercontent.com/6652840/119501981-45a45c00-bd1e-11eb-8336-9145f2888643.gif
2021-05-25 05:46:15 -07:00
Jade
ff585e4730 Add go to type definition for struct fields within struct
Example:

```rust
struct A;

struct B {
    a/*<- cursor*/: A,
}
```

Go to type definition used to not work on this position. It now goes to
`A` as expected.
2021-05-25 04:06:54 -07:00
bors[bot]
8b049ec393
Merge #8942
8942: Add `library` semantic token modifier to items from other crates r=arzg a=arzg

Closes #5772.

A lot of code here is pretty repetitive; please let me know if you have any ideas how to improve it, or whether it’s fine as-is.

Side-note: How can I add tests for this? I don’t see a way for the test Rust code in `test_highlighting` to reference other crates to observe the new behaviour.


Co-authored-by: Aramis Razzaghipour <aramisnoah@gmail.com>
2021-05-25 02:30:47 +00:00
Aramis Razzaghipour
d75277b66b
Refactor application of library semantic token modifier 2021-05-25 12:20:12 +10:00
Laurențiu Nicola
47afa4a5fc Bump misc deps 2021-05-24 16:31:54 +03:00
Aramis Razzaghipour
eca4b764e4
Remove superfluous early-returns 2021-05-24 14:54:48 +10:00
Aramis Razzaghipour
e51188cd09
Rename ‘foreign’ semantic token modifier to ‘library’ 2021-05-24 14:54:48 +10:00
Aramis Razzaghipour
fa0d0bfb7f
Add testing of foreign item highlighting 2021-05-24 14:54:16 +10:00
Aramis Razzaghipour
b4cddc0705
Highlight foreign modules as such 2021-05-24 14:54:16 +10:00
Aramis Razzaghipour
c32428571c
Remove hir krate methods 2021-05-24 14:54:16 +10:00
Aramis Razzaghipour
4fd5248749
Add highlighting of items from other crates 2021-05-24 14:53:48 +10:00
Lukas Tobias Wirth
da74c66947 Correctly resolve crate name in use paths when import shadows itself 2021-05-23 19:37:01 +02:00
Aleksey Kladov
7283163bb9 Minor: fix comment style
See https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/dev/style.md#documentation
2021-05-23 19:50:23 +03:00
Aramis Razzaghipour
4d4dbcfead
Give ‘unsafe’ semantic token modifier to unsafe traits 2021-05-23 21:45:10 +10:00
Aleksey Kladov
188b0f96f9 Add more docs 2021-05-22 16:53:47 +03:00
Jonas Schievink
271ec6b990 Add a "Debug ItemTree" LSP request 2021-05-21 23:59:52 +02:00
Lukas Tobias Wirth
2c7a8c4857 Fix prepare_rename failing for modules 2021-05-19 14:19:44 +02:00
rainy-me
e0b01f34bb Add pub mod option for UnlinkedFile 2021-05-18 08:11:07 +09:00
Aleksey Kladov
75a0123614 fix: don't add extra whitespace around fields
closes #8785
2021-05-17 12:45:01 +03:00
Aleksey Kladov
21918c6f5e minor: add missing tests 2021-05-17 12:37:22 +03:00
Aleksey Kladov
fa7fc0e5cb internal: scalable module structure for fixits 2021-05-17 12:04:17 +03:00
Aleksey Kladov
db8fbb99ce minor: extract fix to file 2021-05-17 11:40:34 +03:00
bors[bot]
ef6df1d994
Merge #8853
8853: Tag Self in impls as a TypeAlias r=matklad a=Veykril

bors r+
Fixes #4398

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-16 17:35:40 +00:00
Aleksey Kladov
1859df37fd internal: use mutable syntax trees when filling fields 2021-05-16 18:10:56 +03:00
Lukas Wirth
90230e882d Tag Self in impls as a TypeAlias 2021-05-16 15:12:58 +02:00
bors[bot]
a57bd59f35
Merge #8813
8813: Get some more array lengths! r=lf- a=lf-

This is built on #8799 and thus contains its changes. I'll rebase it onto master when that one gets merged. It adds support for r-a understanding the length of:

* `let a: [u8; 2] = ...`
* `let a = b"aaa"`
* `let a = [0u8; 4]`

I have added support for getting the values of byte strings, which was not previously there. I am least confident in the correctness of this part and it probably needs some more tests, as we currently have only one test that exercised that part (!).

Fixes #2922.

Co-authored-by: Jade <software@lfcode.ca>
2021-05-16 01:53:12 +00:00
Lukas Wirth
4b5b54279a Attach comments to ast::Impl 2021-05-15 17:32:28 +02:00
Lukas Wirth
3da52d2e93 simplify 2021-05-15 17:22:39 +02:00
hi-rustin
765ccf2eca Address comments 2021-05-14 17:47:16 +08:00
hi-rustin
b98c119ba6 Apply async semantic token modifier to async/await keywords
Only async semantic token modifier
2021-05-14 10:47:00 +08:00
bors[bot]
c9c9b4e9ed
Merge #8823
8823: Enable OPTION::ENABLE_TASKLISTS in pulldown_cmark r=Veykril a=Veykril

Closes #8821

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2021-05-13 16:41:25 +00:00
Lukas Wirth
07fe9a890d Enable OPTION::ENABLE_TASKLISTS in pulldown_cmark 2021-05-13 15:09:46 +02:00
Jade
73023c0299 Support length for ByteStrings
I am not confident that my added byte string parsing is right.
2021-05-12 21:22:46 -07:00
bors[bot]
312f1fe20a
Merge #8799
8799: Add basic support for array lengths in types r=flodiebold a=lf-

This recognizes `let a = [1u8, 2, 3]` as having type `[u8; 3]` instead
of the previous `[u8; _]`. Byte strings and `[0u8; 2]` kinds of range
array declarations are unsupported as before.

I don't know why a bunch of our rustc tests had single quotes inside
strings un-escaped by `UPDATE_EXPECT=1 cargo t`, but I don't think it's
bad? Maybe something in a nightly?

Co-authored-by: Jade <software@lfcode.ca>
2021-05-12 14:49:43 +00:00
Jonas Schievink
23cd6d0d56 Move dot invocation to rust-analyzer crate 2021-05-12 00:14:59 +02:00
Jonas Schievink
d1aa6bbe75 Better node label/shapes 2021-05-11 19:50:01 +02:00
Jonas Schievink
5b3af25121 Only include workspace crates 2021-05-11 19:17:43 +02:00
Jonas Schievink
9e6d9baf2e
Update crates/ide/src/view_crate_graph.rs
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2021-05-11 16:42:27 +02:00
Jonas Schievink
435c422963 Distinguish crates with identical name 2021-05-11 16:36:00 +02:00
Jonas Schievink
a85a2c4d15 Allow viewing the crate graph in a webview 2021-05-11 16:15:31 +02:00
Jade
dc63fea427 Add basic support for array lengths in types
This recognizes `let a = [1u8, 2, 3]` as having type `[u8; 3]` instead
of the previous `[u8; _]`. Byte strings and `[0u8; 2]` kinds of range
array declarations are unsupported as before.

I don't know why a bunch of our rustc tests had single quotes inside
strings un-escaped by `UPDATE_EXPECT=1 cargo t`, but I don't think it's
bad? Maybe something in a nightly?
2021-05-11 05:25:19 -07:00