aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/lib.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-07-20 18:04:34 +0100
committerAleksey Kladov <[email protected]>2019-07-20 18:12:06 +0100
commitc9cfd57eeaa53657c0af7b9c4ba74d6b7b9889ed (patch)
tree422c1d8fb7f8af663df3c6c6183783253692acad /crates/ra_syntax/src/lib.rs
parent7bde8012cb28c44de7ffc779003781d385323808 (diff)
switch to upstream rowan's API
Diffstat (limited to 'crates/ra_syntax/src/lib.rs')
-rw-r--r--crates/ra_syntax/src/lib.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs
index 8af04c136..21c07d69a 100644
--- a/crates/ra_syntax/src/lib.rs
+++ b/crates/ra_syntax/src/lib.rs
@@ -20,7 +20,6 @@
20//! [Swift]: <https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md> 20//! [Swift]: <https://github.com/apple/swift/blob/13d593df6f359d0cb2fc81cfaac273297c539455/lib/Syntax/README.md>
21 21
22mod syntax_node; 22mod syntax_node;
23mod syntax_text;
24mod syntax_error; 23mod syntax_error;
25mod parsing; 24mod parsing;
26mod validation; 25mod validation;
@@ -43,14 +42,13 @@ pub use crate::{
43 ptr::{AstPtr, SyntaxNodePtr}, 42 ptr::{AstPtr, SyntaxNodePtr},
44 syntax_error::{Location, SyntaxError, SyntaxErrorKind}, 43 syntax_error::{Location, SyntaxError, SyntaxErrorKind},
45 syntax_node::{ 44 syntax_node::{
46 Direction, InsertPosition, SyntaxElement, SyntaxNode, SyntaxToken, SyntaxTreeBuilder, 45 Direction, InsertPosition, NodeOrToken, SyntaxElement, SyntaxNode, SyntaxToken,
47 WalkEvent, 46 SyntaxTreeBuilder, WalkEvent,
48 }, 47 },
49 syntax_text::SyntaxText,
50}; 48};
51pub use ra_parser::SyntaxKind; 49pub use ra_parser::SyntaxKind;
52pub use ra_parser::T; 50pub use ra_parser::T;
53pub use rowan::{SmolStr, TextRange, TextUnit}; 51pub use rowan::{SmolStr, SyntaxText, TextRange, TextUnit};
54 52
55/// `Parse` is the result of the parsing: a syntax tree and a collection of 53/// `Parse` is the result of the parsing: a syntax tree and a collection of
56/// errors. 54/// errors.
@@ -76,7 +74,7 @@ impl<T> Parse<T> {
76 } 74 }
77 75
78 pub fn syntax_node(&self) -> SyntaxNode { 76 pub fn syntax_node(&self) -> SyntaxNode {
79 SyntaxNode::new(self.green.clone()) 77 SyntaxNode::new_root(self.green.clone())
80 } 78 }
81} 79}
82 80
@@ -147,7 +145,7 @@ pub use crate::ast::SourceFile;
147 145
148impl SourceFile { 146impl SourceFile {
149 fn new(green: GreenNode) -> SourceFile { 147 fn new(green: GreenNode) -> SourceFile {
150 let root = SyntaxNode::new(green); 148 let root = SyntaxNode::new_root(green);
151 if cfg!(debug_assertions) { 149 if cfg!(debug_assertions) {
152 validation::validate_block_structure(&root); 150 validation::validate_block_structure(&root);
153 } 151 }
@@ -267,8 +265,8 @@ fn api_walkthrough() {
267 match event { 265 match event {
268 WalkEvent::Enter(node) => { 266 WalkEvent::Enter(node) => {
269 let text = match &node { 267 let text = match &node {
270 SyntaxElement::Node(it) => it.text().to_string(), 268 NodeOrToken::Node(it) => it.text().to_string(),
271 SyntaxElement::Token(it) => it.text().to_string(), 269 NodeOrToken::Token(it) => it.text().to_string(),
272 }; 270 };
273 buf += &format!("{:indent$}{:?} {:?}\n", " ", text, node.kind(), indent = indent); 271 buf += &format!("{:indent$}{:?} {:?}\n", " ", text, node.kind(), indent = indent);
274 indent += 2; 272 indent += 2;