diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-02-18 11:26:10 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-02-18 11:26:10 +0000 |
commit | 2768476e491d985317b08230824f96e6718f338a (patch) | |
tree | 08e5d3f64f545d402b1a9f4fe65330ca56e1d741 /crates/ra_lsp_server/src/cli | |
parent | a349e5d4fcda1a6b96a09491a59d1ec940a48654 (diff) | |
parent | 4d307ff8024c8d2d533bc3ab7aac1d63ca5c5977 (diff) |
Merge #3214
3214: Fully document ra_lsp_server r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_lsp_server/src/cli')
-rw-r--r-- | crates/ra_lsp_server/src/cli/analysis_bench.rs | 2 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/cli/analysis_stats.rs | 3 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/cli/load_cargo.rs | 18 |
3 files changed, 13 insertions, 10 deletions
diff --git a/crates/ra_lsp_server/src/cli/analysis_bench.rs b/crates/ra_lsp_server/src/cli/analysis_bench.rs index e00f81073..91855e592 100644 --- a/crates/ra_lsp_server/src/cli/analysis_bench.rs +++ b/crates/ra_lsp_server/src/cli/analysis_bench.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Benchmark operations like highlighting or goto definition. |
2 | 2 | ||
3 | use std::{ | 3 | use std::{ |
4 | path::{Path, PathBuf}, | 4 | path::{Path, PathBuf}, |
diff --git a/crates/ra_lsp_server/src/cli/analysis_stats.rs b/crates/ra_lsp_server/src/cli/analysis_stats.rs index c27fabe3c..99ab6e443 100644 --- a/crates/ra_lsp_server/src/cli/analysis_stats.rs +++ b/crates/ra_lsp_server/src/cli/analysis_stats.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Fully type-check project and print various stats, like the number of type |
2 | //! errors. | ||
2 | 3 | ||
3 | use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; | 4 | use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; |
4 | 5 | ||
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 | ||
3 | use std::{collections::HashSet, path::Path}; | 4 | use std::path::Path; |
4 | 5 | ||
6 | use anyhow::Result; | ||
5 | use crossbeam_channel::{unbounded, Receiver}; | 7 | use crossbeam_channel::{unbounded, Receiver}; |
6 | use ra_db::{CrateGraph, FileId, SourceRootId}; | 8 | use ra_db::{CrateGraph, FileId, SourceRootId}; |
7 | use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags}; | 9 | use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags}; |
8 | use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace}; | 10 | use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace}; |
9 | use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; | 11 | use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; |
10 | use rustc_hash::FxHashMap; | 12 | use rustc_hash::{FxHashMap, FxHashSet}; |
11 | 13 | ||
12 | use crate::vfs_glob::RustPackageFilterBuilder; | 14 | use crate::vfs_glob::RustPackageFilterBuilder; |
13 | 15 | ||
14 | use anyhow::Result; | ||
15 | |||
16 | fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId { | 16 | fn 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 | ||
23 | pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> { | 23 | pub(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 | ||
77 | pub fn load( | 79 | pub(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; |