aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-04-02 12:04:23 +0100
committerAleksey Kladov <[email protected]>2019-04-02 12:49:46 +0100
commit7d6bd5d1379061180e771f7b833a9fecdc85a0b8 (patch)
treef2c8c4b116f73d8b5da458c50ba5b7a03a42c4f8 /crates/ra_syntax/src
parent2d680ff93aa30a52ffe40bb7d359e19565dca733 (diff)
always show token text
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/syntax_node.rs21
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>);
319impl<'a> fmt::Debug for SyntaxToken<'a> { 319impl<'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
502fn 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
510pub struct SyntaxTreeBuilder { 509pub struct SyntaxTreeBuilder {
511 errors: Vec<SyntaxError>, 510 errors: Vec<SyntaxError>,
512 inner: GreenNodeBuilder<RaTypes>, 511 inner: GreenNodeBuilder<RaTypes>,