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/bin/main.rs | 4 +++- crates/ra_lsp_server/src/cli.rs | 2 +- crates/ra_lsp_server/src/cli/analysis_bench.rs | 2 +- crates/ra_lsp_server/src/cli/analysis_stats.rs | 3 ++- crates/ra_lsp_server/src/cli/load_cargo.rs | 18 ++++++++++-------- crates/ra_lsp_server/src/lib.rs | 7 +++++-- 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 @@ -//! `ra_lsp_server` binary +//! Driver for rust-analyzer. +//! +//! Based on cli flags, either spawns an LSP server, or runs a batch analysis mod args; 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 @@ -//! FIXME: write short doc here +//! Various batch processing tasks, intended primarily for debugging. mod load_cargo; 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 @@ -//! FIXME: write short doc here +//! Benchmark operations like highlighting or goto definition. use std::{ 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 @@ -//! FIXME: write short doc here +//! Fully type-check project and print various stats, like the number of type +//! errors. use std::{collections::HashSet, fmt::Write, path::Path, time::Instant}; 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; 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 @@ //! Implementation of the LSP for rust-analyzer. //! -//! This crate takes Rust-specific analysis results from ra_ide and -//! translates into LSP types. +//! This crate takes Rust-specific analysis results from ra_ide and translates +//! into LSP types. //! //! It also is the root of all state. `world` module defines the bulk of the //! state, and `main_loop` module defines the rules for modifying it. +//! +//! The `cli` submodule implements some batch-processing analysis, primarily as +//! a debugging aid. #![recursion_limit = "512"] 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 @@ -//! `ra_vfs_glob` crate implements exclusion rules for vfs. +//! Exclusion rules for vfs. //! //! By default, we include only `.rs` files, and skip some know offenders like //! `/target` or `/node_modules` altogether. -- cgit v1.2.3