aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/syntax_highlighting
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-rw-r--r--crates/ra_ide/src/syntax_highlighting/html.rs2
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tags.rs8
-rw-r--r--crates/ra_ide/src/syntax_highlighting/tests.rs31
3 files changed, 5 insertions, 36 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs
index ed007c382..3477610e5 100644
--- a/crates/ra_ide/src/syntax_highlighting/html.rs
+++ b/crates/ra_ide/src/syntax_highlighting/html.rs
@@ -72,7 +72,7 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
72.field { color: #94BFF3; } 72.field { color: #94BFF3; }
73.function { color: #93E0E3; } 73.function { color: #93E0E3; }
74.function.unsafe { color: #E28C14; } 74.function.unsafe { color: #E28C14; }
75.operator.unsafe { color: #BC8383; } 75.operator.unsafe { color: #E28C14; }
76.parameter { color: #94BFF3; } 76.parameter { color: #94BFF3; }
77.text { color: #DCDCCC; } 77.text { color: #DCDCCC; }
78.type { color: #7CB8BB; } 78.type { color: #7CB8BB; }
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs
index e8e251cfc..b9bea4729 100644
--- a/crates/ra_ide/src/syntax_highlighting/tags.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tags.rs
@@ -25,7 +25,6 @@ pub enum HighlightTag {
25 EnumVariant, 25 EnumVariant,
26 EscapeSequence, 26 EscapeSequence,
27 Field, 27 Field,
28 FormatSpecifier,
29 Function, 28 Function,
30 Generic, 29 Generic,
31 Keyword, 30 Keyword,
@@ -33,7 +32,6 @@ pub enum HighlightTag {
33 Macro, 32 Macro,
34 Module, 33 Module,
35 NumericLiteral, 34 NumericLiteral,
36 Operator,
37 SelfKeyword, 35 SelfKeyword,
38 SelfType, 36 SelfType,
39 Static, 37 Static,
@@ -45,6 +43,8 @@ pub enum HighlightTag {
45 Union, 43 Union,
46 Local, 44 Local,
47 UnresolvedReference, 45 UnresolvedReference,
46 FormatSpecifier,
47 Operator,
48} 48}
49 49
50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] 50#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
@@ -77,7 +77,6 @@ impl HighlightTag {
77 HighlightTag::EnumVariant => "enum_variant", 77 HighlightTag::EnumVariant => "enum_variant",
78 HighlightTag::EscapeSequence => "escape_sequence", 78 HighlightTag::EscapeSequence => "escape_sequence",
79 HighlightTag::Field => "field", 79 HighlightTag::Field => "field",
80 HighlightTag::FormatSpecifier => "format_specifier",
81 HighlightTag::Function => "function", 80 HighlightTag::Function => "function",
82 HighlightTag::Generic => "generic", 81 HighlightTag::Generic => "generic",
83 HighlightTag::Keyword => "keyword", 82 HighlightTag::Keyword => "keyword",
@@ -85,7 +84,6 @@ impl HighlightTag {
85 HighlightTag::Macro => "macro", 84 HighlightTag::Macro => "macro",
86 HighlightTag::Module => "module", 85 HighlightTag::Module => "module",
87 HighlightTag::NumericLiteral => "numeric_literal", 86 HighlightTag::NumericLiteral => "numeric_literal",
88 HighlightTag::Operator => "operator",
89 HighlightTag::SelfKeyword => "self_keyword", 87 HighlightTag::SelfKeyword => "self_keyword",
90 HighlightTag::SelfType => "self_type", 88 HighlightTag::SelfType => "self_type",
91 HighlightTag::Static => "static", 89 HighlightTag::Static => "static",
@@ -97,6 +95,8 @@ impl HighlightTag {
97 HighlightTag::Union => "union", 95 HighlightTag::Union => "union",
98 HighlightTag::Local => "variable", 96 HighlightTag::Local => "variable",
99 HighlightTag::UnresolvedReference => "unresolved_reference", 97 HighlightTag::UnresolvedReference => "unresolved_reference",
98 HighlightTag::FormatSpecifier => "format_specifier",
99 HighlightTag::Operator => "operator",
100 } 100 }
101 } 101 }
102} 102}
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs
index facdc42b7..b7fad9719 100644
--- a/crates/ra_ide/src/syntax_highlighting/tests.rs
+++ b/crates/ra_ide/src/syntax_highlighting/tests.rs
@@ -370,34 +370,3 @@ fn check_highlighting(ra_fixture: &str, snapshot: &str, rainbow: bool) {
370 fs::write(dst_file, &actual_html).unwrap(); 370 fs::write(dst_file, &actual_html).unwrap();
371 assert_eq_text!(expected_html, actual_html); 371 assert_eq_text!(expected_html, actual_html);
372} 372}
373
374#[test]
375fn test_unsafe_highlighting() {
376 let (analysis, file_id) = single_file(
377 r#"
378unsafe fn unsafe_fn() {}
379
380struct HasUnsafeFn;
381
382impl HasUnsafeFn {
383 unsafe fn unsafe_method(&self) {}
384}
385
386fn main() {
387 let x = &5 as *const usize;
388 unsafe {
389 unsafe_fn();
390 HasUnsafeFn.unsafe_method();
391 let y = *x;
392 let z = -x;
393 }
394}
395"#
396 .trim(),
397 );
398 let dst_file = project_dir().join("crates/ra_ide/src/snapshots/highlight_unsafe.html");
399 let actual_html = &analysis.highlight_as_html(file_id, false).unwrap();
400 let expected_html = &read_text(&dst_file);
401 fs::write(dst_file, &actual_html).unwrap();
402 assert_eq_text!(expected_html, actual_html);
403}