diff options
Diffstat (limited to 'crates/libanalysis')
-rw-r--r-- | crates/libanalysis/src/lib.rs | 26 | ||||
-rw-r--r-- | crates/libanalysis/src/symbol_index.rs | 4 |
2 files changed, 15 insertions, 15 deletions
diff --git a/crates/libanalysis/src/lib.rs b/crates/libanalysis/src/lib.rs index ae96a0d62..15a433afc 100644 --- a/crates/libanalysis/src/lib.rs +++ b/crates/libanalysis/src/lib.rs | |||
@@ -26,8 +26,8 @@ use std::{ | |||
26 | }; | 26 | }; |
27 | 27 | ||
28 | use libsyntax2::{ | 28 | use libsyntax2::{ |
29 | TextUnit, TextRange, RefRoot, | 29 | TextUnit, TextRange, |
30 | ast::{self, AstNode, NameOwner}, | 30 | ast::{self, AstNode, NameOwner, ParsedFile}, |
31 | SyntaxKind::*, | 31 | SyntaxKind::*, |
32 | }; | 32 | }; |
33 | use libeditor::{LineIndex, FileSymbol, find_node}; | 33 | use libeditor::{LineIndex, FileSymbol, find_node}; |
@@ -109,7 +109,7 @@ impl WorldState { | |||
109 | 109 | ||
110 | 110 | ||
111 | impl World { | 111 | impl World { |
112 | pub fn file_syntax(&self, file_id: FileId) -> Result<ast::File> { | 112 | pub fn file_syntax(&self, file_id: FileId) -> Result<ParsedFile> { |
113 | let data = self.file_data(file_id)?; | 113 | let data = self.file_data(file_id)?; |
114 | Ok(data.syntax().clone()) | 114 | Ok(data.syntax().clone()) |
115 | } | 115 | } |
@@ -137,11 +137,11 @@ impl World { | |||
137 | offset: TextUnit, | 137 | offset: TextUnit, |
138 | ) -> Result<Vec<(FileId, FileSymbol)>> { | 138 | ) -> Result<Vec<(FileId, FileSymbol)>> { |
139 | let file = self.file_syntax(id)?; | 139 | let file = self.file_syntax(id)?; |
140 | let syntax = file.syntax_ref(); | 140 | let syntax = file.syntax(); |
141 | if let Some(name_ref) = find_node::<ast::NameRef<_>>(syntax, offset) { | 141 | if let Some(name_ref) = find_node::<ast::NameRef>(syntax, offset) { |
142 | return Ok(self.index_resolve(name_ref)); | 142 | return Ok(self.index_resolve(name_ref)); |
143 | } | 143 | } |
144 | if let Some(name) = find_node::<ast::Name<_>>(syntax, offset) { | 144 | if let Some(name) = find_node::<ast::Name>(syntax, offset) { |
145 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { | 145 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { |
146 | if module.has_semi() { | 146 | if module.has_semi() { |
147 | return Ok(self.resolve_module(id, module)); | 147 | return Ok(self.resolve_module(id, module)); |
@@ -151,7 +151,7 @@ impl World { | |||
151 | Ok(vec![]) | 151 | Ok(vec![]) |
152 | } | 152 | } |
153 | 153 | ||
154 | fn index_resolve(&self, name_ref: ast::NameRef<RefRoot>) -> Vec<(FileId, FileSymbol)> { | 154 | fn index_resolve(&self, name_ref: ast::NameRef) -> Vec<(FileId, FileSymbol)> { |
155 | let name = name_ref.text(); | 155 | let name = name_ref.text(); |
156 | let mut query = Query::new(name.to_string()); | 156 | let mut query = Query::new(name.to_string()); |
157 | query.exact(); | 157 | query.exact(); |
@@ -159,7 +159,7 @@ impl World { | |||
159 | self.world_symbols(query) | 159 | self.world_symbols(query) |
160 | } | 160 | } |
161 | 161 | ||
162 | fn resolve_module(&self, id: FileId, module: ast::Module<RefRoot>) -> Vec<(FileId, FileSymbol)> { | 162 | fn resolve_module(&self, id: FileId, module: ast::Module) -> Vec<(FileId, FileSymbol)> { |
163 | let name = match module.name() { | 163 | let name = match module.name() { |
164 | Some(name) => name.text(), | 164 | Some(name) => name.text(), |
165 | None => return Vec::new(), | 165 | None => return Vec::new(), |
@@ -220,7 +220,7 @@ struct WorldData { | |||
220 | struct FileData { | 220 | struct FileData { |
221 | text: String, | 221 | text: String, |
222 | symbols: OnceCell<FileSymbols>, | 222 | symbols: OnceCell<FileSymbols>, |
223 | syntax: OnceCell<ast::File>, | 223 | syntax: OnceCell<ParsedFile>, |
224 | lines: OnceCell<LineIndex>, | 224 | lines: OnceCell<LineIndex>, |
225 | } | 225 | } |
226 | 226 | ||
@@ -234,14 +234,14 @@ impl FileData { | |||
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
237 | fn syntax(&self) -> &ast::File { | 237 | fn syntax(&self) -> &ParsedFile { |
238 | self.syntax | 238 | self.syntax |
239 | .get_or_init(|| ast::File::parse(&self.text)) | 239 | .get_or_init(|| ParsedFile::parse(&self.text)) |
240 | } | 240 | } |
241 | 241 | ||
242 | fn syntax_transient(&self) -> ast::File { | 242 | fn syntax_transient(&self) -> ParsedFile { |
243 | self.syntax.get().map(|s| s.clone()) | 243 | self.syntax.get().map(|s| s.clone()) |
244 | .unwrap_or_else(|| ast::File::parse(&self.text)) | 244 | .unwrap_or_else(|| ParsedFile::parse(&self.text)) |
245 | } | 245 | } |
246 | 246 | ||
247 | fn symbols(&self) -> &FileSymbols { | 247 | fn symbols(&self) -> &FileSymbols { |
diff --git a/crates/libanalysis/src/symbol_index.rs b/crates/libanalysis/src/symbol_index.rs index 3c3252956..426de4c76 100644 --- a/crates/libanalysis/src/symbol_index.rs +++ b/crates/libanalysis/src/symbol_index.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use libeditor::{FileSymbol, file_symbols}; | 1 | use libeditor::{FileSymbol, file_symbols}; |
2 | use libsyntax2::{ | 2 | use libsyntax2::{ |
3 | ast, | 3 | ParsedFile, |
4 | SyntaxKind::{self, *}, | 4 | SyntaxKind::{self, *}, |
5 | }; | 5 | }; |
6 | use fst::{self, IntoStreamer, Streamer}; | 6 | use fst::{self, IntoStreamer, Streamer}; |
@@ -12,7 +12,7 @@ pub(crate) struct FileSymbols { | |||
12 | } | 12 | } |
13 | 13 | ||
14 | impl FileSymbols { | 14 | impl FileSymbols { |
15 | pub(crate) fn new(file: &ast::File) -> FileSymbols { | 15 | pub(crate) fn new(file: &ParsedFile) -> FileSymbols { |
16 | let mut symbols = file_symbols(file) | 16 | let mut symbols = file_symbols(file) |
17 | .into_iter() | 17 | .into_iter() |
18 | .map(|s| (s.name.as_str().to_lowercase(), s)) | 18 | .map(|s| (s.name.as_str().to_lowercase(), s)) |