aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-05-26 13:08:56 +0100
committerGitHub <[email protected]>2021-05-26 13:08:56 +0100
commit5a1fd05760260be9a91f6fad2fd6463edffbcb13 (patch)
treece4c358eceaceeaea43225218bac3f9a753dfa1f /crates
parent5701c553cba5cb1ca4159a874ae5abadbd11041a (diff)
parent887dd2d5bb5dd3fda1da8aa0de7300a78fdebd6b (diff)
Merge #9003
9003: minor: Document semantic token modifiers r=Veykril a=Veykril Part of #6457 Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r--crates/ide/src/syntax_highlighting.rs24
-rw-r--r--crates/ide/src/syntax_highlighting/tags.rs2
2 files changed, 26 insertions, 0 deletions
diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs
index cf1a8bad7..7f7f4d38a 100644
--- a/crates/ide/src/syntax_highlighting.rs
+++ b/crates/ide/src/syntax_highlighting.rs
@@ -49,6 +49,30 @@ pub struct HlRange {
49// The general rule is that a reference to an entity gets colored the same way as the entity itself. 49// The general rule is that a reference to an entity gets colored the same way as the entity itself.
50// We also give special modifier for `mut` and `&mut` local variables. 50// We also give special modifier for `mut` and `&mut` local variables.
51// 51//
52// .Token Modifiers
53//
54// Token modifiers allow to style some elements in the source code more precisely.
55//
56// Rust-analyzer currently emits the following token modifiers:
57//
58// [horizontal]
59// associated:: Emitted for associated items.
60// async:: Emitted for async functions and the `async` and `await` keywords.
61// attribute:: Emitted for tokens inside attributes.
62// callable:: Emitted for locals whose types implements one of the `Fn*` traits.
63// consuming:: Emitted for locals that are being consumed when use in a function call.
64// controlFlow:: Emitted for control-flow related tokens, this includes the `?` operator.
65// declaration:: Emitted for names of definitions, like `foo` in `fn foo() {}`.
66// documentation:: Emitted for documentation comments.
67// injected:: Emitted for doc-string injected highlighting like rust source blocks in documentation.
68// intraDocLink:: Emitted for intra doc links in doc-strings.
69// library:: Emitted for items that are defined outside of the current crate.
70// mutable:: Emitted for mutable locals and statics.
71// static:: Emitted for "static" functions, also known as functions that do not take a `self` param.
72// trait:: Emitted for associated trait items.
73// unsafe:: Emitted for unsafe operations, like unsafe function calls, as well as the `unsafe` token.
74//
75//
52// image::https://user-images.githubusercontent.com/48062697/113164457-06cfb980-9239-11eb-819b-0f93e646acf8.png[] 76// image::https://user-images.githubusercontent.com/48062697/113164457-06cfb980-9239-11eb-819b-0f93e646acf8.png[]
53// image::https://user-images.githubusercontent.com/48062697/113187625-f7f50100-9250-11eb-825e-91c58f236071.png[] 77// image::https://user-images.githubusercontent.com/48062697/113187625-f7f50100-9250-11eb-825e-91c58f236071.png[]
54pub(crate) fn highlight( 78pub(crate) fn highlight(
diff --git a/crates/ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs
index e94f17cd9..9d481deae 100644
--- a/crates/ide/src/syntax_highlighting/tags.rs
+++ b/crates/ide/src/syntax_highlighting/tags.rs
@@ -37,6 +37,8 @@ pub enum HlTag {
37 None, 37 None,
38} 38}
39 39
40// Don't forget to adjust the feature description in crates/ide/src/syntax_highlighting.rs.
41// And make sure to use the lsp strings used when converting to the protocol in crates\rust-analyzer\src\semantic_tokens.rs, not the names of the variants here.
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] 42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41#[repr(u8)] 43#[repr(u8)]
42pub enum HlMod { 44pub enum HlMod {