aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_lsp_server/src/cli/load_cargo.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-18 11:11:32 +0000
committerAleksey Kladov <[email protected]>2020-02-18 11:11:32 +0000
commit93b969003d0a9448d4207d9d5df9dde63f9444be (patch)
tree14652e5a5e5c81712dd681495801d99e1eef93fe /crates/ra_lsp_server/src/cli/load_cargo.rs
parent59e1207dac8eb9cc56a72ee685bd4f143683d2bb (diff)
Some docs
Diffstat (limited to 'crates/ra_lsp_server/src/cli/load_cargo.rs')
-rw-r--r--crates/ra_lsp_server/src/cli/load_cargo.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/crates/ra_lsp_server/src/cli/load_cargo.rs b/crates/ra_lsp_server/src/cli/load_cargo.rs
index bb3e1513b..8cd08ecb6 100644
--- a/crates/ra_lsp_server/src/cli/load_cargo.rs
+++ b/crates/ra_lsp_server/src/cli/load_cargo.rs
@@ -1,18 +1,18 @@
1//! FIXME: write short doc here 1//! Loads a Cargo project into a static instance of analysis, without support
2//! for incorporating changes.
2 3
3use std::{collections::HashSet, path::Path}; 4use std::path::Path;
4 5
6use anyhow::Result;
5use crossbeam_channel::{unbounded, Receiver}; 7use crossbeam_channel::{unbounded, Receiver};
6use ra_db::{CrateGraph, FileId, SourceRootId}; 8use ra_db::{CrateGraph, FileId, SourceRootId};
7use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags}; 9use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags};
8use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace}; 10use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace};
9use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; 11use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch};
10use rustc_hash::FxHashMap; 12use rustc_hash::{FxHashMap, FxHashSet};
11 13
12use crate::vfs_glob::RustPackageFilterBuilder; 14use crate::vfs_glob::RustPackageFilterBuilder;
13 15
14use anyhow::Result;
15
16fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId { 16fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId {
17 FileId(f.0) 17 FileId(f.0)
18} 18}
@@ -20,7 +20,9 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
20 SourceRootId(r.0) 20 SourceRootId(r.0)
21} 21}
22 22
23pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> { 23pub(crate) fn load_cargo(
24 root: &Path,
25) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> {
24 let root = std::env::current_dir()?.join(root); 26 let root = std::env::current_dir()?.join(root);
25 let ws = ProjectWorkspace::discover(root.as_ref(), &Default::default())?; 27 let ws = ProjectWorkspace::discover(root.as_ref(), &Default::default())?;
26 let project_roots = ws.to_roots(); 28 let project_roots = ws.to_roots();
@@ -74,7 +76,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
74 Ok((host, source_roots)) 76 Ok((host, source_roots))
75} 77}
76 78
77pub fn load( 79pub(crate) fn load(
78 source_roots: &FxHashMap<SourceRootId, PackageRoot>, 80 source_roots: &FxHashMap<SourceRootId, PackageRoot>,
79 crate_graph: CrateGraph, 81 crate_graph: CrateGraph,
80 vfs: &mut Vfs, 82 vfs: &mut Vfs,
@@ -86,7 +88,7 @@ pub fn load(
86 analysis_change.set_crate_graph(crate_graph); 88 analysis_change.set_crate_graph(crate_graph);
87 89
88 // wait until Vfs has loaded all roots 90 // wait until Vfs has loaded all roots
89 let mut roots_loaded = HashSet::new(); 91 let mut roots_loaded = FxHashSet::default();
90 for task in receiver { 92 for task in receiver {
91 vfs.handle_task(task); 93 vfs.handle_task(task);
92 let mut done = false; 94 let mut done = false;