diff options
author | Aleksey Kladov <[email protected]> | 2018-10-25 15:52:50 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-10-25 15:52:50 +0100 |
commit | d19001957172287afee90bd4fc3d037d2ce6f5dd (patch) | |
tree | bbcc2302fa6c44d5fc2a07f2c81a3de9123d643c /crates/ra_analysis/src/lib.rs | |
parent | 5ef3fda5e165cbc079f731e459635df0a714b778 (diff) |
Move input to top-level
Diffstat (limited to 'crates/ra_analysis/src/lib.rs')
-rw-r--r-- | crates/ra_analysis/src/lib.rs | 33 |
1 files changed, 3 insertions, 30 deletions
diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index af7894cd0..a67cac21e 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs | |||
@@ -6,6 +6,7 @@ extern crate relative_path; | |||
6 | extern crate rustc_hash; | 6 | extern crate rustc_hash; |
7 | extern crate salsa; | 7 | extern crate salsa; |
8 | 8 | ||
9 | mod input; | ||
9 | mod db; | 10 | mod db; |
10 | mod descriptors; | 11 | mod descriptors; |
11 | mod imp; | 12 | mod imp; |
@@ -17,9 +18,8 @@ use std::{ | |||
17 | sync::Arc, | 18 | sync::Arc, |
18 | }; | 19 | }; |
19 | 20 | ||
20 | use rustc_hash::FxHashMap; | ||
21 | use ra_syntax::{AtomEdit, File, TextRange, TextUnit}; | 21 | use ra_syntax::{AtomEdit, File, TextRange, TextUnit}; |
22 | use relative_path::{RelativePath, RelativePathBuf}; | 22 | use relative_path::RelativePathBuf; |
23 | use rayon::prelude::*; | 23 | use rayon::prelude::*; |
24 | 24 | ||
25 | use crate::{ | 25 | use crate::{ |
@@ -29,6 +29,7 @@ use crate::{ | |||
29 | 29 | ||
30 | pub use crate::{ | 30 | pub use crate::{ |
31 | descriptors::FnDescriptor, | 31 | descriptors::FnDescriptor, |
32 | input::{FileId, FileResolver, CrateGraph, CrateId} | ||
32 | }; | 33 | }; |
33 | pub use ra_editor::{ | 34 | pub use ra_editor::{ |
34 | CompletionItem, FileSymbol, Fold, FoldKind, HighlightedRange, LineIndex, Runnable, | 35 | CompletionItem, FileSymbol, Fold, FoldKind, HighlightedRange, LineIndex, Runnable, |
@@ -49,34 +50,6 @@ impl std::fmt::Display for Canceled { | |||
49 | impl std::error::Error for Canceled { | 50 | impl std::error::Error for Canceled { |
50 | } | 51 | } |
51 | 52 | ||
52 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
53 | pub struct FileId(pub u32); | ||
54 | |||
55 | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | ||
56 | pub struct CrateId(pub u32); | ||
57 | |||
58 | #[derive(Debug, Clone, Default, PartialEq, Eq)] | ||
59 | pub struct CrateGraph { | ||
60 | crate_roots: FxHashMap<CrateId, FileId>, | ||
61 | } | ||
62 | |||
63 | impl CrateGraph { | ||
64 | pub fn new() -> CrateGraph { | ||
65 | CrateGraph::default() | ||
66 | } | ||
67 | pub fn add_crate_root(&mut self, file_id: FileId) -> CrateId{ | ||
68 | let crate_id = CrateId(self.crate_roots.len() as u32); | ||
69 | let prev = self.crate_roots.insert(crate_id, file_id); | ||
70 | assert!(prev.is_none()); | ||
71 | crate_id | ||
72 | } | ||
73 | } | ||
74 | |||
75 | pub trait FileResolver: fmt::Debug + Send + Sync + 'static { | ||
76 | fn file_stem(&self, file_id: FileId) -> String; | ||
77 | fn resolve(&self, file_id: FileId, path: &RelativePath) -> Option<FileId>; | ||
78 | } | ||
79 | |||
80 | #[derive(Default)] | 53 | #[derive(Default)] |
81 | pub struct AnalysisChange { | 54 | pub struct AnalysisChange { |
82 | files_added: Vec<(FileId, String)>, | 55 | files_added: Vec<(FileId, String)>, |