diff options
author | Aleksey Kladov <[email protected]> | 2020-02-18 11:11:32 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-02-18 11:11:32 +0000 |
commit | 93b969003d0a9448d4207d9d5df9dde63f9444be (patch) | |
tree | 14652e5a5e5c81712dd681495801d99e1eef93fe | |
parent | 59e1207dac8eb9cc56a72ee685bd4f143683d2bb (diff) |
Some docs
-rw-r--r-- | crates/ra_lsp_server/src/bin/main.rs | 4 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/cli.rs | 2 | ||||
-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 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/lib.rs | 7 | ||||
-rw-r--r-- | crates/ra_lsp_server/src/vfs_glob.rs | 2 |
7 files changed, 23 insertions, 15 deletions
diff --git a/crates/ra_lsp_server/src/bin/main.rs b/crates/ra_lsp_server/src/bin/main.rs index a549e5ff1..e25d54a0d 100644 --- a/crates/ra_lsp_server/src/bin/main.rs +++ b/crates/ra_lsp_server/src/bin/main.rs | |||
@@ -1,4 +1,6 @@ | |||
1 | //! `ra_lsp_server` binary | 1 | //! Driver for rust-analyzer. |
2 | //! | ||
3 | //! Based on cli flags, either spawns an LSP server, or runs a batch analysis | ||
2 | mod args; | 4 | mod args; |
3 | 5 | ||
4 | use lsp_server::Connection; | 6 | use lsp_server::Connection; |
diff --git a/crates/ra_lsp_server/src/cli.rs b/crates/ra_lsp_server/src/cli.rs index 3c7b8e250..c9738d101 100644 --- a/crates/ra_lsp_server/src/cli.rs +++ b/crates/ra_lsp_server/src/cli.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! Various batch processing tasks, intended primarily for debugging. |
2 | 2 | ||
3 | mod load_cargo; | 3 | mod load_cargo; |
4 | mod analysis_stats; | 4 | mod analysis_stats; |
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; |
diff --git a/crates/ra_lsp_server/src/lib.rs b/crates/ra_lsp_server/src/lib.rs index 958c70fe5..0dae30e46 100644 --- a/crates/ra_lsp_server/src/lib.rs +++ b/crates/ra_lsp_server/src/lib.rs | |||
@@ -1,10 +1,13 @@ | |||
1 | //! Implementation of the LSP for rust-analyzer. | 1 | //! Implementation of the LSP for rust-analyzer. |
2 | //! | 2 | //! |
3 | //! This crate takes Rust-specific analysis results from ra_ide and | 3 | //! This crate takes Rust-specific analysis results from ra_ide and translates |
4 | //! translates into LSP types. | 4 | //! into LSP types. |
5 | //! | 5 | //! |
6 | //! It also is the root of all state. `world` module defines the bulk of the | 6 | //! It also is the root of all state. `world` module defines the bulk of the |
7 | //! state, and `main_loop` module defines the rules for modifying it. | 7 | //! state, and `main_loop` module defines the rules for modifying it. |
8 | //! | ||
9 | //! The `cli` submodule implements some batch-processing analysis, primarily as | ||
10 | //! a debugging aid. | ||
8 | #![recursion_limit = "512"] | 11 | #![recursion_limit = "512"] |
9 | 12 | ||
10 | pub mod cli; | 13 | pub mod cli; |
diff --git a/crates/ra_lsp_server/src/vfs_glob.rs b/crates/ra_lsp_server/src/vfs_glob.rs index 12401d75a..91b33f94e 100644 --- a/crates/ra_lsp_server/src/vfs_glob.rs +++ b/crates/ra_lsp_server/src/vfs_glob.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | //! `ra_vfs_glob` crate implements exclusion rules for vfs. | 1 | //! Exclusion rules for vfs. |
2 | //! | 2 | //! |
3 | //! By default, we include only `.rs` files, and skip some know offenders like | 3 | //! By default, we include only `.rs` files, and skip some know offenders like |
4 | //! `/target` or `/node_modules` altogether. | 4 | //! `/target` or `/node_modules` altogether. |