mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Merge branch 'master' into add-disable-diagnostics
This commit is contained in:
commit
c26c911ec1
1140 changed files with 2355 additions and 2386 deletions
|
@ -1,10 +1,10 @@
|
|||
[package]
|
||||
edition = "2018"
|
||||
name = "rust-analyzer"
|
||||
version = "0.1.0"
|
||||
version = "0.0.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
authors = ["rust-analyzer developers"]
|
||||
autobins = false
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
@ -30,29 +30,28 @@ serde_json = "1.0.48"
|
|||
threadpool = "1.7.1"
|
||||
rayon = "1.3.1"
|
||||
mimalloc = { version = "0.1.19", default-features = false, optional = true }
|
||||
lsp-server = "0.3.3"
|
||||
|
||||
stdx = { path = "../stdx" }
|
||||
|
||||
lsp-server = "0.3.3"
|
||||
flycheck = { path = "../flycheck" }
|
||||
ra_ide = { path = "../ra_ide" }
|
||||
ra_prof = { path = "../ra_prof" }
|
||||
ra_project_model = { path = "../ra_project_model" }
|
||||
ra_syntax = { path = "../ra_syntax" }
|
||||
ra_text_edit = { path = "../ra_text_edit" }
|
||||
ide = { path = "../ide" }
|
||||
profile = { path = "../profile" }
|
||||
project_model = { path = "../project_model" }
|
||||
syntax = { path = "../syntax" }
|
||||
text_edit = { path = "../text_edit" }
|
||||
vfs = { path = "../vfs" }
|
||||
vfs-notify = { path = "../vfs-notify" }
|
||||
ra_cfg = { path = "../ra_cfg" }
|
||||
ra_toolchain = { path = "../ra_toolchain" }
|
||||
cfg = { path = "../cfg" }
|
||||
toolchain = { path = "../toolchain" }
|
||||
|
||||
# This should only be used in CLI
|
||||
ra_db = { path = "../ra_db" }
|
||||
ra_ide_db = { path = "../ra_ide_db" }
|
||||
ra_ssr = { path = "../ra_ssr" }
|
||||
hir = { path = "../ra_hir", package = "ra_hir" }
|
||||
hir_def = { path = "../ra_hir_def", package = "ra_hir_def" }
|
||||
hir_ty = { path = "../ra_hir_ty", package = "ra_hir_ty" }
|
||||
ra_proc_macro_srv = { path = "../ra_proc_macro_srv" }
|
||||
base_db = { path = "../base_db" }
|
||||
ide_db = { path = "../ide_db" }
|
||||
ssr = { path = "../ssr" }
|
||||
hir = { path = "../hir" }
|
||||
hir_def = { path = "../hir_def" }
|
||||
hir_ty = { path = "../hir_ty" }
|
||||
proc_macro_srv = { path = "../proc_macro_srv" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = "0.3.8"
|
||||
|
@ -60,5 +59,5 @@ winapi = "0.3.8"
|
|||
[dev-dependencies]
|
||||
expect = { path = "../expect" }
|
||||
test_utils = { path = "../test_utils" }
|
||||
mbe = { path = "../ra_mbe", package = "ra_mbe" }
|
||||
tt = { path = "../ra_tt", package = "ra_tt" }
|
||||
mbe = { path = "../mbe" }
|
||||
tt = { path = "../tt" }
|
||||
|
|
|
@ -7,8 +7,8 @@ use std::{env, fmt::Write, path::PathBuf};
|
|||
|
||||
use anyhow::{bail, Result};
|
||||
use pico_args::Arguments;
|
||||
use ra_ssr::{SsrPattern, SsrRule};
|
||||
use rust_analyzer::cli::{AnalysisStatsCmd, BenchCmd, BenchWhat, Position, Verbosity};
|
||||
use ssr::{SsrPattern, SsrRule};
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
pub(crate) struct Args {
|
||||
|
|
|
@ -6,7 +6,7 @@ mod args;
|
|||
use std::{convert::TryFrom, process};
|
||||
|
||||
use lsp_server::Connection;
|
||||
use ra_project_model::ProjectManifest;
|
||||
use project_model::ProjectManifest;
|
||||
use rust_analyzer::{
|
||||
cli,
|
||||
config::{Config, LinkedProject},
|
||||
|
@ -30,7 +30,7 @@ fn try_main() -> Result<()> {
|
|||
let args = args::Args::parse()?;
|
||||
match args.command {
|
||||
args::Command::RunServer => run_server()?,
|
||||
args::Command::ProcMacro => ra_proc_macro_srv::cli::run()?,
|
||||
args::Command::ProcMacro => proc_macro_srv::cli::run()?,
|
||||
|
||||
args::Command::Parse { no_dump } => cli::parse(no_dump)?,
|
||||
args::Command::Symbols => cli::symbols()?,
|
||||
|
@ -55,7 +55,7 @@ fn try_main() -> Result<()> {
|
|||
fn setup_logging() -> Result<()> {
|
||||
std::env::set_var("RUST_BACKTRACE", "short");
|
||||
env_logger::try_init_from_env("RA_LOG")?;
|
||||
ra_prof::init();
|
||||
profile::init();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
//! See `CargoTargetSpec`
|
||||
|
||||
use ra_cfg::CfgExpr;
|
||||
use ra_ide::{FileId, RunnableKind, TestId};
|
||||
use ra_project_model::{self, TargetKind};
|
||||
use cfg::CfgExpr;
|
||||
use ide::{FileId, RunnableKind, TestId};
|
||||
use project_model::{self, TargetKind};
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
use crate::{global_state::GlobalStateSnapshot, Result};
|
||||
|
@ -177,9 +177,9 @@ fn required_features(cfg_expr: &CfgExpr, features: &mut Vec<String>) {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use cfg::CfgExpr;
|
||||
use mbe::ast_to_token_tree;
|
||||
use ra_cfg::CfgExpr;
|
||||
use ra_syntax::{
|
||||
use syntax::{
|
||||
ast::{self, AstNode},
|
||||
SmolStr,
|
||||
};
|
||||
|
|
|
@ -10,15 +10,16 @@ mod ssr;
|
|||
use std::io::Read;
|
||||
|
||||
use anyhow::Result;
|
||||
use ra_ide::Analysis;
|
||||
use ra_prof::profile;
|
||||
use ra_syntax::{AstNode, SourceFile};
|
||||
use ide::Analysis;
|
||||
use syntax::{AstNode, SourceFile};
|
||||
|
||||
pub use analysis_bench::{BenchCmd, BenchWhat, Position};
|
||||
pub use analysis_stats::AnalysisStatsCmd;
|
||||
pub use diagnostics::diagnostics;
|
||||
pub use load_cargo::load_cargo;
|
||||
pub use ssr::{apply_ssr_rules, search_for_patterns};
|
||||
pub use self::{
|
||||
analysis_bench::{BenchCmd, BenchWhat, Position},
|
||||
analysis_stats::AnalysisStatsCmd,
|
||||
diagnostics::diagnostics,
|
||||
load_cargo::load_cargo,
|
||||
ssr::{apply_ssr_rules, search_for_patterns},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Verbosity {
|
||||
|
@ -38,7 +39,7 @@ impl Verbosity {
|
|||
}
|
||||
|
||||
pub fn parse(no_dump: bool) -> Result<()> {
|
||||
let _p = profile("parsing");
|
||||
let _p = profile::span("parsing");
|
||||
let file = file()?;
|
||||
if !no_dump {
|
||||
println!("{:#?}", file.syntax());
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
use std::{env, path::PathBuf, str::FromStr, sync::Arc, time::Instant};
|
||||
|
||||
use anyhow::{bail, format_err, Result};
|
||||
use ra_db::{
|
||||
use base_db::{
|
||||
salsa::{Database, Durability},
|
||||
FileId,
|
||||
};
|
||||
use ra_ide::{Analysis, AnalysisChange, AnalysisHost, CompletionConfig, FilePosition, LineCol};
|
||||
use ide::{Analysis, AnalysisChange, AnalysisHost, CompletionConfig, FilePosition, LineCol};
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
use crate::{
|
||||
|
@ -52,7 +52,7 @@ impl FromStr for Position {
|
|||
|
||||
impl BenchCmd {
|
||||
pub fn run(self, verbosity: Verbosity) -> Result<()> {
|
||||
ra_prof::init();
|
||||
profile::init();
|
||||
|
||||
let start = Instant::now();
|
||||
eprint!("loading: ");
|
||||
|
|
|
@ -6,6 +6,10 @@ use std::{
|
|||
time::{SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use base_db::{
|
||||
salsa::{self, ParallelDatabase},
|
||||
SourceDatabaseExt,
|
||||
};
|
||||
use hir::{
|
||||
db::{AstDatabase, DefDatabase, HirDatabase},
|
||||
original_range, AssocItem, Crate, HasSource, HirDisplay, ModuleDef,
|
||||
|
@ -14,14 +18,10 @@ use hir_def::FunctionId;
|
|||
use hir_ty::{Ty, TypeWalk};
|
||||
use itertools::Itertools;
|
||||
use oorandom::Rand32;
|
||||
use ra_db::{
|
||||
salsa::{self, ParallelDatabase},
|
||||
SourceDatabaseExt,
|
||||
};
|
||||
use ra_syntax::AstNode;
|
||||
use rayon::prelude::*;
|
||||
use rustc_hash::FxHashSet;
|
||||
use stdx::format_to;
|
||||
use syntax::AstNode;
|
||||
|
||||
use crate::{
|
||||
cli::{
|
||||
|
@ -29,7 +29,7 @@ use crate::{
|
|||
},
|
||||
print_memory_usage,
|
||||
};
|
||||
use ra_prof::StopWatch;
|
||||
use profile::StopWatch;
|
||||
|
||||
/// Need to wrap Snapshot to provide `Clone` impl for `map_with`
|
||||
struct Snap<DB>(DB);
|
||||
|
|
|
@ -6,9 +6,9 @@ use std::path::Path;
|
|||
use anyhow::anyhow;
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
use base_db::SourceDatabaseExt;
|
||||
use hir::Crate;
|
||||
use ra_db::SourceDatabaseExt;
|
||||
use ra_ide::Severity;
|
||||
use ide::Severity;
|
||||
|
||||
use crate::cli::{load_cargo::load_cargo, Result};
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
use std::{path::Path, sync::Arc};
|
||||
|
||||
use anyhow::Result;
|
||||
use base_db::CrateGraph;
|
||||
use crossbeam_channel::{unbounded, Receiver};
|
||||
use ra_db::CrateGraph;
|
||||
use ra_ide::{AnalysisChange, AnalysisHost};
|
||||
use ra_project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace};
|
||||
use ide::{AnalysisChange, AnalysisHost};
|
||||
use project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace};
|
||||
use vfs::{loader::Handle, AbsPath, AbsPathBuf};
|
||||
|
||||
use crate::reload::{ProjectFolders, SourceRootConfig};
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
//! Applies structured search replace rules from the command line.
|
||||
|
||||
use crate::cli::{load_cargo::load_cargo, Result};
|
||||
use ra_ssr::{MatchFinder, SsrPattern, SsrRule};
|
||||
use ssr::{MatchFinder, SsrPattern, SsrRule};
|
||||
|
||||
pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
||||
use ra_db::SourceDatabaseExt;
|
||||
use base_db::SourceDatabaseExt;
|
||||
let (host, vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
|
||||
let db = host.raw_database();
|
||||
let mut match_finder = MatchFinder::at_first_file(db)?;
|
||||
|
@ -26,8 +26,8 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
|||
/// `debug_snippet`. This is intended for debugging and probably isn't in it's current form useful
|
||||
/// for much else.
|
||||
pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> {
|
||||
use ra_db::SourceDatabaseExt;
|
||||
use ra_ide_db::symbol_index::SymbolsDatabase;
|
||||
use base_db::SourceDatabaseExt;
|
||||
use ide_db::symbol_index::SymbolsDatabase;
|
||||
let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
|
||||
let db = host.raw_database();
|
||||
let mut match_finder = MatchFinder::at_first_file(db)?;
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
use std::{collections::HashSet, ffi::OsString, path::PathBuf};
|
||||
|
||||
use flycheck::FlycheckConfig;
|
||||
use ide::{AnalysisConfig, AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig};
|
||||
use lsp_types::ClientCapabilities;
|
||||
use ra_ide::{AnalysisConfig, AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig};
|
||||
use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
|
||||
use project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
|
||||
use serde::Deserialize;
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ pub(crate) mod to_proto;
|
|||
|
||||
use std::{mem, sync::Arc};
|
||||
|
||||
use ra_ide::FileId;
|
||||
use ide::FileId;
|
||||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
|
||||
use crate::lsp_ext;
|
||||
|
|
|
@ -1116,7 +1116,7 @@ mod tests {
|
|||
fn macro_compiler_error() {
|
||||
check(
|
||||
r##"{
|
||||
"rendered": "error: Please register your known path in the path module\n --> crates/ra_hir_def/src/path.rs:265:9\n |\n265 | compile_error!(\"Please register your known path in the path module\")\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n | \n ::: crates/ra_hir_def/src/data.rs:80:16\n |\n80 | let path = path![std::future::Future];\n | -------------------------- in this macro invocation\n\n",
|
||||
"rendered": "error: Please register your known path in the path module\n --> crates/hir_def/src/path.rs:265:9\n |\n265 | compile_error!(\"Please register your known path in the path module\")\n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n | \n ::: crates/hir_def/src/data.rs:80:16\n |\n80 | let path = path![std::future::Future];\n | -------------------------- in this macro invocation\n\n",
|
||||
"children": [],
|
||||
"code": null,
|
||||
"level": "error",
|
||||
|
@ -1134,7 +1134,7 @@ mod tests {
|
|||
"column_end": 2,
|
||||
"column_start": 1,
|
||||
"expansion": null,
|
||||
"file_name": "crates/ra_hir_def/src/path.rs",
|
||||
"file_name": "crates/hir_def/src/path.rs",
|
||||
"is_primary": false,
|
||||
"label": null,
|
||||
"line_end": 267,
|
||||
|
@ -1227,7 +1227,7 @@ mod tests {
|
|||
"column_end": 2,
|
||||
"column_start": 1,
|
||||
"expansion": null,
|
||||
"file_name": "crates/ra_hir_def/src/path.rs",
|
||||
"file_name": "crates/hir_def/src/path.rs",
|
||||
"is_primary": false,
|
||||
"label": null,
|
||||
"line_end": 277,
|
||||
|
@ -1284,7 +1284,7 @@ mod tests {
|
|||
"column_end": 42,
|
||||
"column_start": 16,
|
||||
"expansion": null,
|
||||
"file_name": "crates/ra_hir_def/src/data.rs",
|
||||
"file_name": "crates/hir_def/src/data.rs",
|
||||
"is_primary": false,
|
||||
"label": null,
|
||||
"line_end": 80,
|
||||
|
@ -1300,7 +1300,7 @@ mod tests {
|
|||
]
|
||||
}
|
||||
},
|
||||
"file_name": "crates/ra_hir_def/src/path.rs",
|
||||
"file_name": "crates/hir_def/src/path.rs",
|
||||
"is_primary": false,
|
||||
"label": null,
|
||||
"line_end": 272,
|
||||
|
@ -1316,7 +1316,7 @@ mod tests {
|
|||
]
|
||||
}
|
||||
},
|
||||
"file_name": "crates/ra_hir_def/src/path.rs",
|
||||
"file_name": "crates/hir_def/src/path.rs",
|
||||
"is_primary": true,
|
||||
"label": null,
|
||||
"line_end": 265,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//! Conversion lsp_types types to rust-analyzer specific ones.
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use ra_db::{FileId, FilePosition, FileRange};
|
||||
use ra_ide::{AssistKind, LineCol, LineIndex};
|
||||
use ra_syntax::{TextRange, TextSize};
|
||||
use base_db::{FileId, FilePosition, FileRange};
|
||||
use ide::{AssistKind, LineCol, LineIndex};
|
||||
use syntax::{TextRange, TextSize};
|
||||
use vfs::AbsPathBuf;
|
||||
|
||||
use crate::{global_state::GlobalStateSnapshot, Result};
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
|
||||
use std::{sync::Arc, time::Instant};
|
||||
|
||||
use base_db::{CrateId, VfsPath};
|
||||
use crossbeam_channel::{unbounded, Receiver, Sender};
|
||||
use flycheck::FlycheckHandle;
|
||||
use ide::{Analysis, AnalysisChange, AnalysisHost, FileId};
|
||||
use lsp_types::{SemanticTokens, Url};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use ra_db::{CrateId, VfsPath};
|
||||
use ra_ide::{Analysis, AnalysisChange, AnalysisHost, FileId};
|
||||
use ra_project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
|
||||
use project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};
|
||||
use rustc_hash::FxHashMap;
|
||||
|
||||
use crate::{
|
||||
|
@ -27,7 +27,6 @@ use crate::{
|
|||
to_proto::url_from_abs_path,
|
||||
Result,
|
||||
};
|
||||
use ra_prof::profile;
|
||||
|
||||
#[derive(Eq, PartialEq, Copy, Clone)]
|
||||
pub(crate) enum Status {
|
||||
|
@ -135,7 +134,7 @@ impl GlobalState {
|
|||
}
|
||||
|
||||
pub(crate) fn process_changes(&mut self) -> bool {
|
||||
let _p = profile("GlobalState::process_changes");
|
||||
let _p = profile::span("GlobalState::process_changes");
|
||||
let mut fs_changes = Vec::new();
|
||||
let mut has_fs_changes = false;
|
||||
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
//! This module is responsible for implementing handlers for Language Server
|
||||
//! Protocol. The majority of requests are fulfilled by calling into the
|
||||
//! `ra_ide` crate.
|
||||
//! `ide` crate.
|
||||
|
||||
use std::{
|
||||
io::Write as _,
|
||||
process::{self, Stdio},
|
||||
};
|
||||
|
||||
use ide::{
|
||||
FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query,
|
||||
RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit,
|
||||
};
|
||||
use lsp_server::ErrorCode;
|
||||
use lsp_types::{
|
||||
CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams, CallHierarchyItem,
|
||||
|
@ -18,16 +22,11 @@ use lsp_types::{
|
|||
SemanticTokensRangeResult, SemanticTokensResult, SymbolInformation, SymbolTag,
|
||||
TextDocumentIdentifier, Url, WorkspaceEdit,
|
||||
};
|
||||
use ra_ide::{
|
||||
FileId, FilePosition, FileRange, HoverAction, HoverGotoTypeData, NavigationTarget, Query,
|
||||
RangeInfo, Runnable, RunnableKind, SearchScope, TextEdit,
|
||||
};
|
||||
use ra_prof::profile;
|
||||
use ra_project_model::TargetKind;
|
||||
use ra_syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize};
|
||||
use project_model::TargetKind;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::to_value;
|
||||
use stdx::{format_to, split_once};
|
||||
use syntax::{algo, ast, AstNode, SyntaxKind, TextRange, TextSize};
|
||||
|
||||
use crate::{
|
||||
cargo_target_spec::CargoTargetSpec,
|
||||
|
@ -39,7 +38,7 @@ use crate::{
|
|||
};
|
||||
|
||||
pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result<String> {
|
||||
let _p = profile("handle_analyzer_status");
|
||||
let _p = profile::span("handle_analyzer_status");
|
||||
|
||||
let mut buf = String::new();
|
||||
if snap.workspaces.is_empty() {
|
||||
|
@ -64,7 +63,7 @@ pub(crate) fn handle_analyzer_status(snap: GlobalStateSnapshot, _: ()) -> Result
|
|||
}
|
||||
|
||||
pub(crate) fn handle_memory_usage(state: &mut GlobalState, _: ()) -> Result<String> {
|
||||
let _p = profile("handle_memory_usage");
|
||||
let _p = profile::span("handle_memory_usage");
|
||||
let mem = state.analysis_host.per_query_memory_usage();
|
||||
|
||||
let mut out = String::new();
|
||||
|
@ -78,7 +77,7 @@ pub(crate) fn handle_syntax_tree(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::SyntaxTreeParams,
|
||||
) -> Result<String> {
|
||||
let _p = profile("handle_syntax_tree");
|
||||
let _p = profile::span("handle_syntax_tree");
|
||||
let id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(id)?;
|
||||
let text_range = params.range.map(|r| from_proto::text_range(&line_index, r));
|
||||
|
@ -90,7 +89,7 @@ pub(crate) fn handle_expand_macro(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::ExpandMacroParams,
|
||||
) -> Result<Option<lsp_ext::ExpandedMacro>> {
|
||||
let _p = profile("handle_expand_macro");
|
||||
let _p = profile::span("handle_expand_macro");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
let offset = from_proto::offset(&line_index, params.position);
|
||||
|
@ -103,7 +102,7 @@ pub(crate) fn handle_selection_range(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::SelectionRangeParams,
|
||||
) -> Result<Option<Vec<lsp_types::SelectionRange>>> {
|
||||
let _p = profile("handle_selection_range");
|
||||
let _p = profile::span("handle_selection_range");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
let res: Result<Vec<lsp_types::SelectionRange>> = params
|
||||
|
@ -146,7 +145,7 @@ pub(crate) fn handle_matching_brace(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::MatchingBraceParams,
|
||||
) -> Result<Vec<Position>> {
|
||||
let _p = profile("handle_matching_brace");
|
||||
let _p = profile::span("handle_matching_brace");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
let res = params
|
||||
|
@ -168,7 +167,7 @@ pub(crate) fn handle_join_lines(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::JoinLinesParams,
|
||||
) -> Result<Vec<lsp_types::TextEdit>> {
|
||||
let _p = profile("handle_join_lines");
|
||||
let _p = profile::span("handle_join_lines");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
let line_endings = snap.file_line_endings(file_id);
|
||||
|
@ -191,7 +190,7 @@ pub(crate) fn handle_on_enter(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::TextDocumentPositionParams,
|
||||
) -> Result<Option<Vec<lsp_ext::SnippetTextEdit>>> {
|
||||
let _p = profile("handle_on_enter");
|
||||
let _p = profile::span("handle_on_enter");
|
||||
let position = from_proto::file_position(&snap, params)?;
|
||||
let edit = match snap.analysis.on_enter(position)? {
|
||||
None => return Ok(None),
|
||||
|
@ -208,12 +207,12 @@ pub(crate) fn handle_on_type_formatting(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::DocumentOnTypeFormattingParams,
|
||||
) -> Result<Option<Vec<lsp_types::TextEdit>>> {
|
||||
let _p = profile("handle_on_type_formatting");
|
||||
let _p = profile::span("handle_on_type_formatting");
|
||||
let mut position = from_proto::file_position(&snap, params.text_document_position)?;
|
||||
let line_index = snap.analysis.file_line_index(position.file_id)?;
|
||||
let line_endings = snap.file_line_endings(position.file_id);
|
||||
|
||||
// in `ra_ide`, the `on_type` invariant is that
|
||||
// in `ide`, the `on_type` invariant is that
|
||||
// `text.char_at(position) == typed_char`.
|
||||
position.offset -= TextSize::of('.');
|
||||
let char_typed = params.ch.chars().next().unwrap_or('\0');
|
||||
|
@ -247,7 +246,7 @@ pub(crate) fn handle_document_symbol(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::DocumentSymbolParams,
|
||||
) -> Result<Option<lsp_types::DocumentSymbolResponse>> {
|
||||
let _p = profile("handle_document_symbol");
|
||||
let _p = profile::span("handle_document_symbol");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
|
||||
|
@ -332,7 +331,7 @@ pub(crate) fn handle_workspace_symbol(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::WorkspaceSymbolParams,
|
||||
) -> Result<Option<Vec<SymbolInformation>>> {
|
||||
let _p = profile("handle_workspace_symbol");
|
||||
let _p = profile::span("handle_workspace_symbol");
|
||||
let all_symbols = params.query.contains('#');
|
||||
let libs = params.query.contains('*');
|
||||
let query = {
|
||||
|
@ -380,7 +379,7 @@ pub(crate) fn handle_goto_definition(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::GotoDefinitionParams,
|
||||
) -> Result<Option<lsp_types::GotoDefinitionResponse>> {
|
||||
let _p = profile("handle_goto_definition");
|
||||
let _p = profile::span("handle_goto_definition");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
|
||||
let nav_info = match snap.analysis.goto_definition(position)? {
|
||||
None => return Ok(None),
|
||||
|
@ -395,7 +394,7 @@ pub(crate) fn handle_goto_implementation(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::request::GotoImplementationParams,
|
||||
) -> Result<Option<lsp_types::request::GotoImplementationResponse>> {
|
||||
let _p = profile("handle_goto_implementation");
|
||||
let _p = profile::span("handle_goto_implementation");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
|
||||
let nav_info = match snap.analysis.goto_implementation(position)? {
|
||||
None => return Ok(None),
|
||||
|
@ -410,7 +409,7 @@ pub(crate) fn handle_goto_type_definition(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::request::GotoTypeDefinitionParams,
|
||||
) -> Result<Option<lsp_types::request::GotoTypeDefinitionResponse>> {
|
||||
let _p = profile("handle_goto_type_definition");
|
||||
let _p = profile::span("handle_goto_type_definition");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
|
||||
let nav_info = match snap.analysis.goto_type_definition(position)? {
|
||||
None => return Ok(None),
|
||||
|
@ -425,7 +424,7 @@ pub(crate) fn handle_parent_module(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::TextDocumentPositionParams,
|
||||
) -> Result<Option<lsp_types::GotoDefinitionResponse>> {
|
||||
let _p = profile("handle_parent_module");
|
||||
let _p = profile::span("handle_parent_module");
|
||||
let position = from_proto::file_position(&snap, params)?;
|
||||
let navs = snap.analysis.parent_module(position)?;
|
||||
let res = to_proto::goto_definition_response(&snap, None, navs)?;
|
||||
|
@ -436,7 +435,7 @@ pub(crate) fn handle_runnables(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::RunnablesParams,
|
||||
) -> Result<Vec<lsp_ext::Runnable>> {
|
||||
let _p = profile("handle_runnables");
|
||||
let _p = profile::span("handle_runnables");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
let offset = params.position.map(|it| from_proto::offset(&line_index, it));
|
||||
|
@ -513,7 +512,7 @@ pub(crate) fn handle_completion(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::CompletionParams,
|
||||
) -> Result<Option<lsp_types::CompletionResponse>> {
|
||||
let _p = profile("handle_completion");
|
||||
let _p = profile::span("handle_completion");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position)?;
|
||||
let completion_triggered_after_single_colon = {
|
||||
let mut res = false;
|
||||
|
@ -555,7 +554,7 @@ pub(crate) fn handle_folding_range(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: FoldingRangeParams,
|
||||
) -> Result<Option<Vec<FoldingRange>>> {
|
||||
let _p = profile("handle_folding_range");
|
||||
let _p = profile::span("handle_folding_range");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let folds = snap.analysis.folding_ranges(file_id)?;
|
||||
let text = snap.analysis.file_text(file_id)?;
|
||||
|
@ -572,7 +571,7 @@ pub(crate) fn handle_signature_help(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::SignatureHelpParams,
|
||||
) -> Result<Option<lsp_types::SignatureHelp>> {
|
||||
let _p = profile("handle_signature_help");
|
||||
let _p = profile::span("handle_signature_help");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
|
||||
let call_info = match snap.analysis.call_info(position)? {
|
||||
Some(it) => it,
|
||||
|
@ -591,7 +590,7 @@ pub(crate) fn handle_hover(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::HoverParams,
|
||||
) -> Result<Option<lsp_ext::Hover>> {
|
||||
let _p = profile("handle_hover");
|
||||
let _p = profile::span("handle_hover");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
|
||||
let info = match snap.analysis.hover(position)? {
|
||||
None => return Ok(None),
|
||||
|
@ -614,7 +613,7 @@ pub(crate) fn handle_prepare_rename(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::TextDocumentPositionParams,
|
||||
) -> Result<Option<PrepareRenameResponse>> {
|
||||
let _p = profile("handle_prepare_rename");
|
||||
let _p = profile::span("handle_prepare_rename");
|
||||
let position = from_proto::file_position(&snap, params)?;
|
||||
|
||||
let optional_change = snap.analysis.rename(position, "dummy")?;
|
||||
|
@ -632,7 +631,7 @@ pub(crate) fn handle_rename(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: RenameParams,
|
||||
) -> Result<Option<WorkspaceEdit>> {
|
||||
let _p = profile("handle_rename");
|
||||
let _p = profile::span("handle_rename");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position)?;
|
||||
|
||||
if params.new_name.is_empty() {
|
||||
|
@ -656,7 +655,7 @@ pub(crate) fn handle_references(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::ReferenceParams,
|
||||
) -> Result<Option<Vec<Location>>> {
|
||||
let _p = profile("handle_references");
|
||||
let _p = profile::span("handle_references");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position)?;
|
||||
|
||||
let refs = match snap.analysis.find_all_refs(position, None)? {
|
||||
|
@ -683,7 +682,7 @@ pub(crate) fn handle_formatting(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: DocumentFormattingParams,
|
||||
) -> Result<Option<Vec<lsp_types::TextEdit>>> {
|
||||
let _p = profile("handle_formatting");
|
||||
let _p = profile::span("handle_formatting");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let file = snap.analysis.file_text(file_id)?;
|
||||
let crate_ids = snap.analysis.crate_for(file_id)?;
|
||||
|
@ -693,7 +692,7 @@ pub(crate) fn handle_formatting(
|
|||
|
||||
let mut rustfmt = match &snap.config.rustfmt {
|
||||
RustfmtConfig::Rustfmt { extra_args } => {
|
||||
let mut cmd = process::Command::new(ra_toolchain::rustfmt());
|
||||
let mut cmd = process::Command::new(toolchain::rustfmt());
|
||||
cmd.args(extra_args);
|
||||
if let Some(&crate_id) = crate_ids.first() {
|
||||
// Assume all crates are in the same edition
|
||||
|
@ -805,7 +804,7 @@ pub(crate) fn handle_code_action(
|
|||
mut snap: GlobalStateSnapshot,
|
||||
params: lsp_types::CodeActionParams,
|
||||
) -> Result<Option<Vec<lsp_ext::CodeAction>>> {
|
||||
let _p = profile("handle_code_action");
|
||||
let _p = profile::span("handle_code_action");
|
||||
// We intentionally don't support command-based actions, as those either
|
||||
// requires custom client-code anyway, or requires server-initiated edits.
|
||||
// Server initiated edits break causality, so we avoid those as well.
|
||||
|
@ -847,7 +846,7 @@ pub(crate) fn handle_resolve_code_action(
|
|||
mut snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::ResolveCodeActionParams,
|
||||
) -> Result<Option<lsp_ext::SnippetWorkspaceEdit>> {
|
||||
let _p = profile("handle_resolve_code_action");
|
||||
let _p = profile::span("handle_resolve_code_action");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.code_action_params.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
let range = from_proto::text_range(&line_index, params.code_action_params.range);
|
||||
|
@ -871,7 +870,7 @@ pub(crate) fn handle_code_lens(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::CodeLensParams,
|
||||
) -> Result<Option<Vec<CodeLens>>> {
|
||||
let _p = profile("handle_code_lens");
|
||||
let _p = profile::span("handle_code_lens");
|
||||
let mut lenses: Vec<CodeLens> = Default::default();
|
||||
|
||||
if snap.config.lens.none() {
|
||||
|
@ -957,7 +956,7 @@ pub(crate) fn handle_code_lens_resolve(
|
|||
snap: GlobalStateSnapshot,
|
||||
code_lens: CodeLens,
|
||||
) -> Result<CodeLens> {
|
||||
let _p = profile("handle_code_lens_resolve");
|
||||
let _p = profile::span("handle_code_lens_resolve");
|
||||
let data = code_lens.data.unwrap();
|
||||
let resolve = from_json::<Option<CodeLensResolveData>>("CodeLensResolveData", data)?;
|
||||
match resolve {
|
||||
|
@ -994,7 +993,7 @@ pub(crate) fn handle_document_highlight(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_types::DocumentHighlightParams,
|
||||
) -> Result<Option<Vec<DocumentHighlight>>> {
|
||||
let _p = profile("handle_document_highlight");
|
||||
let _p = profile::span("handle_document_highlight");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
|
||||
let line_index = snap.analysis.file_line_index(position.file_id)?;
|
||||
|
||||
|
@ -1021,7 +1020,7 @@ pub(crate) fn handle_ssr(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: lsp_ext::SsrParams,
|
||||
) -> Result<lsp_types::WorkspaceEdit> {
|
||||
let _p = profile("handle_ssr");
|
||||
let _p = profile::span("handle_ssr");
|
||||
let selections = params
|
||||
.selections
|
||||
.iter()
|
||||
|
@ -1041,7 +1040,7 @@ pub(crate) fn publish_diagnostics(
|
|||
snap: &GlobalStateSnapshot,
|
||||
file_id: FileId,
|
||||
) -> Result<Vec<Diagnostic>> {
|
||||
let _p = profile("publish_diagnostics");
|
||||
let _p = profile::span("publish_diagnostics");
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
let diagnostics: Vec<Diagnostic> = snap
|
||||
.analysis
|
||||
|
@ -1064,7 +1063,7 @@ pub(crate) fn handle_inlay_hints(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: InlayHintsParams,
|
||||
) -> Result<Vec<InlayHint>> {
|
||||
let _p = profile("handle_inlay_hints");
|
||||
let _p = profile::span("handle_inlay_hints");
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let line_index = snap.analysis.file_line_index(file_id)?;
|
||||
Ok(snap
|
||||
|
@ -1079,7 +1078,7 @@ pub(crate) fn handle_call_hierarchy_prepare(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: CallHierarchyPrepareParams,
|
||||
) -> Result<Option<Vec<CallHierarchyItem>>> {
|
||||
let _p = profile("handle_call_hierarchy_prepare");
|
||||
let _p = profile::span("handle_call_hierarchy_prepare");
|
||||
let position = from_proto::file_position(&snap, params.text_document_position_params)?;
|
||||
|
||||
let nav_info = match snap.analysis.call_hierarchy(position)? {
|
||||
|
@ -1101,7 +1100,7 @@ pub(crate) fn handle_call_hierarchy_incoming(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: CallHierarchyIncomingCallsParams,
|
||||
) -> Result<Option<Vec<CallHierarchyIncomingCall>>> {
|
||||
let _p = profile("handle_call_hierarchy_incoming");
|
||||
let _p = profile::span("handle_call_hierarchy_incoming");
|
||||
let item = params.item;
|
||||
|
||||
let doc = TextDocumentIdentifier::new(item.uri);
|
||||
|
@ -1136,7 +1135,7 @@ pub(crate) fn handle_call_hierarchy_outgoing(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: CallHierarchyOutgoingCallsParams,
|
||||
) -> Result<Option<Vec<CallHierarchyOutgoingCall>>> {
|
||||
let _p = profile("handle_call_hierarchy_outgoing");
|
||||
let _p = profile::span("handle_call_hierarchy_outgoing");
|
||||
let item = params.item;
|
||||
|
||||
let doc = TextDocumentIdentifier::new(item.uri);
|
||||
|
@ -1171,7 +1170,7 @@ pub(crate) fn handle_semantic_tokens(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: SemanticTokensParams,
|
||||
) -> Result<Option<SemanticTokensResult>> {
|
||||
let _p = profile("handle_semantic_tokens");
|
||||
let _p = profile::span("handle_semantic_tokens");
|
||||
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let text = snap.analysis.file_text(file_id)?;
|
||||
|
@ -1190,7 +1189,7 @@ pub(crate) fn handle_semantic_tokens_edits(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: SemanticTokensEditsParams,
|
||||
) -> Result<Option<SemanticTokensEditResult>> {
|
||||
let _p = profile("handle_semantic_tokens_edits");
|
||||
let _p = profile::span("handle_semantic_tokens_edits");
|
||||
|
||||
let file_id = from_proto::file_id(&snap, ¶ms.text_document.uri)?;
|
||||
let text = snap.analysis.file_text(file_id)?;
|
||||
|
@ -1220,7 +1219,7 @@ pub(crate) fn handle_semantic_tokens_range(
|
|||
snap: GlobalStateSnapshot,
|
||||
params: SemanticTokensRangeParams,
|
||||
) -> Result<Option<SemanticTokensRangeResult>> {
|
||||
let _p = profile("handle_semantic_tokens_range");
|
||||
let _p = profile::span("handle_semantic_tokens_range");
|
||||
|
||||
let frange = from_proto::file_range(&snap, params.text_document, params.range)?;
|
||||
let text = snap.analysis.file_text(frange.file_id)?;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Implementation of the LSP for rust-analyzer.
|
||||
//!
|
||||
//! This crate takes Rust-specific analysis results from ra_ide and translates
|
||||
//! This crate takes Rust-specific analysis results from ide and translates
|
||||
//! into LSP types.
|
||||
//!
|
||||
//! It also is the root of all state. `world` module defines the bulk of the
|
||||
|
@ -41,7 +41,7 @@ use serde::de::DeserializeOwned;
|
|||
|
||||
pub type Result<T, E = Box<dyn std::error::Error + Send + Sync>> = std::result::Result<T, E>;
|
||||
pub use crate::{caps::server_capabilities, main_loop::main_loop};
|
||||
use ra_ide::AnalysisHost;
|
||||
use ide::AnalysisHost;
|
||||
use std::fmt;
|
||||
use vfs::Vfs;
|
||||
|
||||
|
@ -74,16 +74,16 @@ impl std::error::Error for LspError {}
|
|||
fn print_memory_usage(mut host: AnalysisHost, vfs: Vfs) {
|
||||
let mut mem = host.per_query_memory_usage();
|
||||
|
||||
let before = ra_prof::memory_usage();
|
||||
let before = profile::memory_usage();
|
||||
drop(vfs);
|
||||
let vfs = before.allocated - ra_prof::memory_usage().allocated;
|
||||
let vfs = before.allocated - profile::memory_usage().allocated;
|
||||
mem.push(("VFS".into(), vfs));
|
||||
|
||||
let before = ra_prof::memory_usage();
|
||||
let before = profile::memory_usage();
|
||||
drop(host);
|
||||
mem.push(("Unaccounted".into(), before.allocated - ra_prof::memory_usage().allocated));
|
||||
mem.push(("Unaccounted".into(), before.allocated - profile::memory_usage().allocated));
|
||||
|
||||
mem.push(("Remaining".into(), ra_prof::memory_usage().allocated));
|
||||
mem.push(("Remaining".into(), profile::memory_usage().allocated));
|
||||
|
||||
for (name, bytes) in mem {
|
||||
eprintln!("{:>8} {}", bytes, name);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
//! Utilities for LSP-related boilerplate code.
|
||||
use std::{error::Error, ops::Range};
|
||||
|
||||
use base_db::Canceled;
|
||||
use ide::LineIndex;
|
||||
use lsp_server::Notification;
|
||||
use ra_db::Canceled;
|
||||
use ra_ide::LineIndex;
|
||||
|
||||
use crate::{from_proto, global_state::GlobalState};
|
||||
|
||||
|
|
|
@ -5,12 +5,11 @@ use std::{
|
|||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
use base_db::VfsPath;
|
||||
use crossbeam_channel::{select, Receiver};
|
||||
use ide::{Canceled, FileId};
|
||||
use lsp_server::{Connection, Notification, Request, Response};
|
||||
use lsp_types::notification::Notification as _;
|
||||
use ra_db::VfsPath;
|
||||
use ra_ide::{Canceled, FileId};
|
||||
use ra_prof::profile;
|
||||
|
||||
use crate::{
|
||||
config::Config,
|
||||
|
@ -22,7 +21,7 @@ use crate::{
|
|||
lsp_utils::{apply_document_changes, is_canceled, notification_is, Progress},
|
||||
Result,
|
||||
};
|
||||
use ra_project_model::ProjectWorkspace;
|
||||
use project_model::ProjectWorkspace;
|
||||
use vfs::ChangeKind;
|
||||
|
||||
pub fn main_loop(config: Config, connection: Connection) -> Result<()> {
|
||||
|
@ -173,7 +172,7 @@ impl GlobalState {
|
|||
fn handle_event(&mut self, event: Event) -> Result<()> {
|
||||
let loop_start = Instant::now();
|
||||
// NOTE: don't count blocking select! call as a loop-turn time
|
||||
let _p = profile("GlobalState::handle_event");
|
||||
let _p = profile::span("GlobalState::handle_event");
|
||||
|
||||
log::info!("handle_event({:?})", event);
|
||||
let queue_count = self.task_pool.handle.len();
|
||||
|
@ -204,7 +203,7 @@ impl GlobalState {
|
|||
self.analysis_host.maybe_collect_garbage();
|
||||
}
|
||||
Event::Vfs(mut task) => {
|
||||
let _p = profile("GlobalState::handle_event/vfs");
|
||||
let _p = profile::span("GlobalState::handle_event/vfs");
|
||||
loop {
|
||||
match task {
|
||||
vfs::loader::Message::Loaded { files } => {
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
//! Project loading & configuration updates
|
||||
use std::{mem, sync::Arc};
|
||||
|
||||
use base_db::{CrateGraph, SourceRoot, VfsPath};
|
||||
use flycheck::FlycheckHandle;
|
||||
use ra_db::{CrateGraph, SourceRoot, VfsPath};
|
||||
use ra_ide::AnalysisChange;
|
||||
use ra_prof::profile;
|
||||
use ra_project_model::{ProcMacroClient, ProjectWorkspace};
|
||||
use ide::AnalysisChange;
|
||||
use project_model::{ProcMacroClient, ProjectWorkspace};
|
||||
use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind};
|
||||
|
||||
use crate::{
|
||||
|
@ -17,7 +16,7 @@ use crate::{
|
|||
|
||||
impl GlobalState {
|
||||
pub(crate) fn update_configuration(&mut self, config: Config) {
|
||||
let _p = profile("GlobalState::update_configuration");
|
||||
let _p = profile::span("GlobalState::update_configuration");
|
||||
let old_config = mem::replace(&mut self.config, config);
|
||||
if self.config.lru_capacity != old_config.lru_capacity {
|
||||
self.analysis_host.update_lru_capacity(old_config.lru_capacity);
|
||||
|
@ -99,14 +98,14 @@ impl GlobalState {
|
|||
.iter()
|
||||
.map(|project| match project {
|
||||
LinkedProject::ProjectManifest(manifest) => {
|
||||
ra_project_model::ProjectWorkspace::load(
|
||||
project_model::ProjectWorkspace::load(
|
||||
manifest.clone(),
|
||||
&cargo_config,
|
||||
with_sysroot,
|
||||
)
|
||||
}
|
||||
LinkedProject::InlineJsonProject(it) => {
|
||||
Ok(ra_project_model::ProjectWorkspace::Json { project: it.clone() })
|
||||
Ok(project_model::ProjectWorkspace::Json { project: it.clone() })
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -115,7 +114,7 @@ impl GlobalState {
|
|||
});
|
||||
}
|
||||
pub(crate) fn switch_workspaces(&mut self, workspaces: Vec<anyhow::Result<ProjectWorkspace>>) {
|
||||
let _p = profile("GlobalState::switch_workspaces");
|
||||
let _p = profile::span("GlobalState::switch_workspaces");
|
||||
log::info!("reloading projects: {:?}", self.config.linked_projects);
|
||||
|
||||
let mut has_errors = false;
|
||||
|
@ -177,7 +176,7 @@ impl GlobalState {
|
|||
Ok(it) => it,
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
"Failed to run ra_proc_macro_srv from path {}, error: {:?}",
|
||||
"Failed to run proc_macro_srv from path {}, error: {:?}",
|
||||
path.display(),
|
||||
err
|
||||
);
|
||||
|
@ -300,7 +299,7 @@ pub(crate) struct SourceRootConfig {
|
|||
|
||||
impl SourceRootConfig {
|
||||
pub(crate) fn partition(&self, vfs: &vfs::Vfs) -> Vec<SourceRoot> {
|
||||
let _p = profile("SourceRootConfig::partition");
|
||||
let _p = profile::span("SourceRootConfig::partition");
|
||||
self.fsc
|
||||
.partition(vfs)
|
||||
.into_iter()
|
||||
|
|
|
@ -4,15 +4,15 @@ use std::{
|
|||
sync::atomic::{AtomicU32, Ordering},
|
||||
};
|
||||
|
||||
use itertools::Itertools;
|
||||
use ra_db::{FileId, FileRange};
|
||||
use ra_ide::{
|
||||
use base_db::{FileId, FileRange};
|
||||
use ide::{
|
||||
Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation,
|
||||
FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, HighlightedRange,
|
||||
Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, NavigationTarget,
|
||||
ReferenceAccess, ResolvedAssist, Runnable, Severity, SourceChange, SourceFileEdit, TextEdit,
|
||||
};
|
||||
use ra_syntax::{SyntaxKind, TextRange, TextSize};
|
||||
use itertools::Itertools;
|
||||
use syntax::{SyntaxKind, TextRange, TextSize};
|
||||
|
||||
use crate::{
|
||||
cargo_target_spec::CargoTargetSpec, global_state::GlobalStateSnapshot,
|
||||
|
@ -761,7 +761,7 @@ pub(crate) fn markup_content(markup: Markup) -> lsp_types::MarkupContent {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use ra_ide::Analysis;
|
||||
use ide::Analysis;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[
|
||||
MappedRustDiagnostic {
|
||||
url: "file:///test/crates/ra_hir_def/src/data.rs",
|
||||
url: "file:///test/crates/hir_def/src/data.rs",
|
||||
diagnostic: Diagnostic {
|
||||
range: Range {
|
||||
start: Position {
|
||||
|
@ -24,7 +24,7 @@
|
|||
[
|
||||
DiagnosticRelatedInformation {
|
||||
location: Location {
|
||||
uri: "file:///test/crates/ra_hir_def/src/path.rs",
|
||||
uri: "file:///test/crates/hir_def/src/path.rs",
|
||||
range: Range {
|
||||
start: Position {
|
||||
line: 264,
|
||||
|
|
|
@ -12,7 +12,7 @@ use lsp_types::{
|
|||
notification::Exit, request::Shutdown, TextDocumentIdentifier, Url, WorkDoneProgress,
|
||||
};
|
||||
use lsp_types::{ProgressParams, ProgressParamsValue};
|
||||
use ra_project_model::ProjectManifest;
|
||||
use project_model::ProjectManifest;
|
||||
use rust_analyzer::{
|
||||
config::{ClientCapsConfig, Config, FilesConfig, FilesWatcher, LinkedProject},
|
||||
main_loop,
|
||||
|
@ -62,7 +62,7 @@ impl<'a> Project<'a> {
|
|||
static INIT: Once = Once::new();
|
||||
INIT.call_once(|| {
|
||||
env_logger::builder().is_test(true).try_init().unwrap();
|
||||
ra_prof::init_from(crate::PROFILE);
|
||||
profile::init_from(crate::PROFILE);
|
||||
});
|
||||
|
||||
for entry in Fixture::parse(self.fixture) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue