Skip to content

Commit e2d36cb

Browse files
committed
Highlight true and false as literals
1 parent 7e86262 commit e2d36cb

File tree

10 files changed

+14
-1
lines changed

10 files changed

+14
-1
lines changed

crates/ra_ide/src/snapshots/highlight_injection.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.type_param { color: #DFAF8F; }
1818
.attribute { color: #94BFF3; }
1919
.numeric_literal { color: #BFEBBF; }
20+
.bool_literal { color: #BFE6EB; }
2021
.macro { color: #94BFF3; }
2122
.module { color: #AFD8AF; }
2223
.variable { color: #DCDCCC; }

crates/ra_ide/src/snapshots/highlight_strings.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.type_param { color: #DFAF8F; }
1818
.attribute { color: #94BFF3; }
1919
.numeric_literal { color: #BFEBBF; }
20+
.bool_literal { color: #BFE6EB; }
2021
.macro { color: #94BFF3; }
2122
.module { color: #AFD8AF; }
2223
.variable { color: #DCDCCC; }

crates/ra_ide/src/snapshots/highlighting.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.type_param { color: #DFAF8F; }
1818
.attribute { color: #94BFF3; }
1919
.numeric_literal { color: #BFEBBF; }
20+
.bool_literal { color: #BFE6EB; }
2021
.macro { color: #94BFF3; }
2122
.module { color: #AFD8AF; }
2223
.variable { color: #DCDCCC; }
@@ -64,7 +65,7 @@
6465
<span class="macro">println!</span>(<span class="string_literal">"Hello, {}!"</span>, <span class="numeric_literal">92</span>);
6566

6667
<span class="keyword">let</span> <span class="keyword">mut</span> <span class="variable declaration mutable">vec</span> = <span class="unresolved_reference">Vec</span>::<span class="unresolved_reference">new</span>();
67-
<span class="keyword control">if</span> <span class="keyword">true</span> {
68+
<span class="keyword control">if</span> <span class="bool_literal">true</span> {
6869
<span class="keyword">let</span> <span class="variable declaration">x</span> = <span class="numeric_literal">92</span>;
6970
<span class="variable mutable">vec</span>.<span class="unresolved_reference">push</span>(<span class="struct">Foo</span> { <span class="field">x</span>, <span class="field">y</span>: <span class="numeric_literal">1</span> });
7071
}

crates/ra_ide/src/snapshots/rainbow_highlighting.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
.type_param { color: #DFAF8F; }
1818
.attribute { color: #94BFF3; }
1919
.numeric_literal { color: #BFEBBF; }
20+
.bool_literal { color: #BFE6EB; }
2021
.macro { color: #94BFF3; }
2122
.module { color: #AFD8AF; }
2223
.variable { color: #DCDCCC; }

crates/ra_ide/src/syntax_highlighting.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ fn highlight_element(
413413
| T![in] => h | HighlightModifier::ControlFlow,
414414
T![for] if !is_child_of_impl(element) => h | HighlightModifier::ControlFlow,
415415
T![unsafe] => h | HighlightModifier::Unsafe,
416+
T![true] | T![false] => HighlightTag::BoolLiteral.into(),
416417
_ => h,
417418
}
418419
}

crates/ra_ide/src/syntax_highlighting/html.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
7676
.type_param { color: #DFAF8F; }
7777
.attribute { color: #94BFF3; }
7878
.numeric_literal { color: #BFEBBF; }
79+
.bool_literal { color: #BFE6EB; }
7980
.macro { color: #94BFF3; }
8081
.module { color: #AFD8AF; }
8182
.variable { color: #DCDCCC; }

crates/ra_ide/src/syntax_highlighting/tags.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub struct HighlightModifiers(u32);
1515
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1616
pub enum HighlightTag {
1717
Attribute,
18+
BoolLiteral,
1819
BuiltinType,
1920
ByteLiteral,
2021
CharLiteral,
@@ -60,6 +61,7 @@ impl HighlightTag {
6061
fn as_str(self) -> &'static str {
6162
match self {
6263
HighlightTag::Attribute => "attribute",
64+
HighlightTag::BoolLiteral => "bool_literal",
6365
HighlightTag::BuiltinType => "builtin_type",
6466
HighlightTag::ByteLiteral => "byte_literal",
6567
HighlightTag::CharLiteral => "char_literal",

crates/rust-analyzer/src/semantic_tokens.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ macro_rules! define_semantic_token_types {
3636

3737
define_semantic_token_types![
3838
(ATTRIBUTE, "attribute"),
39+
(BOOLEAN, "boolean"),
3940
(BUILTIN_TYPE, "builtinType"),
4041
(ENUM_MEMBER, "enumMember"),
4142
(LIFETIME, "lifetime"),

crates/rust-analyzer/src/to_proto.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ fn semantic_token_type_and_modifiers(
295295
HighlightTag::ByteLiteral | HighlightTag::NumericLiteral => {
296296
lsp_types::SemanticTokenType::NUMBER
297297
}
298+
HighlightTag::BoolLiteral => semantic_tokens::BOOLEAN,
298299
HighlightTag::CharLiteral | HighlightTag::StringLiteral => {
299300
lsp_types::SemanticTokenType::STRING
300301
}

editors/code/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,9 @@
644644
"function.attribute": [
645645
"entity.name.function.attribute.rust"
646646
],
647+
"boolean": [
648+
"constant.language.boolean.rust"
649+
],
647650
"builtinType": [
648651
"support.type.primitive.rust"
649652
],

0 commit comments

Comments
 (0)