mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +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
|
||||
}
|
||||
|
||||
pub fn range(&self) -> TextRange {
|
||||
self.data().range
|
||||
}
|
||||
|
||||
pub fn text(&self) -> &'f str {
|
||||
let range = self.data().range;
|
||||
&self.file.text.as_str()[range]
|
||||
&self.file.text.as_str()[self.range()]
|
||||
}
|
||||
|
||||
pub fn parent(&self) -> Option<Node<'f>> {
|
||||
|
@ -78,6 +81,8 @@ impl<'f> Node<'f> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
pub struct Children<'f> {
|
||||
next: Option<Node<'f>>,
|
||||
}
|
||||
|
@ -115,4 +120,10 @@ impl ::std::ops::IndexMut<NodeIdx> for Vec<NodeData> {
|
|||
fn index_mut(&mut self, NodeIdx(idx): NodeIdx) -> &mut NodeData {
|
||||
&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