diff options
-rw-r--r-- | crates/ra_syntax/Cargo.toml | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/crates/ra_syntax/Cargo.toml b/crates/ra_syntax/Cargo.toml index 043c9bacd..6c2e012ee 100644 --- a/crates/ra_syntax/Cargo.toml +++ b/crates/ra_syntax/Cargo.toml | |||
@@ -1,5 +1,5 @@ | |||
1 | [package] | 1 | [package] |
2 | edition = "2018" | 2 | edition = "2015" |
3 | name = "ra_syntax" | 3 | name = "ra_syntax" |
4 | version = "0.1.0" | 4 | version = "0.1.0" |
5 | authors = ["Aleksey Kladov <[email protected]>"] | 5 | authors = ["Aleksey Kladov <[email protected]>"] |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 8996eb921..acc2d9603 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -60,6 +60,7 @@ pub use crate::{ | |||
60 | 60 | ||
61 | use crate::yellow::GreenNode; | 61 | use crate::yellow::GreenNode; |
62 | 62 | ||
63 | /// File represents a parse tree for a single Rust file. | ||
63 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] | 64 | #[derive(Clone, Debug, Hash, PartialEq, Eq)] |
64 | pub struct File { | 65 | pub struct File { |
65 | root: SyntaxNode, | 66 | root: SyntaxNode, |
@@ -92,9 +93,11 @@ impl File { | |||
92 | text_utils::replace_range(self.syntax().text().to_string(), edit.delete, &edit.insert); | 93 | text_utils::replace_range(self.syntax().text().to_string(), edit.delete, &edit.insert); |
93 | File::parse(&text) | 94 | File::parse(&text) |
94 | } | 95 | } |
96 | /// Typed AST representation of the parse tree. | ||
95 | pub fn ast(&self) -> ast::Root { | 97 | pub fn ast(&self) -> ast::Root { |
96 | ast::Root::cast(self.syntax()).unwrap() | 98 | ast::Root::cast(self.syntax()).unwrap() |
97 | } | 99 | } |
100 | /// Untyped homogeneous representation of the parse tree. | ||
98 | pub fn syntax(&self) -> SyntaxNodeRef { | 101 | pub fn syntax(&self) -> SyntaxNodeRef { |
99 | self.root.borrowed() | 102 | self.root.borrowed() |
100 | } | 103 | } |