diff options
Diffstat (limited to 'crates/ra_analysis')
-rw-r--r-- | crates/ra_analysis/src/completion.rs | 10 | ||||
-rw-r--r-- | crates/ra_analysis/src/db.rs | 8 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/function/scope.rs | 6 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/module/scope.rs | 4 | ||||
-rw-r--r-- | crates/ra_analysis/src/imp.rs | 8 | ||||
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 14 | ||||
-rw-r--r-- | crates/ra_analysis/src/symbol_index.rs | 8 | ||||
-rw-r--r-- | crates/ra_analysis/src/syntax_ptr.rs | 6 |
8 files changed, 33 insertions, 31 deletions
diff --git a/crates/ra_analysis/src/completion.rs b/crates/ra_analysis/src/completion.rs index 7c3476e5c..689d4c92f 100644 --- a/crates/ra_analysis/src/completion.rs +++ b/crates/ra_analysis/src/completion.rs | |||
@@ -2,7 +2,7 @@ use ra_editor::find_node_at_offset; | |||
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | algo::visit::{visitor, visitor_ctx, Visitor, VisitorCtx}, | 3 | algo::visit::{visitor, visitor_ctx, Visitor, VisitorCtx}, |
4 | ast::{self, AstChildren, LoopBodyOwner, ModuleItemOwner}, | 4 | ast::{self, AstChildren, LoopBodyOwner, ModuleItemOwner}, |
5 | AstNode, AtomEdit, File, | 5 | AstNode, AtomEdit, SourceFileNode, |
6 | SyntaxKind::*, | 6 | SyntaxKind::*, |
7 | SyntaxNodeRef, TextUnit, | 7 | SyntaxNodeRef, TextUnit, |
8 | }; | 8 | }; |
@@ -63,7 +63,7 @@ pub(crate) fn resolve_based_completion( | |||
63 | pub(crate) fn find_target_module( | 63 | pub(crate) fn find_target_module( |
64 | module_tree: &ModuleTree, | 64 | module_tree: &ModuleTree, |
65 | module_id: ModuleId, | 65 | module_id: ModuleId, |
66 | file: &File, | 66 | file: &SourceFileNode, |
67 | offset: TextUnit, | 67 | offset: TextUnit, |
68 | ) -> Option<ModuleId> { | 68 | ) -> Option<ModuleId> { |
69 | let name_ref: ast::NameRef = find_node_at_offset(file.syntax(), offset)?; | 69 | let name_ref: ast::NameRef = find_node_at_offset(file.syntax(), offset)?; |
@@ -142,7 +142,7 @@ pub(crate) fn scope_completion( | |||
142 | } | 142 | } |
143 | 143 | ||
144 | fn complete_module_items( | 144 | fn complete_module_items( |
145 | file: &File, | 145 | file: &SourceFileNode, |
146 | items: AstChildren<ast::ModuleItem>, | 146 | items: AstChildren<ast::ModuleItem>, |
147 | this_item: Option<ast::NameRef>, | 147 | this_item: Option<ast::NameRef>, |
148 | acc: &mut Vec<CompletionItem>, | 148 | acc: &mut Vec<CompletionItem>, |
@@ -164,7 +164,7 @@ fn complete_module_items( | |||
164 | ); | 164 | ); |
165 | } | 165 | } |
166 | 166 | ||
167 | fn complete_name_ref(file: &File, name_ref: ast::NameRef, acc: &mut Vec<CompletionItem>) { | 167 | fn complete_name_ref(file: &SourceFileNode, name_ref: ast::NameRef, acc: &mut Vec<CompletionItem>) { |
168 | if !is_node::<ast::Path>(name_ref.syntax()) { | 168 | if !is_node::<ast::Path>(name_ref.syntax()) { |
169 | return; | 169 | return; |
170 | } | 170 | } |
@@ -239,7 +239,7 @@ fn is_node<'a, N: AstNode<'a>>(node: SyntaxNodeRef<'a>) -> bool { | |||
239 | } | 239 | } |
240 | 240 | ||
241 | fn complete_expr_keywords( | 241 | fn complete_expr_keywords( |
242 | file: &File, | 242 | file: &SourceFileNode, |
243 | fn_def: ast::FnDef, | 243 | fn_def: ast::FnDef, |
244 | name_ref: ast::NameRef, | 244 | name_ref: ast::NameRef, |
245 | acc: &mut Vec<CompletionItem>, | 245 | acc: &mut Vec<CompletionItem>, |
diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index 627512553..194f1a6b0 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use ra_editor::LineIndex; | 3 | use ra_editor::LineIndex; |
4 | use ra_syntax::{File, SyntaxNode}; | 4 | use ra_syntax::{SourceFileNode, SyntaxNode}; |
5 | use salsa::{self, Database}; | 5 | use salsa::{self, Database}; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
@@ -85,7 +85,7 @@ salsa::database_storage! { | |||
85 | 85 | ||
86 | salsa::query_group! { | 86 | salsa::query_group! { |
87 | pub(crate) trait SyntaxDatabase: crate::input::FilesDatabase { | 87 | pub(crate) trait SyntaxDatabase: crate::input::FilesDatabase { |
88 | fn file_syntax(file_id: FileId) -> File { | 88 | fn file_syntax(file_id: FileId) -> SourceFileNode { |
89 | type FileSyntaxQuery; | 89 | type FileSyntaxQuery; |
90 | } | 90 | } |
91 | fn file_lines(file_id: FileId) -> Arc<LineIndex> { | 91 | fn file_lines(file_id: FileId) -> Arc<LineIndex> { |
@@ -103,9 +103,9 @@ salsa::query_group! { | |||
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | fn file_syntax(db: &impl SyntaxDatabase, file_id: FileId) -> File { | 106 | fn file_syntax(db: &impl SyntaxDatabase, file_id: FileId) -> SourceFileNode { |
107 | let text = db.file_text(file_id); | 107 | let text = db.file_text(file_id); |
108 | File::parse(&*text) | 108 | SourceFileNode::parse(&*text) |
109 | } | 109 | } |
110 | fn file_lines(db: &impl SyntaxDatabase, file_id: FileId) -> Arc<LineIndex> { | 110 | fn file_lines(db: &impl SyntaxDatabase, file_id: FileId) -> Arc<LineIndex> { |
111 | let text = db.file_text(file_id); | 111 | let text = db.file_text(file_id); |
diff --git a/crates/ra_analysis/src/descriptors/function/scope.rs b/crates/ra_analysis/src/descriptors/function/scope.rs index 62b46ffba..bbe16947c 100644 --- a/crates/ra_analysis/src/descriptors/function/scope.rs +++ b/crates/ra_analysis/src/descriptors/function/scope.rs | |||
@@ -272,7 +272,7 @@ pub fn resolve_local_name<'a>( | |||
272 | #[cfg(test)] | 272 | #[cfg(test)] |
273 | mod tests { | 273 | mod tests { |
274 | use ra_editor::find_node_at_offset; | 274 | use ra_editor::find_node_at_offset; |
275 | use ra_syntax::File; | 275 | use ra_syntax::SourceFileNode; |
276 | use test_utils::extract_offset; | 276 | use test_utils::extract_offset; |
277 | 277 | ||
278 | use super::*; | 278 | use super::*; |
@@ -287,7 +287,7 @@ mod tests { | |||
287 | buf.push_str(&code[off..]); | 287 | buf.push_str(&code[off..]); |
288 | buf | 288 | buf |
289 | }; | 289 | }; |
290 | let file = File::parse(&code); | 290 | let file = SourceFileNode::parse(&code); |
291 | let marker: ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap(); | 291 | let marker: ast::PathExpr = find_node_at_offset(file.syntax(), off).unwrap(); |
292 | let fn_def: ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); | 292 | let fn_def: ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); |
293 | let scopes = FnScopes::new(fn_def); | 293 | let scopes = FnScopes::new(fn_def); |
@@ -376,7 +376,7 @@ mod tests { | |||
376 | 376 | ||
377 | fn do_check_local_name(code: &str, expected_offset: u32) { | 377 | fn do_check_local_name(code: &str, expected_offset: u32) { |
378 | let (off, code) = extract_offset(code); | 378 | let (off, code) = extract_offset(code); |
379 | let file = File::parse(&code); | 379 | let file = SourceFileNode::parse(&code); |
380 | let fn_def: ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); | 380 | let fn_def: ast::FnDef = find_node_at_offset(file.syntax(), off).unwrap(); |
381 | let name_ref: ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); | 381 | let name_ref: ast::NameRef = find_node_at_offset(file.syntax(), off).unwrap(); |
382 | 382 | ||
diff --git a/crates/ra_analysis/src/descriptors/module/scope.rs b/crates/ra_analysis/src/descriptors/module/scope.rs index 215b31f8e..5fcbc3cb0 100644 --- a/crates/ra_analysis/src/descriptors/module/scope.rs +++ b/crates/ra_analysis/src/descriptors/module/scope.rs | |||
@@ -95,10 +95,10 @@ fn collect_imports(tree: ast::UseTree, acc: &mut Vec<Entry>) { | |||
95 | #[cfg(test)] | 95 | #[cfg(test)] |
96 | mod tests { | 96 | mod tests { |
97 | use super::*; | 97 | use super::*; |
98 | use ra_syntax::{ast::ModuleItemOwner, File}; | 98 | use ra_syntax::{ast::ModuleItemOwner, SourceFileNode}; |
99 | 99 | ||
100 | fn do_check(code: &str, expected: &[&str]) { | 100 | fn do_check(code: &str, expected: &[&str]) { |
101 | let file = File::parse(&code); | 101 | let file = SourceFileNode::parse(&code); |
102 | let scope = ModuleScope::new(file.ast().items()); | 102 | let scope = ModuleScope::new(file.ast().items()); |
103 | let actual = scope.entries.iter().map(|it| it.name()).collect::<Vec<_>>(); | 103 | let actual = scope.entries.iter().map(|it| it.name()).collect::<Vec<_>>(); |
104 | assert_eq!(expected, actual.as_slice()); | 104 | assert_eq!(expected, actual.as_slice()); |
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 166f1484f..00c4a08bd 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs | |||
@@ -7,7 +7,7 @@ use std::{ | |||
7 | use ra_editor::{self, find_node_at_offset, FileSymbol, LineIndex, LocalEdit}; | 7 | use ra_editor::{self, find_node_at_offset, FileSymbol, LineIndex, LocalEdit}; |
8 | use ra_syntax::{ | 8 | use ra_syntax::{ |
9 | ast::{self, ArgListOwner, Expr, NameOwner}, | 9 | ast::{self, ArgListOwner, Expr, NameOwner}, |
10 | AstNode, File, SmolStr, | 10 | AstNode, SourceFileNode, SmolStr, |
11 | SyntaxKind::*, | 11 | SyntaxKind::*, |
12 | SyntaxNodeRef, TextRange, TextUnit, | 12 | SyntaxNodeRef, TextRange, TextUnit, |
13 | }; | 13 | }; |
@@ -27,7 +27,7 @@ use crate::{ | |||
27 | input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, | 27 | input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, |
28 | symbol_index::SymbolIndex, | 28 | symbol_index::SymbolIndex, |
29 | AnalysisChange, Cancelable, CrateGraph, CrateId, Diagnostic, FileId, FileResolver, | 29 | AnalysisChange, Cancelable, CrateGraph, CrateId, Diagnostic, FileId, FileResolver, |
30 | FileSystemEdit, FilePosition, Query, SourceChange, SourceFileEdit, | 30 | FileSystemEdit, FilePosition, Query, SourceChange, SourceFileNodeEdit, |
31 | }; | 31 | }; |
32 | 32 | ||
33 | #[derive(Clone, Debug)] | 33 | #[derive(Clone, Debug)] |
@@ -180,7 +180,7 @@ impl fmt::Debug for AnalysisImpl { | |||
180 | } | 180 | } |
181 | 181 | ||
182 | impl AnalysisImpl { | 182 | impl AnalysisImpl { |
183 | pub fn file_syntax(&self, file_id: FileId) -> File { | 183 | pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode { |
184 | self.db.file_syntax(file_id) | 184 | self.db.file_syntax(file_id) |
185 | } | 185 | } |
186 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 186 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
@@ -562,7 +562,7 @@ impl AnalysisImpl { | |||
562 | 562 | ||
563 | impl SourceChange { | 563 | impl SourceChange { |
564 | pub(crate) fn from_local_edit(file_id: FileId, label: &str, edit: LocalEdit) -> SourceChange { | 564 | pub(crate) fn from_local_edit(file_id: FileId, label: &str, edit: LocalEdit) -> SourceChange { |
565 | let file_edit = SourceFileEdit { | 565 | let file_edit = SourceFileNodeEdit { |
566 | file_id, | 566 | file_id, |
567 | edits: edit.edit.into_atoms(), | 567 | edits: edit.edit.into_atoms(), |
568 | }; | 568 | }; |
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index 9475c938d..ad0273edc 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -20,7 +20,7 @@ pub mod mock_analysis; | |||
20 | 20 | ||
21 | use std::{fmt, sync::Arc}; | 21 | use std::{fmt, sync::Arc}; |
22 | 22 | ||
23 | use ra_syntax::{AtomEdit, File, TextRange, TextUnit}; | 23 | use ra_syntax::{AtomEdit, SourceFileNode, TextRange, TextUnit}; |
24 | use rayon::prelude::*; | 24 | use rayon::prelude::*; |
25 | use relative_path::RelativePathBuf; | 25 | use relative_path::RelativePathBuf; |
26 | 26 | ||
@@ -128,13 +128,13 @@ pub struct FilePosition { | |||
128 | #[derive(Debug)] | 128 | #[derive(Debug)] |
129 | pub struct SourceChange { | 129 | pub struct SourceChange { |
130 | pub label: String, | 130 | pub label: String, |
131 | pub source_file_edits: Vec<SourceFileEdit>, | 131 | pub source_file_edits: Vec<SourceFileNodeEdit>, |
132 | pub file_system_edits: Vec<FileSystemEdit>, | 132 | pub file_system_edits: Vec<FileSystemEdit>, |
133 | pub cursor_position: Option<FilePosition>, | 133 | pub cursor_position: Option<FilePosition>, |
134 | } | 134 | } |
135 | 135 | ||
136 | #[derive(Debug)] | 136 | #[derive(Debug)] |
137 | pub struct SourceFileEdit { | 137 | pub struct SourceFileNodeEdit { |
138 | pub file_id: FileId, | 138 | pub file_id: FileId, |
139 | pub edits: Vec<AtomEdit>, | 139 | pub edits: Vec<AtomEdit>, |
140 | } | 140 | } |
@@ -204,16 +204,16 @@ pub struct Analysis { | |||
204 | } | 204 | } |
205 | 205 | ||
206 | impl Analysis { | 206 | impl Analysis { |
207 | pub fn file_syntax(&self, file_id: FileId) -> File { | 207 | pub fn file_syntax(&self, file_id: FileId) -> SourceFileNode { |
208 | self.imp.file_syntax(file_id).clone() | 208 | self.imp.file_syntax(file_id).clone() |
209 | } | 209 | } |
210 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { | 210 | pub fn file_line_index(&self, file_id: FileId) -> Arc<LineIndex> { |
211 | self.imp.file_line_index(file_id) | 211 | self.imp.file_line_index(file_id) |
212 | } | 212 | } |
213 | pub fn extend_selection(&self, file: &File, range: TextRange) -> TextRange { | 213 | pub fn extend_selection(&self, file: &SourceFileNode, range: TextRange) -> TextRange { |
214 | ra_editor::extend_selection(file, range).unwrap_or(range) | 214 | ra_editor::extend_selection(file, range).unwrap_or(range) |
215 | } | 215 | } |
216 | pub fn matching_brace(&self, file: &File, offset: TextUnit) -> Option<TextUnit> { | 216 | pub fn matching_brace(&self, file: &SourceFileNode, offset: TextUnit) -> Option<TextUnit> { |
217 | ra_editor::matching_brace(file, offset) | 217 | ra_editor::matching_brace(file, offset) |
218 | } | 218 | } |
219 | pub fn syntax_tree(&self, file_id: FileId) -> String { | 219 | pub fn syntax_tree(&self, file_id: FileId) -> String { |
@@ -309,7 +309,7 @@ pub struct LibraryData { | |||
309 | impl LibraryData { | 309 | impl LibraryData { |
310 | pub fn prepare(files: Vec<(FileId, String)>, file_resolver: Arc<FileResolver>) -> LibraryData { | 310 | pub fn prepare(files: Vec<(FileId, String)>, file_resolver: Arc<FileResolver>) -> LibraryData { |
311 | let symbol_index = SymbolIndex::for_files(files.par_iter().map(|(file_id, text)| { | 311 | let symbol_index = SymbolIndex::for_files(files.par_iter().map(|(file_id, text)| { |
312 | let file = File::parse(text); | 312 | let file = SourceFileNode::parse(text); |
313 | (*file_id, file) | 313 | (*file_id, file) |
314 | })); | 314 | })); |
315 | LibraryData { | 315 | LibraryData { |
diff --git a/crates/ra_analysis/src/symbol_index.rs b/crates/ra_analysis/src/symbol_index.rs index b57ad5d33..3a0667ecd 100644 --- a/crates/ra_analysis/src/symbol_index.rs +++ b/crates/ra_analysis/src/symbol_index.rs | |||
@@ -6,7 +6,7 @@ use std::{ | |||
6 | use fst::{self, Streamer}; | 6 | use fst::{self, Streamer}; |
7 | use ra_editor::{file_symbols, FileSymbol}; | 7 | use ra_editor::{file_symbols, FileSymbol}; |
8 | use ra_syntax::{ | 8 | use ra_syntax::{ |
9 | File, | 9 | SourceFileNode, |
10 | SyntaxKind::{self, *}, | 10 | SyntaxKind::{self, *}, |
11 | }; | 11 | }; |
12 | use rayon::prelude::*; | 12 | use rayon::prelude::*; |
@@ -34,7 +34,9 @@ impl Hash for SymbolIndex { | |||
34 | } | 34 | } |
35 | 35 | ||
36 | impl SymbolIndex { | 36 | impl SymbolIndex { |
37 | pub(crate) fn for_files(files: impl ParallelIterator<Item = (FileId, File)>) -> SymbolIndex { | 37 | pub(crate) fn for_files( |
38 | files: impl ParallelIterator<Item = (FileId, SourceFileNode)>, | ||
39 | ) -> SymbolIndex { | ||
38 | let mut symbols = files | 40 | let mut symbols = files |
39 | .flat_map(|(file_id, file)| { | 41 | .flat_map(|(file_id, file)| { |
40 | file_symbols(&file) | 42 | file_symbols(&file) |
@@ -51,7 +53,7 @@ impl SymbolIndex { | |||
51 | SymbolIndex { symbols, map } | 53 | SymbolIndex { symbols, map } |
52 | } | 54 | } |
53 | 55 | ||
54 | pub(crate) fn for_file(file_id: FileId, file: File) -> SymbolIndex { | 56 | pub(crate) fn for_file(file_id: FileId, file: SourceFileNode) -> SymbolIndex { |
55 | SymbolIndex::for_files(rayon::iter::once((file_id, file))) | 57 | SymbolIndex::for_files(rayon::iter::once((file_id, file))) |
56 | } | 58 | } |
57 | } | 59 | } |
diff --git a/crates/ra_analysis/src/syntax_ptr.rs b/crates/ra_analysis/src/syntax_ptr.rs index 4afb1fc93..e45934ce0 100644 --- a/crates/ra_analysis/src/syntax_ptr.rs +++ b/crates/ra_analysis/src/syntax_ptr.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_syntax::{File, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange}; | 1 | use ra_syntax::{SourceFileNode, SyntaxKind, SyntaxNode, SyntaxNodeRef, TextRange}; |
2 | 2 | ||
3 | use crate::db::SyntaxDatabase; | 3 | use crate::db::SyntaxDatabase; |
4 | use crate::FileId; | 4 | use crate::FileId; |
@@ -43,7 +43,7 @@ impl LocalSyntaxPtr { | |||
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
46 | pub(crate) fn resolve(self, file: &File) -> SyntaxNode { | 46 | pub(crate) fn resolve(self, file: &SourceFileNode) -> SyntaxNode { |
47 | let mut curr = file.syntax(); | 47 | let mut curr = file.syntax(); |
48 | loop { | 48 | loop { |
49 | if curr.range() == self.range && curr.kind() == self.kind { | 49 | if curr.range() == self.range && curr.kind() == self.kind { |
@@ -67,7 +67,7 @@ impl LocalSyntaxPtr { | |||
67 | #[test] | 67 | #[test] |
68 | fn test_local_syntax_ptr() { | 68 | fn test_local_syntax_ptr() { |
69 | use ra_syntax::{ast, AstNode}; | 69 | use ra_syntax::{ast, AstNode}; |
70 | let file = File::parse("struct Foo { f: u32, }"); | 70 | let file = SourceFileNode::parse("struct Foo { f: u32, }"); |
71 | let field = file | 71 | let field = file |
72 | .syntax() | 72 | .syntax() |
73 | .descendants() | 73 | .descendants() |