Some docs

This commit is contained in:
Aleksey Kladov 2020-02-18 12:11:32 +01:00
parent 59e1207dac
commit 93b969003d
7 changed files with 23 additions and 15 deletions

View File

@ -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;

View File

@ -1,4 +1,4 @@
//! FIXME: write short doc here
//! Various batch processing tasks, intended primarily for debugging.
mod load_cargo;
mod analysis_stats;

View File

@ -1,4 +1,4 @@
//! FIXME: write short doc here
//! Benchmark operations like highlighting or goto definition.
use std::{
path::{Path, PathBuf},

View File

@ -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};

View File

@ -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<SourceRootId, PackageRoot>)> {
pub(crate) fn load_cargo(
root: &Path,
) -> Result<(AnalysisHost, FxHashMap<SourceRootId, PackageRoot>)> {
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<SourceRootId,
Ok((host, source_roots))
}
pub fn load(
pub(crate) fn load(
source_roots: &FxHashMap<SourceRootId, PackageRoot>,
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;

View File

@ -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;

View File

@ -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.