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; mod args;
use lsp_server::Connection; 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 load_cargo;
mod analysis_stats; mod analysis_stats;

View file

@ -1,4 +1,4 @@
//! FIXME: write short doc here //! Benchmark operations like highlighting or goto definition.
use std::{ use std::{
path::{Path, PathBuf}, 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}; 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 crossbeam_channel::{unbounded, Receiver};
use ra_db::{CrateGraph, FileId, SourceRootId}; use ra_db::{CrateGraph, FileId, SourceRootId};
use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags}; use ra_ide::{AnalysisChange, AnalysisHost, FeatureFlags};
use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace}; use ra_project_model::{get_rustc_cfg_options, PackageRoot, ProjectWorkspace};
use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch}; use ra_vfs::{RootEntry, Vfs, VfsChange, VfsTask, Watch};
use rustc_hash::FxHashMap; use rustc_hash::{FxHashMap, FxHashSet};
use crate::vfs_glob::RustPackageFilterBuilder; use crate::vfs_glob::RustPackageFilterBuilder;
use anyhow::Result;
fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId { fn vfs_file_to_id(f: ra_vfs::VfsFile) -> FileId {
FileId(f.0) FileId(f.0)
} }
@ -20,7 +20,9 @@ fn vfs_root_to_id(r: ra_vfs::VfsRoot) -> SourceRootId {
SourceRootId(r.0) 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 root = std::env::current_dir()?.join(root);
let ws = ProjectWorkspace::discover(root.as_ref(), &Default::default())?; let ws = ProjectWorkspace::discover(root.as_ref(), &Default::default())?;
let project_roots = ws.to_roots(); let project_roots = ws.to_roots();
@ -74,7 +76,7 @@ pub fn load_cargo(root: &Path) -> Result<(AnalysisHost, FxHashMap<SourceRootId,
Ok((host, source_roots)) Ok((host, source_roots))
} }
pub fn load( pub(crate) fn load(
source_roots: &FxHashMap<SourceRootId, PackageRoot>, source_roots: &FxHashMap<SourceRootId, PackageRoot>,
crate_graph: CrateGraph, crate_graph: CrateGraph,
vfs: &mut Vfs, vfs: &mut Vfs,
@ -86,7 +88,7 @@ pub fn load(
analysis_change.set_crate_graph(crate_graph); analysis_change.set_crate_graph(crate_graph);
// wait until Vfs has loaded all roots // wait until Vfs has loaded all roots
let mut roots_loaded = HashSet::new(); let mut roots_loaded = FxHashSet::default();
for task in receiver { for task in receiver {
vfs.handle_task(task); vfs.handle_task(task);
let mut done = false; let mut done = false;

View file

@ -1,10 +1,13 @@
//! Implementation of the LSP for rust-analyzer. //! Implementation of the LSP for rust-analyzer.
//! //!
//! This crate takes Rust-specific analysis results from ra_ide and //! This crate takes Rust-specific analysis results from ra_ide and translates
//! translates into LSP types. //! into LSP types.
//! //!
//! It also is the root of all state. `world` module defines the bulk of the //! 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. //! 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"] #![recursion_limit = "512"]
pub mod cli; 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 //! By default, we include only `.rs` files, and skip some know offenders like
//! `/target` or `/node_modules` altogether. //! `/target` or `/node_modules` altogether.