From 93b969003d0a9448d4207d9d5df9dde63f9444be Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 18 Feb 2020 12:11:32 +0100 Subject: Some docs --- crates/ra_lsp_server/src/cli/load_cargo.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'crates/ra_lsp_server/src/cli/load_cargo.rs') 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 @@ -//! FIXME: write short doc here +//! Loads a Cargo project into a static instance of analysis, without support +//! for incorporating changes. -use std::{collections::HashSet, path::Path}; +use std::path::Path; +use anyhow::Result; use crossbeam_channel::{unbounded, Receiver}; use ra_db::{CrateGraph, FileId, SourceRootId}; use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags}; use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace}; use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; -use rustc_hash::FxHashMap; +use rustc_hash::{FxHashMap, FxHashSet}; use crate::vfs_glob::RustPackageFilterBuilder; -use anyhow::Result; - fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId { FileId(f.0) } @@ -20,7 +20,9 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId { SourceRootId(r.0) } -pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap)> { +pub(crate) fn load_cargo( + root: &Path, +) -> Result<(AnalysisHost, FxHashMap)> { let root = std::env::current_dir()?.join(root); let ws = ProjectWorkspace::discover(root.as_ref(), &Default::default())?; let project_roots = ws.to_roots(); @@ -74,7 +76,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap, crate_graph: CrateGraph, vfs: &mut Vfs, @@ -86,7 +88,7 @@ pub fn load( analysis_change.set_crate_graph(crate_graph); // wait until Vfs has loaded all roots - let mut roots_loaded = HashSet::new(); + let mut roots_loaded = FxHashSet::default(); for task in receiver { vfs.handle_task(task); let mut done = false; -- cgit v1.2.3