diff options
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r-- | crates/ra_syntax/src/syntax_node.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/crates/ra_syntax/src/syntax_node.rs b/crates/ra_syntax/src/syntax_node.rs index be181d0ae..a88a348ad 100644 --- a/crates/ra_syntax/src/syntax_node.rs +++ b/crates/ra_syntax/src/syntax_node.rs | |||
@@ -319,10 +319,17 @@ pub struct SyntaxToken<'a>(pub(crate) rowan::SyntaxToken<'a, RaTypes>); | |||
319 | impl<'a> fmt::Debug for SyntaxToken<'a> { | 319 | impl<'a> fmt::Debug for SyntaxToken<'a> { |
320 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { | 320 | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { |
321 | write!(fmt, "{:?}@{:?}", self.kind(), self.range())?; | 321 | write!(fmt, "{:?}@{:?}", self.kind(), self.range())?; |
322 | if has_short_text(self.kind()) { | 322 | if self.text().len() < 25 { |
323 | write!(fmt, " \"{}\"", self.text())?; | 323 | return write!(fmt, " {:?}", self.text()); |
324 | } | 324 | } |
325 | Ok(()) | 325 | let text = self.text().as_str(); |
326 | for idx in 21..25 { | ||
327 | if text.is_char_boundary(idx) { | ||
328 | let text = format!("{} ...", &text[..idx]); | ||
329 | return write!(fmt, " {:?}", text); | ||
330 | } | ||
331 | } | ||
332 | unreachable!() | ||
326 | } | 333 | } |
327 | } | 334 | } |
328 | 335 | ||
@@ -499,14 +506,6 @@ impl<'a> Iterator for SyntaxElementChildren<'a> { | |||
499 | } | 506 | } |
500 | } | 507 | } |
501 | 508 | ||
502 | fn has_short_text(kind: SyntaxKind) -> bool { | ||
503 | use crate::SyntaxKind::*; | ||
504 | match kind { | ||
505 | IDENT | LIFETIME | INT_NUMBER | FLOAT_NUMBER => true, | ||
506 | _ => false, | ||
507 | } | ||
508 | } | ||
509 | |||
510 | pub struct SyntaxTreeBuilder { | 509 | pub struct SyntaxTreeBuilder { |
511 | errors: Vec<SyntaxError>, | 510 | errors: Vec<SyntaxError>, |
512 | inner: GreenNodeBuilder<RaTypes>, | 511 | inner: GreenNodeBuilder<RaTypes>, |