aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-27 10:56:06 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-27 10:56:06 +0100
commit0d1c6076073c73f57340e256dc25da9d37311ef0 (patch)
tree60ff1f4a42f8ef297c07d5716af67e3057c8e1bd /crates/ra_syntax/src
parent4b48cff022a1606bde596f01fbf44361640b10d8 (diff)
parent1e6ba1901550fb1610a1a464c48ec358cd3c339c (diff)
Merge #1319
1319: Rainbow highlighting spike 🌈 r=killercup a=killercup Very simple approach: For each identifier, set the hash of the range where it's defined as its 'id' and use it in the VSCode extension to generate unique colors. Thus, the generated colors are per-file. They are also quite fragile, and I'm not entirely sure why. Looks like we need to make sure the same ranges aren't overwritten by a later request? Co-authored-by: Pascal Hertleif <[email protected]>
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/syntax_text.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/syntax_text.rs b/crates/ra_syntax/src/syntax_text.rs
index b013164c4..c9038cd5c 100644
--- a/crates/ra_syntax/src/syntax_text.rs
+++ b/crates/ra_syntax/src/syntax_text.rs
@@ -1,6 +1,6 @@
1use std::{fmt, ops::{self, Bound}}; 1use std::{fmt, ops::{self, Bound}};
2 2
3use crate::{SyntaxNode, TextRange, TextUnit, SyntaxElement}; 3use crate::{SmolStr, SyntaxNode, TextRange, TextUnit, SyntaxElement};
4 4
5#[derive(Clone)] 5#[derive(Clone)]
6pub struct SyntaxText<'a> { 6pub struct SyntaxText<'a> {
@@ -34,6 +34,12 @@ impl<'a> SyntaxText<'a> {
34 self.chunks().collect() 34 self.chunks().collect()
35 } 35 }
36 36
37 pub fn to_smol_string(&self) -> SmolStr {
38 // FIXME: use `self.chunks().collect()` here too once
39 // https://github.com/matklad/smol_str/pull/12 is merged and published
40 self.to_string().into()
41 }
42
37 pub fn contains(&self, c: char) -> bool { 43 pub fn contains(&self, c: char) -> bool {
38 self.chunks().any(|it| it.contains(c)) 44 self.chunks().any(|it| it.contains(c))
39 } 45 }