aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src')
-rw-r--r--crates/ra_syntax/src/ast/generated.rs1
-rw-r--r--crates/ra_syntax/src/grammar.ron1
-rw-r--r--crates/ra_syntax/src/ptr.rs5
3 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs
index e2a92ae60..bcf753f78 100644
--- a/crates/ra_syntax/src/ast/generated.rs
+++ b/crates/ra_syntax/src/ast/generated.rs
@@ -934,6 +934,7 @@ impl AstNode for ExternCrateItem {
934 &self.syntax 934 &self.syntax
935 } 935 }
936} 936}
937impl ast::AttrsOwner for ExternCrateItem {}
937impl ExternCrateItem { 938impl ExternCrateItem {
938 pub fn name_ref(&self) -> Option<NameRef> { 939 pub fn name_ref(&self) -> Option<NameRef> {
939 AstChildren::new(&self.syntax).next() 940 AstChildren::new(&self.syntax).next()
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron
index c14ee0e85..3e6c2d3f3 100644
--- a/crates/ra_syntax/src/grammar.ron
+++ b/crates/ra_syntax/src/grammar.ron
@@ -669,6 +669,7 @@ Grammar(
669 collections: [("use_trees", "UseTree")] 669 collections: [("use_trees", "UseTree")]
670 ), 670 ),
671 "ExternCrateItem": ( 671 "ExternCrateItem": (
672 traits: ["AttrsOwner"],
672 options: ["NameRef", "Alias"], 673 options: ["NameRef", "Alias"],
673 ), 674 ),
674 "ArgList": ( 675 "ArgList": (
diff --git a/crates/ra_syntax/src/ptr.rs b/crates/ra_syntax/src/ptr.rs
index 80e55d2aa..992034ef0 100644
--- a/crates/ra_syntax/src/ptr.rs
+++ b/crates/ra_syntax/src/ptr.rs
@@ -15,8 +15,9 @@ impl SyntaxNodePtr {
15 SyntaxNodePtr { range: node.text_range(), kind: node.kind() } 15 SyntaxNodePtr { range: node.text_range(), kind: node.kind() }
16 } 16 }
17 17
18 pub fn to_node(self, parent: &SyntaxNode) -> SyntaxNode { 18 pub fn to_node(self, root: &SyntaxNode) -> SyntaxNode {
19 successors(Some(parent.clone()), |node| { 19 assert!(root.parent().is_none());
20 successors(Some(root.clone()), |node| {
20 node.children().find(|it| self.range.is_subrange(&it.text_range())) 21 node.children().find(|it| self.range.is_subrange(&it.text_range()))
21 }) 22 })
22 .find(|it| it.text_range() == self.range && it.kind() == self.kind) 23 .find(|it| it.text_range() == self.range && it.kind() == self.kind)