diff options
Diffstat (limited to 'crates/ra_ide/src/lib.rs')
-rw-r--r-- | crates/ra_ide/src/lib.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 51dc1f041..ecac5134e 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -47,7 +47,7 @@ use std::sync::Arc; | |||
47 | use ra_cfg::CfgOptions; | 47 | use ra_cfg::CfgOptions; |
48 | use ra_db::{ | 48 | use ra_db::{ |
49 | salsa::{self, ParallelDatabase}, | 49 | salsa::{self, ParallelDatabase}, |
50 | CheckCanceled, Env, FileLoader, SourceDatabase, | 50 | CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, |
51 | }; | 51 | }; |
52 | use ra_ide_db::{ | 52 | use ra_ide_db::{ |
53 | symbol_index::{self, FileSymbol}, | 53 | symbol_index::{self, FileSymbol}, |
@@ -66,11 +66,10 @@ pub use crate::{ | |||
66 | display::{file_structure, FunctionSignature, NavigationTarget, StructureNode}, | 66 | display::{file_structure, FunctionSignature, NavigationTarget, StructureNode}, |
67 | expand_macro::ExpandedMacro, | 67 | expand_macro::ExpandedMacro, |
68 | folding_ranges::{Fold, FoldKind}, | 68 | folding_ranges::{Fold, FoldKind}, |
69 | hover::{HoverAction, HoverConfig, HoverResult}, | 69 | hover::{HoverAction, HoverConfig, HoverGotoTypeData, HoverResult}, |
70 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, | 70 | inlay_hints::{InlayHint, InlayHintsConfig, InlayKind}, |
71 | references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult}, | 71 | references::{Declaration, Reference, ReferenceAccess, ReferenceKind, ReferenceSearchResult}, |
72 | runnables::{Runnable, RunnableKind, TestId}, | 72 | runnables::{Runnable, RunnableKind, TestId}, |
73 | ssr::SsrError, | ||
74 | syntax_highlighting::{ | 73 | syntax_highlighting::{ |
75 | Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange, | 74 | Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange, |
76 | }, | 75 | }, |
@@ -79,7 +78,8 @@ pub use crate::{ | |||
79 | pub use hir::Documentation; | 78 | pub use hir::Documentation; |
80 | pub use ra_assists::{Assist, AssistConfig, AssistId, ResolvedAssist}; | 79 | pub use ra_assists::{Assist, AssistConfig, AssistId, ResolvedAssist}; |
81 | pub use ra_db::{ | 80 | pub use ra_db::{ |
82 | Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRootId, | 81 | Canceled, CrateGraph, CrateId, Edition, FileId, FilePosition, FileRange, SourceRoot, |
82 | SourceRootId, | ||
83 | }; | 83 | }; |
84 | pub use ra_ide_db::{ | 84 | pub use ra_ide_db::{ |
85 | change::AnalysisChange, | 85 | change::AnalysisChange, |
@@ -89,6 +89,7 @@ pub use ra_ide_db::{ | |||
89 | symbol_index::Query, | 89 | symbol_index::Query, |
90 | RootDatabase, | 90 | RootDatabase, |
91 | }; | 91 | }; |
92 | pub use ra_ssr::SsrError; | ||
92 | pub use ra_text_edit::{Indel, TextEdit}; | 93 | pub use ra_text_edit::{Indel, TextEdit}; |
93 | 94 | ||
94 | pub type Cancelable<T> = Result<T, Canceled>; | 95 | pub type Cancelable<T> = Result<T, Canceled>; |
@@ -212,11 +213,14 @@ impl Analysis { | |||
212 | // `AnalysisHost` for creating a fully-featured analysis. | 213 | // `AnalysisHost` for creating a fully-featured analysis. |
213 | pub fn from_single_file(text: String) -> (Analysis, FileId) { | 214 | pub fn from_single_file(text: String) -> (Analysis, FileId) { |
214 | let mut host = AnalysisHost::default(); | 215 | let mut host = AnalysisHost::default(); |
215 | let source_root = SourceRootId(0); | 216 | let file_id = FileId(0); |
217 | let mut file_set = FileSet::default(); | ||
218 | file_set.insert(file_id, VfsPath::new_virtual_path("/main.rs".to_string())); | ||
219 | let source_root = SourceRoot::new_local(file_set); | ||
220 | |||
216 | let mut change = AnalysisChange::new(); | 221 | let mut change = AnalysisChange::new(); |
217 | change.add_root(source_root, true); | 222 | change.set_roots(vec![source_root]); |
218 | let mut crate_graph = CrateGraph::default(); | 223 | let mut crate_graph = CrateGraph::default(); |
219 | let file_id = FileId(0); | ||
220 | // FIXME: cfg options | 224 | // FIXME: cfg options |
221 | // Default to enable test for single file. | 225 | // Default to enable test for single file. |
222 | let mut cfg_options = CfgOptions::default(); | 226 | let mut cfg_options = CfgOptions::default(); |
@@ -228,9 +232,8 @@ impl Analysis { | |||
228 | cfg_options, | 232 | cfg_options, |
229 | Env::default(), | 233 | Env::default(), |
230 | Default::default(), | 234 | Default::default(), |
231 | Default::default(), | ||
232 | ); | 235 | ); |
233 | change.add_file(source_root, file_id, "main.rs".into(), Arc::new(text)); | 236 | change.change_file(file_id, Some(Arc::new(text))); |
234 | change.set_crate_graph(crate_graph); | 237 | change.set_crate_graph(crate_graph); |
235 | host.apply_change(change); | 238 | host.apply_change(change); |
236 | (host.analysis(), file_id) | 239 | (host.analysis(), file_id) |