From 996e18846dab8e5c4a2846641289f85fe99eb480 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 27 Feb 2020 19:00:10 +0100 Subject: add more tags --- crates/ra_ide/src/syntax_highlighting.rs | 17 ++++++++++------- crates/ra_ide/src/syntax_highlighting/tags.rs | 26 ++++++++++++++++---------- crates/rust-analyzer/src/conv.rs | 8 ++++++-- crates/rust-analyzer/src/semantic_tokens.rs | 2 -- 4 files changed, 32 insertions(+), 21 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index d7bca1193..ae2163f9f 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -255,15 +255,15 @@ fn highlight_name(db: &RootDatabase, def: NameDefinition) -> Highlight { NameDefinition::ModuleDef(def) => match def { hir::ModuleDef::Module(_) => HighlightTag::Module, hir::ModuleDef::Function(_) => HighlightTag::Function, - hir::ModuleDef::Adt(_) => HighlightTag::Type, + hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, + hir::ModuleDef::Adt(hir::Adt::Enum(_)) => HighlightTag::Enum, + hir::ModuleDef::Adt(hir::Adt::Union(_)) => HighlightTag::Union, hir::ModuleDef::EnumVariant(_) => HighlightTag::Constant, hir::ModuleDef::Const(_) => HighlightTag::Constant, hir::ModuleDef::Static(_) => HighlightTag::Constant, - hir::ModuleDef::Trait(_) => HighlightTag::Type, - hir::ModuleDef::TypeAlias(_) => HighlightTag::Type, - hir::ModuleDef::BuiltinType(_) => { - return HighlightTag::Type | HighlightModifier::Builtin - } + hir::ModuleDef::Trait(_) => HighlightTag::Trait, + hir::ModuleDef::TypeAlias(_) => HighlightTag::TypeAlias, + hir::ModuleDef::BuiltinType(_) => HighlightTag::BuiltinType, }, NameDefinition::SelfType(_) => HighlightTag::TypeSelf, NameDefinition::TypeParam(_) => HighlightTag::TypeParam, @@ -287,7 +287,10 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight { }; match parent.kind() { - STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => HighlightTag::Type.into(), + STRUCT_DEF => HighlightTag::Struct.into(), + ENUM_DEF => HighlightTag::Enum.into(), + TRAIT_DEF => HighlightTag::Trait.into(), + TYPE_ALIAS_DEF => HighlightTag::TypeAlias.into(), TYPE_PARAM => HighlightTag::TypeParam.into(), RECORD_FIELD_DEF => HighlightTag::Field.into(), _ => default, diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index 383c74c98..df2fc3c48 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs @@ -14,6 +14,13 @@ pub struct HighlightModifiers(u32); #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum HighlightTag { + Struct, + Enum, + Union, + Trait, + TypeAlias, + BuiltinType, + Field, Function, Module, @@ -21,7 +28,6 @@ pub enum HighlightTag { Macro, Variable, - Type, TypeSelf, TypeParam, TypeLifetime, @@ -44,19 +50,24 @@ pub enum HighlightModifier { Unsafe, /// Used with keywords like `if` and `break`. Control, - Builtin, } impl HighlightTag { fn as_str(self) -> &'static str { match self { + HighlightTag::Struct => "struct", + HighlightTag::Enum => "enum", + HighlightTag::Union => "union", + HighlightTag::Trait => "trait", + HighlightTag::TypeAlias => "type_alias", + HighlightTag::BuiltinType => "builtin_type", + HighlightTag::Field => "field", HighlightTag::Function => "function", HighlightTag::Module => "module", HighlightTag::Constant => "constant", HighlightTag::Macro => "macro", HighlightTag::Variable => "variable", - HighlightTag::Type => "type", HighlightTag::TypeSelf => "type.self", HighlightTag::TypeParam => "type.param", HighlightTag::TypeLifetime => "type.lifetime", @@ -78,19 +89,14 @@ impl fmt::Display for HighlightTag { } impl HighlightModifier { - const ALL: &'static [HighlightModifier] = &[ - HighlightModifier::Mutable, - HighlightModifier::Unsafe, - HighlightModifier::Control, - HighlightModifier::Builtin, - ]; + const ALL: &'static [HighlightModifier] = + &[HighlightModifier::Mutable, HighlightModifier::Unsafe, HighlightModifier::Control]; fn as_str(self) -> &'static str { match self { HighlightModifier::Mutable => "mutable", HighlightModifier::Unsafe => "unsafe", HighlightModifier::Control => "control", - HighlightModifier::Builtin => "builtin", } } diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs index b012f5dd5..e4255e24a 100644 --- a/crates/rust-analyzer/src/conv.rs +++ b/crates/rust-analyzer/src/conv.rs @@ -316,6 +316,12 @@ impl Conv for Highlight { fn conv(self) -> Self::Output { let mut mods = ModifierSet::default(); let type_ = match self.tag { + HighlightTag::Struct + | HighlightTag::Enum + | HighlightTag::Union + | HighlightTag::TypeAlias + | HighlightTag::Trait + | HighlightTag::BuiltinType => SemanticTokenType::TYPE, HighlightTag::Field => SemanticTokenType::MEMBER, HighlightTag::Function => SemanticTokenType::FUNCTION, HighlightTag::Module => SemanticTokenType::NAMESPACE, @@ -326,7 +332,6 @@ impl Conv for Highlight { } HighlightTag::Macro => SemanticTokenType::MACRO, HighlightTag::Variable => SemanticTokenType::VARIABLE, - HighlightTag::Type => SemanticTokenType::TYPE, HighlightTag::TypeSelf => { mods |= SemanticTokenModifier::REFERENCE; SemanticTokenType::TYPE @@ -350,7 +355,6 @@ impl Conv for Highlight { HighlightModifier::Mutable => MUTABLE, HighlightModifier::Unsafe => UNSAFE, HighlightModifier::Control => CONTROL, - HighlightModifier::Builtin => BUILTIN, }; mods |= modifier; } diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index d8362409d..3069f3054 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs @@ -10,7 +10,6 @@ pub(crate) const CONSTANT: SemanticTokenType = SemanticTokenType::new("constant" pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable"); pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe"); pub(crate) const CONTROL: SemanticTokenModifier = SemanticTokenModifier::new("control"); -pub(crate) const BUILTIN: SemanticTokenModifier = SemanticTokenModifier::new("builtin"); pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[ SemanticTokenType::COMMENT, @@ -51,7 +50,6 @@ pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[ MUTABLE, UNSAFE, CONTROL, - BUILTIN, ]; #[derive(Default)] -- cgit v1.2.3 From 701cf436063590c710cd7783032b5e7c3c41af22 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Feb 2020 12:06:54 +0100 Subject: Cleanup highlighting tags --- crates/ra_ide/src/syntax_highlighting.rs | 30 +++++---- crates/ra_ide/src/syntax_highlighting/tags.rs | 92 ++++++++++++++------------- crates/rust-analyzer/src/conv.rs | 46 +++++++------- crates/rust-analyzer/src/semantic_tokens.rs | 16 ++++- 4 files changed, 99 insertions(+), 85 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index ae2163f9f..30ca9d8b0 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -177,10 +177,11 @@ fn highlight_element( } }; - match name_kind { + let h = match name_kind { Some(name_kind) => highlight_name(db, name_kind), None => highlight_name_by_syntax(name), - } + }; + h | HighlightModifier::Definition } // Highlight references like the definitions they resolve to @@ -206,12 +207,13 @@ fn highlight_element( // Simple token-based highlighting COMMENT => HighlightTag::Comment.into(), - STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::LiteralString.into(), + STRING | RAW_STRING | RAW_BYTE_STRING | BYTE_STRING => HighlightTag::StringLiteral.into(), ATTR => HighlightTag::Attribute.into(), - INT_NUMBER | FLOAT_NUMBER => HighlightTag::LiteralNumeric.into(), - BYTE => HighlightTag::LiteralByte.into(), - CHAR => HighlightTag::LiteralChar.into(), - LIFETIME => HighlightTag::TypeLifetime.into(), + INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(), + BYTE => HighlightTag::ByteLiteral.into(), + CHAR => HighlightTag::CharLiteral.into(), + // FIXME: set Declaration for decls + LIFETIME => HighlightTag::Lifetime.into(), k if k.is_keyword() => { let h = Highlight::new(HighlightTag::Keyword); @@ -258,17 +260,18 @@ fn highlight_name(db: &RootDatabase, def: NameDefinition) -> Highlight { hir::ModuleDef::Adt(hir::Adt::Struct(_)) => HighlightTag::Struct, hir::ModuleDef::Adt(hir::Adt::Enum(_)) => HighlightTag::Enum, hir::ModuleDef::Adt(hir::Adt::Union(_)) => HighlightTag::Union, - hir::ModuleDef::EnumVariant(_) => HighlightTag::Constant, + hir::ModuleDef::EnumVariant(_) => HighlightTag::EnumVariant, hir::ModuleDef::Const(_) => HighlightTag::Constant, - hir::ModuleDef::Static(_) => HighlightTag::Constant, + hir::ModuleDef::Static(_) => HighlightTag::Static, hir::ModuleDef::Trait(_) => HighlightTag::Trait, hir::ModuleDef::TypeAlias(_) => HighlightTag::TypeAlias, hir::ModuleDef::BuiltinType(_) => HighlightTag::BuiltinType, }, - NameDefinition::SelfType(_) => HighlightTag::TypeSelf, + NameDefinition::SelfType(_) => HighlightTag::SelfType, NameDefinition::TypeParam(_) => HighlightTag::TypeParam, + // FIXME: distinguish between locals and parameters NameDefinition::Local(local) => { - let mut h = Highlight::new(HighlightTag::Variable); + let mut h = Highlight::new(HighlightTag::Local); if local.is_mut(db) || local.ty(db).is_mutable_reference() { h |= HighlightModifier::Mutable; } @@ -289,6 +292,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight { match parent.kind() { STRUCT_DEF => HighlightTag::Struct.into(), ENUM_DEF => HighlightTag::Enum.into(), + UNION_KW => HighlightTag::Union.into(), TRAIT_DEF => HighlightTag::Trait.into(), TYPE_ALIAS_DEF => HighlightTag::TypeAlias.into(), TYPE_PARAM => HighlightTag::TypeParam.into(), @@ -315,7 +319,7 @@ fn highlight_injection( if let Some(range) = literal.open_quote_text_range() { acc.push(HighlightedRange { range, - highlight: HighlightTag::LiteralString.into(), + highlight: HighlightTag::StringLiteral.into(), binding_hash: None, }) } @@ -330,7 +334,7 @@ fn highlight_injection( if let Some(range) = literal.close_quote_text_range() { acc.push(HighlightedRange { range, - highlight: HighlightTag::LiteralString.into(), + highlight: HighlightTag::StringLiteral.into(), binding_hash: None, }) } diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index df2fc3c48..0b12bdef5 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs @@ -14,70 +14,71 @@ pub struct HighlightModifiers(u32); #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum HighlightTag { - Struct, - Enum, - Union, - Trait, - TypeAlias, + Attribute, BuiltinType, - + ByteLiteral, + CharLiteral, + Comment, + Constant, + Enum, + EnumVariant, Field, Function, - Module, - Constant, + Keyword, + Lifetime, Macro, - Variable, - - TypeSelf, + Module, + NumericLiteral, + SelfType, + Static, + StringLiteral, + Struct, + Trait, + TypeAlias, TypeParam, - TypeLifetime, - - LiteralByte, - LiteralNumeric, - LiteralChar, - - Comment, - LiteralString, - Attribute, - - Keyword, + Union, + Local, } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] #[repr(u8)] pub enum HighlightModifier { - Mutable = 0, - Unsafe, /// Used with keywords like `if` and `break`. - Control, + Control = 0, + /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is + /// not. + Definition, + Mutable, + Unsafe, } impl HighlightTag { fn as_str(self) -> &'static str { match self { - HighlightTag::Struct => "struct", - HighlightTag::Enum => "enum", - HighlightTag::Union => "union", - HighlightTag::Trait => "trait", - HighlightTag::TypeAlias => "type_alias", + HighlightTag::Attribute => "attribute", HighlightTag::BuiltinType => "builtin_type", - + HighlightTag::ByteLiteral => "byte_literal", + HighlightTag::CharLiteral => "char_literal", + HighlightTag::Comment => "comment", + HighlightTag::Constant => "constant", + HighlightTag::Enum => "enum", + HighlightTag::EnumVariant => "enum_variant", HighlightTag::Field => "field", HighlightTag::Function => "function", - HighlightTag::Module => "module", - HighlightTag::Constant => "constant", - HighlightTag::Macro => "macro", - HighlightTag::Variable => "variable", - HighlightTag::TypeSelf => "type.self", - HighlightTag::TypeParam => "type.param", - HighlightTag::TypeLifetime => "type.lifetime", - HighlightTag::LiteralByte => "literal.byte", - HighlightTag::LiteralNumeric => "literal.numeric", - HighlightTag::LiteralChar => "literal.char", - HighlightTag::Comment => "comment", - HighlightTag::LiteralString => "string", - HighlightTag::Attribute => "attribute", HighlightTag::Keyword => "keyword", + HighlightTag::Lifetime => "lifetime", + HighlightTag::Macro => "macro", + HighlightTag::Module => "module", + HighlightTag::NumericLiteral => "numeric_literal", + HighlightTag::SelfType => "self_type", + HighlightTag::Static => "static", + HighlightTag::StringLiteral => "string", + HighlightTag::Struct => "struct", + HighlightTag::Trait => "trait", + HighlightTag::TypeAlias => "type_alias", + HighlightTag::TypeParam => "type_param", + HighlightTag::Union => "union", + HighlightTag::Local => "variable", } } } @@ -94,9 +95,10 @@ impl HighlightModifier { fn as_str(self) -> &'static str { match self { + HighlightModifier::Control => "control", + HighlightModifier::Definition => "declaration", HighlightModifier::Mutable => "mutable", HighlightModifier::Unsafe => "unsafe", - HighlightModifier::Control => "control", } } diff --git a/crates/rust-analyzer/src/conv.rs b/crates/rust-analyzer/src/conv.rs index e4255e24a..ff156307a 100644 --- a/crates/rust-analyzer/src/conv.rs +++ b/crates/rust-analyzer/src/conv.rs @@ -20,11 +20,11 @@ use ra_vfs::LineEndings; use crate::{ req, - semantic_tokens::{self, ModifierSet, BUILTIN, CONSTANT, CONTROL, MUTABLE, UNSAFE}, + semantic_tokens::{self, ModifierSet, CONSTANT, CONTROL, MUTABLE, UNSAFE}, world::WorldSnapshot, Result, }; -use semantic_tokens::ATTRIBUTE; +use semantic_tokens::{ATTRIBUTE, BUILTIN_TYPE, ENUM_MEMBER, LIFETIME, TYPE_ALIAS, UNION}; pub trait Conv { type Output; @@ -316,45 +316,43 @@ impl Conv for Highlight { fn conv(self) -> Self::Output { let mut mods = ModifierSet::default(); let type_ = match self.tag { - HighlightTag::Struct - | HighlightTag::Enum - | HighlightTag::Union - | HighlightTag::TypeAlias - | HighlightTag::Trait - | HighlightTag::BuiltinType => SemanticTokenType::TYPE, + HighlightTag::Struct => SemanticTokenType::STRUCT, + HighlightTag::Enum => SemanticTokenType::ENUM, + HighlightTag::Union => UNION, + HighlightTag::TypeAlias => TYPE_ALIAS, + HighlightTag::Trait => SemanticTokenType::INTERFACE, + HighlightTag::BuiltinType => BUILTIN_TYPE, + HighlightTag::SelfType => SemanticTokenType::TYPE, HighlightTag::Field => SemanticTokenType::MEMBER, HighlightTag::Function => SemanticTokenType::FUNCTION, HighlightTag::Module => SemanticTokenType::NAMESPACE, HighlightTag::Constant => { + mods |= CONSTANT; mods |= SemanticTokenModifier::STATIC; - mods |= SemanticTokenModifier::READONLY; - CONSTANT + SemanticTokenType::VARIABLE } - HighlightTag::Macro => SemanticTokenType::MACRO, - HighlightTag::Variable => SemanticTokenType::VARIABLE, - HighlightTag::TypeSelf => { - mods |= SemanticTokenModifier::REFERENCE; - SemanticTokenType::TYPE + HighlightTag::Static => { + mods |= SemanticTokenModifier::STATIC; + SemanticTokenType::VARIABLE } + HighlightTag::EnumVariant => ENUM_MEMBER, + HighlightTag::Macro => SemanticTokenType::MACRO, + HighlightTag::Local => SemanticTokenType::VARIABLE, HighlightTag::TypeParam => SemanticTokenType::TYPE_PARAMETER, - HighlightTag::TypeLifetime => { - mods |= SemanticTokenModifier::REFERENCE; - SemanticTokenType::LABEL - } - HighlightTag::LiteralByte => SemanticTokenType::NUMBER, - HighlightTag::LiteralNumeric => SemanticTokenType::NUMBER, - HighlightTag::LiteralChar => SemanticTokenType::NUMBER, + HighlightTag::Lifetime => LIFETIME, + HighlightTag::ByteLiteral | HighlightTag::NumericLiteral => SemanticTokenType::NUMBER, + HighlightTag::CharLiteral | HighlightTag::StringLiteral => SemanticTokenType::STRING, HighlightTag::Comment => SemanticTokenType::COMMENT, - HighlightTag::LiteralString => SemanticTokenType::STRING, HighlightTag::Attribute => ATTRIBUTE, HighlightTag::Keyword => SemanticTokenType::KEYWORD, }; for modifier in self.modifiers.iter() { let modifier = match modifier { + HighlightModifier::Definition => SemanticTokenModifier::DECLARATION, + HighlightModifier::Control => CONTROL, HighlightModifier::Mutable => MUTABLE, HighlightModifier::Unsafe => UNSAFE, - HighlightModifier::Control => CONTROL, }; mods |= modifier; } diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index 3069f3054..1b146e4d8 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs @@ -5,11 +5,16 @@ use std::ops; use lsp_types::{Range, SemanticToken, SemanticTokenModifier, SemanticTokenType}; pub(crate) const ATTRIBUTE: SemanticTokenType = SemanticTokenType::new("attribute"); -pub(crate) const CONSTANT: SemanticTokenType = SemanticTokenType::new("constant"); +pub(crate) const BUILTIN_TYPE: SemanticTokenType = SemanticTokenType::new("builtinType"); +pub(crate) const ENUM_MEMBER: SemanticTokenType = SemanticTokenType::new("enumMember"); +pub(crate) const LIFETIME: SemanticTokenType = SemanticTokenType::new("lifetime"); +pub(crate) const TYPE_ALIAS: SemanticTokenType = SemanticTokenType::new("typeAlias"); +pub(crate) const UNION: SemanticTokenType = SemanticTokenType::new("union"); +pub(crate) const CONSTANT: SemanticTokenModifier = SemanticTokenModifier::new("constant"); +pub(crate) const CONTROL: SemanticTokenModifier = SemanticTokenModifier::new("control"); pub(crate) const MUTABLE: SemanticTokenModifier = SemanticTokenModifier::new("mutable"); pub(crate) const UNSAFE: SemanticTokenModifier = SemanticTokenModifier::new("unsafe"); -pub(crate) const CONTROL: SemanticTokenModifier = SemanticTokenModifier::new("control"); pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[ SemanticTokenType::COMMENT, @@ -33,7 +38,11 @@ pub(crate) const SUPPORTED_TYPES: &[SemanticTokenType] = &[ SemanticTokenType::PARAMETER, SemanticTokenType::LABEL, ATTRIBUTE, - CONSTANT, + BUILTIN_TYPE, + ENUM_MEMBER, + LIFETIME, + TYPE_ALIAS, + UNION, ]; pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[ @@ -47,6 +56,7 @@ pub(crate) const SUPPORTED_MODIFIERS: &[SemanticTokenModifier] = &[ SemanticTokenModifier::ASYNC, SemanticTokenModifier::VOLATILE, SemanticTokenModifier::READONLY, + CONSTANT, MUTABLE, UNSAFE, CONTROL, -- cgit v1.2.3 From 9464ca97c90dca4cad57d29cac4fccdd99235925 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Feb 2020 14:47:33 +0100 Subject: Fix highlighting test --- crates/ra_ide/src/snapshots/highlighting.html | 54 +++++++++++----------- .../ra_ide/src/snapshots/rainbow_highlighting.html | 26 ++++++----- crates/ra_ide/src/syntax_highlighting/html.rs | 20 ++++---- crates/ra_ide/src/syntax_highlighting/tags.rs | 2 +- crates/ra_ide/src/syntax_highlighting/tests.rs | 2 +- 5 files changed, 55 insertions(+), 49 deletions(-) (limited to 'crates') diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html index 51851763e..8c372ad27 100644 --- a/crates/ra_ide/src/snapshots/highlighting.html +++ b/crates/ra_ide/src/snapshots/highlighting.html @@ -3,70 +3,72 @@ body { margin: 0; } pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } + .comment { color: #7F9F7F; } -.string { color: #CC9393; } +.struct, .enum { color: #7CB8BB; } +.enum_variant { color: #BDE0F3; } +.string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } -.type.builtin { color: #8CD0D3; } -.type.param { color: #20999D; } +.builtin_type { color: #8CD0D3; } +.type_param { color: #DFAF8F; } .attribute { color: #94BFF3; } -.literal { color: #BFEBBF; } -.literal.numeric { color: #6A8759; } +.numeric_literal { color: #BFEBBF; } .macro { color: #94BFF3; } .module { color: #AFD8AF; } .variable { color: #DCDCCC; } -.variable.mut { color: #DCDCCC; text-decoration: underline; } +.mutable { text-decoration: underline; } -.keyword { color: #F0DFAF; } -.keyword.unsafe { color: #DFAF8F; } -.keyword.control { color: #F0DFAF; font-weight: bold; } +.keyword { color: #F0DFAF; font-weight: bold; } +.keyword.unsafe { color: #BC8383; font-weight: bold; } +.control { font-style: italic; }
#[derive(Clone, Debug)]
-struct Foo {
-    pub x: i32,
-    pub y: i32,
+struct Foo {
+    pub x: i32,
+    pub y: i32,
 }
 
-fn foo<T>() -> T {
+fn foo<T>() -> T {
     unimplemented!();
-    foo::<i32>();
+    foo::<i32>();
 }
 
 macro_rules! def_fn {
     ($($tt:tt)*) => {$($tt)*}
 }
 
-def_fn!{
-    fn bar() -> u32 {
-        100
+def_fn! {
+    fn bar() -> u32 {
+        100
     }
 }
 
 // comment
 fn main() {
-    println!("Hello, {}!", 92);
+    println!("Hello, {}!", 92);
 
     let mut vec = Vec::new();
     if true {
-        let x = 92;
-        vec.push(Foo { x, y: 1 });
+        let x = 92;
+        vec.push(Foo { x, y: 1 });
     }
-    unsafe { vec.set_len(0); }
+    unsafe { vec.set_len(0); }
 
-    let mut x = 42;
+    let mut x = 42;
     let y = &mut x;
     let z = &y;
 
     y;
 }
 
-enum E<X> {
-    V(X)
+enum E<X> {
+    V(X)
 }
 
-impl<X> E<X> {
-    fn new<T>() -> E<T> {}
+impl<X> E<X> {
+    fn new<T>() -> E<T> {}
 }
\ No newline at end of file diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html index 1f869867f..f63e64b6d 100644 --- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html +++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html @@ -3,36 +3,38 @@ body { margin: 0; } pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } + .comment { color: #7F9F7F; } -.string { color: #CC9393; } +.struct, .enum { color: #7CB8BB; } +.enum_variant { color: #BDE0F3; } +.string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } -.type.builtin { color: #8CD0D3; } -.type.param { color: #20999D; } +.builtin_type { color: #8CD0D3; } +.type_param { color: #DFAF8F; } .attribute { color: #94BFF3; } -.literal { color: #BFEBBF; } -.literal.numeric { color: #6A8759; } +.numeric_literal { color: #BFEBBF; } .macro { color: #94BFF3; } .module { color: #AFD8AF; } .variable { color: #DCDCCC; } -.variable.mut { color: #DCDCCC; text-decoration: underline; } +.mutable { text-decoration: underline; } -.keyword { color: #F0DFAF; } -.keyword.unsafe { color: #DFAF8F; } -.keyword.control { color: #F0DFAF; font-weight: bold; } +.keyword { color: #F0DFAF; font-weight: bold; } +.keyword.unsafe { color: #BC8383; font-weight: bold; } +.control { font-style: italic; }
fn main() {
-    let hello = "hello";
+    let hello = "hello";
     let x = hello.to_string();
     let y = hello.to_string();
 
-    let x = "other color please!";
+    let x = "other color please!";
     let y = x.to_string();
 }
 
 fn bar() {
-    let mut hello = "hello";
+    let mut hello = "hello";
 }
\ No newline at end of file diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 210d9a57b..54678c278 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs @@ -80,25 +80,27 @@ const STYLE: &str = " body { margin: 0; } pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } + .comment { color: #7F9F7F; } -.string { color: #CC9393; } +.struct, .enum { color: #7CB8BB; } +.enum_variant { color: #BDE0F3; } +.string_literal { color: #CC9393; } .field { color: #94BFF3; } .function { color: #93E0E3; } .parameter { color: #94BFF3; } .text { color: #DCDCCC; } .type { color: #7CB8BB; } -.type.builtin { color: #8CD0D3; } -.type.param { color: #20999D; } +.builtin_type { color: #8CD0D3; } +.type_param { color: #DFAF8F; } .attribute { color: #94BFF3; } -.literal { color: #BFEBBF; } -.literal.numeric { color: #6A8759; } +.numeric_literal { color: #BFEBBF; } .macro { color: #94BFF3; } .module { color: #AFD8AF; } .variable { color: #DCDCCC; } -.variable.mut { color: #DCDCCC; text-decoration: underline; } +.mutable { text-decoration: underline; } -.keyword { color: #F0DFAF; } -.keyword.unsafe { color: #DFAF8F; } -.keyword.control { color: #F0DFAF; font-weight: bold; } +.keyword { color: #F0DFAF; font-weight: bold; } +.keyword.unsafe { color: #BC8383; font-weight: bold; } +.control { font-style: italic; } "; diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index 0b12bdef5..9da80823c 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs @@ -72,7 +72,7 @@ impl HighlightTag { HighlightTag::NumericLiteral => "numeric_literal", HighlightTag::SelfType => "self_type", HighlightTag::Static => "static", - HighlightTag::StringLiteral => "string", + HighlightTag::StringLiteral => "string_literal", HighlightTag::Struct => "struct", HighlightTag::Trait => "trait", HighlightTag::TypeAlias => "type_alias", diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index ff23d4ac5..2d90a072f 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs @@ -26,7 +26,7 @@ macro_rules! def_fn { ($($tt:tt)*) => {$($tt)*} } -def_fn!{ +def_fn! { fn bar() -> u32 { 100 } -- cgit v1.2.3