diff options
Diffstat (limited to 'crates/ra_syntax/src/lib.rs')
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 54012b7b6..9f8066c70 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -61,12 +61,12 @@ pub use crate::{ | |||
61 | 61 | ||
62 | use crate::yellow::GreenNode; | 62 | use crate::yellow::GreenNode; |
63 | 63 | ||
64 | // TODO: pick a single name for everything. SourceFile maybe? | 64 | // TODO: pick a single name for everything. SourceFileNode maybe? |
65 | /// File represents a parse tree for a single Rust file. | 65 | /// File represents a parse tree for a single Rust file. |
66 | pub type File = ast::RootNode; | 66 | pub type SourceFileNode = ast::RootNode; |
67 | 67 | ||
68 | impl File { | 68 | impl SourceFileNode { |
69 | fn new(green: GreenNode, errors: Vec<SyntaxError>) -> File { | 69 | fn new(green: GreenNode, errors: Vec<SyntaxError>) -> SourceFileNode { |
70 | let root = SyntaxNode::new(green, errors); | 70 | let root = SyntaxNode::new(green, errors); |
71 | if cfg!(debug_assertions) { | 71 | if cfg!(debug_assertions) { |
72 | utils::validate_block_structure(root.borrowed()); | 72 | utils::validate_block_structure(root.borrowed()); |
@@ -74,24 +74,24 @@ impl File { | |||
74 | assert_eq!(root.kind(), SyntaxKind::ROOT); | 74 | assert_eq!(root.kind(), SyntaxKind::ROOT); |
75 | ast::RootNode { syntax: root } | 75 | ast::RootNode { syntax: root } |
76 | } | 76 | } |
77 | pub fn parse(text: &str) -> File { | 77 | pub fn parse(text: &str) -> SourceFileNode { |
78 | let tokens = tokenize(&text); | 78 | let tokens = tokenize(&text); |
79 | let (green, errors) = | 79 | let (green, errors) = |
80 | parser_impl::parse_with(yellow::GreenBuilder::new(), text, &tokens, grammar::root); | 80 | parser_impl::parse_with(yellow::GreenBuilder::new(), text, &tokens, grammar::root); |
81 | File::new(green, errors) | 81 | SourceFileNode::new(green, errors) |
82 | } | 82 | } |
83 | pub fn reparse(&self, edit: &AtomEdit) -> File { | 83 | pub fn reparse(&self, edit: &AtomEdit) -> SourceFileNode { |
84 | self.incremental_reparse(edit) | 84 | self.incremental_reparse(edit) |
85 | .unwrap_or_else(|| self.full_reparse(edit)) | 85 | .unwrap_or_else(|| self.full_reparse(edit)) |
86 | } | 86 | } |
87 | pub fn incremental_reparse(&self, edit: &AtomEdit) -> Option<File> { | 87 | pub fn incremental_reparse(&self, edit: &AtomEdit) -> Option<SourceFileNode> { |
88 | reparsing::incremental_reparse(self.syntax(), edit, self.errors()) | 88 | reparsing::incremental_reparse(self.syntax(), edit, self.errors()) |
89 | .map(|(green_node, errors)| File::new(green_node, errors)) | 89 | .map(|(green_node, errors)| SourceFileNode::new(green_node, errors)) |
90 | } | 90 | } |
91 | fn full_reparse(&self, edit: &AtomEdit) -> File { | 91 | fn full_reparse(&self, edit: &AtomEdit) -> SourceFileNode { |
92 | let text = | 92 | let text = |
93 | 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); |
94 | File::parse(&text) | 94 | SourceFileNode::parse(&text) |
95 | } | 95 | } |
96 | /// Typed AST representation of the parse tree. | 96 | /// Typed AST representation of the parse tree. |
97 | pub fn ast(&self) -> ast::Root { | 97 | pub fn ast(&self) -> ast::Root { |