aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/imp.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-02 14:26:06 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-02 14:26:06 +0000
commit29d8bfb9c909847cb37ff6e564ea0e61744277ad (patch)
tree53e4d51b9a80330e3ebb53959ed2a2a67a605fbf /crates/ra_analysis/src/imp.rs
parentafa972e78d2d81598c02b742ab84d70c88208300 (diff)
parent76910639e6930d1d76ec0a5d7c11219e073b73be (diff)
Merge #404
404: Move FileSymbol to ra_analysis r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_analysis/src/imp.rs')
-rw-r--r--crates/ra_analysis/src/imp.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs
index ec7da437a..8071554a7 100644
--- a/crates/ra_analysis/src/imp.rs
+++ b/crates/ra_analysis/src/imp.rs
@@ -10,7 +10,7 @@ use hir::{
10 self, FnSignatureInfo, Problem, source_binder, 10 self, FnSignatureInfo, Problem, source_binder,
11}; 11};
12use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase}; 12use ra_db::{FilesDatabase, SourceRoot, SourceRootId, SyntaxDatabase};
13use ra_editor::{self, FileSymbol, find_node_at_offset, LineIndex, LocalEdit, Severity}; 13use ra_editor::{self, find_node_at_offset, LineIndex, LocalEdit, Severity};
14use ra_syntax::{ 14use ra_syntax::{
15 algo::find_covering_node, 15 algo::find_covering_node,
16 ast::{self, ArgListOwner, Expr, FnDef, NameOwner}, 16 ast::{self, ArgListOwner, Expr, FnDef, NameOwner},
@@ -21,11 +21,11 @@ use ra_syntax::{
21 21
22use crate::{ 22use crate::{
23 AnalysisChange, 23 AnalysisChange,
24 Cancelable, 24 Cancelable, NavigationTarget,
25 completion::{CompletionItem, completions}, 25 completion::{CompletionItem, completions},
26 CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit, 26 CrateId, db, Diagnostic, FileId, FilePosition, FileRange, FileSystemEdit,
27 Query, ReferenceResolution, RootChange, SourceChange, SourceFileEdit, 27 Query, ReferenceResolution, RootChange, SourceChange, SourceFileEdit,
28 symbol_index::{LibrarySymbolsQuery, SymbolIndex, SymbolsDatabase}, 28 symbol_index::{LibrarySymbolsQuery, SymbolIndex, SymbolsDatabase, FileSymbol},
29}; 29};
30 30
31#[derive(Debug, Default)] 31#[derive(Debug, Default)]
@@ -205,7 +205,7 @@ impl AnalysisImpl {
205 205
206 /// This returns `Vec` because a module may be included from several places. We 206 /// This returns `Vec` because a module may be included from several places. We
207 /// don't handle this case yet though, so the Vec has length at most one. 207 /// don't handle this case yet though, so the Vec has length at most one.
208 pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<(FileId, FileSymbol)>> { 208 pub fn parent_module(&self, position: FilePosition) -> Cancelable<Vec<NavigationTarget>> {
209 let descr = match source_binder::module_from_position(&*self.db, position)? { 209 let descr = match source_binder::module_from_position(&*self.db, position)? {
210 None => return Ok(Vec::new()), 210 None => return Ok(Vec::new()),
211 Some(it) => it, 211 Some(it) => it,
@@ -216,12 +216,12 @@ impl AnalysisImpl {
216 }; 216 };
217 let decl = decl.borrowed(); 217 let decl = decl.borrowed();
218 let decl_name = decl.name().unwrap(); 218 let decl_name = decl.name().unwrap();
219 let sym = FileSymbol { 219 let symbol = FileSymbol {
220 name: decl_name.text(), 220 name: decl_name.text(),
221 node_range: decl_name.syntax().range(), 221 node_range: decl_name.syntax().range(),
222 kind: MODULE, 222 kind: MODULE,
223 }; 223 };
224 Ok(vec![(file_id, sym)]) 224 Ok(vec![NavigationTarget { file_id, symbol }])
225 } 225 }
226 /// Returns `Vec` for the same reason as `parent_module` 226 /// Returns `Vec` for the same reason as `parent_module`
227 pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> { 227 pub fn crate_for(&self, file_id: FileId) -> Cancelable<Vec<CrateId>> {
@@ -355,9 +355,9 @@ impl AnalysisImpl {
355 Ok(Some((binding, descr))) 355 Ok(Some((binding, descr)))
356 } 356 }
357 } 357 }
358 pub fn doc_text_for(&self, file_id: FileId, symbol: FileSymbol) -> Cancelable<Option<String>> { 358 pub fn doc_text_for(&self, nav: NavigationTarget) -> Cancelable<Option<String>> {
359 let file = self.db.source_file(file_id); 359 let file = self.db.source_file(nav.file_id);
360 let result = match (symbol.description(&file), symbol.docs(&file)) { 360 let result = match (nav.symbol.description(&file), nav.symbol.docs(&file)) {
361 (Some(desc), Some(docs)) => { 361 (Some(desc), Some(docs)) => {
362 Some("```rust\n".to_string() + &*desc + "\n```\n\n" + &*docs) 362 Some("```rust\n".to_string() + &*desc + "\n```\n\n" + &*docs)
363 } 363 }