always show token text

This commit is contained in:
Aleksey Kladov
2019-04-02 14:04:23 +03:00
parent 2d680ff93a
commit 7d6bd5d137
221 changed files with 8921 additions and 8921 deletions

View File

@@ -319,10 +319,17 @@ pub struct SyntaxToken<'a>(pub(crate) rowan::SyntaxToken<'a, RaTypes>);
impl<'a> fmt::Debug for SyntaxToken<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{:?}@{:?}", self.kind(), self.range())?;
if has_short_text(self.kind()) {
write!(fmt, " \"{}\"", self.text())?;
if self.text().len() < 25 {
return write!(fmt, " {:?}", self.text());
}
Ok(())
let text = self.text().as_str();
for idx in 21..25 {
if text.is_char_boundary(idx) {
let text = format!("{} ...", &text[..idx]);
return write!(fmt, " {:?}", text);
}
}
unreachable!()
}
}
@@ -499,14 +506,6 @@ impl<'a> Iterator for SyntaxElementChildren<'a> {
}
}
fn has_short_text(kind: SyntaxKind) -> bool {
use crate::SyntaxKind::*;
match kind {
IDENT | LIFETIME | INT_NUMBER | FLOAT_NUMBER => true,
_ => false,
}
}
pub struct SyntaxTreeBuilder {
errors: Vec<SyntaxError>,
inner: GreenNodeBuilder<RaTypes>,