mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Debug for Node
This commit is contained in:
parent
f16fed18b3
commit
8e42f26965
1 changed files with 13 additions and 2 deletions
|
@ -56,9 +56,12 @@ impl<'f> Node<'f> {
|
||||||
self.data().kind
|
self.data().kind
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn range(&self) -> TextRange {
|
||||||
|
self.data().range
|
||||||
|
}
|
||||||
|
|
||||||
pub fn text(&self) -> &'f str {
|
pub fn text(&self) -> &'f str {
|
||||||
let range = self.data().range;
|
&self.file.text.as_str()[self.range()]
|
||||||
&self.file.text.as_str()[range]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parent(&self) -> Option<Node<'f>> {
|
pub fn parent(&self) -> Option<Node<'f>> {
|
||||||
|
@ -78,6 +81,8 @@ impl<'f> Node<'f> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
pub struct Children<'f> {
|
pub struct Children<'f> {
|
||||||
next: Option<Node<'f>>,
|
next: Option<Node<'f>>,
|
||||||
}
|
}
|
||||||
|
@ -116,3 +121,9 @@ impl ::std::ops::IndexMut<NodeIdx> for Vec<NodeData> {
|
||||||
&mut self[idx as usize]
|
&mut self[idx as usize]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'f> fmt::Debug for Node<'f> {
|
||||||
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(fmt, "{:?}@{:?}", self.kind(), self.range())
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue