mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Merge #10403
10403: feat: Add semantic token modifier for crate root r=Veykril a=lhvy Resolves #9073 I managed to implement crate root highlighting for crates mentioned specifically by name (e.g. `serde` in `use serde::Serialize;`), but not for crates referred to with `crate` or `super`. How could I implement this? > P.S. I'm participating in [Hacktoberfest 2021](https://hacktoberfest.digitalocean.com/). If this PR is up to standard and merged, I'd appreciate if the `hacktoberfest-accepted` label could be added. Thanks! Co-authored-by: lhvy <me@lhvy.dev>
This commit is contained in:
commit
47c079a037
10 changed files with 141 additions and 14 deletions
|
@ -779,6 +779,50 @@ fn test_extern_crate() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_crate_root() {
|
||||
check_highlighting(
|
||||
r#"
|
||||
//- minicore: iterators
|
||||
//- /main.rs crate:main deps:foo
|
||||
extern crate foo;
|
||||
use core::iter;
|
||||
|
||||
pub const NINETY_TWO: u8 = 92;
|
||||
|
||||
use foo as foooo;
|
||||
|
||||
pub(crate) fn main() {
|
||||
let baz = iter::repeat(92);
|
||||
}
|
||||
|
||||
mod bar {
|
||||
pub(in super) const FORTY_TWO: u8 = 42;
|
||||
|
||||
mod baz {
|
||||
use super::super::NINETY_TWO;
|
||||
use crate::foooo::Point;
|
||||
|
||||
pub(in super::super) const TWENTY_NINE: u8 = 29;
|
||||
}
|
||||
}
|
||||
//- /foo.rs crate:foo
|
||||
struct Point {
|
||||
x: u8,
|
||||
y: u8,
|
||||
}
|
||||
|
||||
mod inner {
|
||||
pub(super) fn swap(p: crate::Point) -> crate::Point {
|
||||
crate::Point { x: p.y, y: p.x }
|
||||
}
|
||||
}
|
||||
"#,
|
||||
expect_file!["./test_data/highlight_crate_root.html"],
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_default_library() {
|
||||
check_highlighting(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue