mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-02 04:48:13 +00:00
Show workspace info in the status bar
This commit is contained in:
parent
56bee2ddaf
commit
18ca22a98e
15 changed files with 168 additions and 81 deletions
|
|
@ -13,7 +13,7 @@ mod version;
|
|||
|
||||
use base_db::Env;
|
||||
use indexmap::IndexSet;
|
||||
use paths::AbsPathBuf;
|
||||
use paths::{AbsPath, AbsPathBuf};
|
||||
use rustc_hash::FxHashMap;
|
||||
use span::Span;
|
||||
use std::{
|
||||
|
|
@ -54,6 +54,7 @@ pub struct ProcMacroServer {
|
|||
///
|
||||
/// Therefore, we just wrap the `ProcMacroProcessSrv` in a mutex here.
|
||||
process: Arc<Mutex<ProcMacroProcessSrv>>,
|
||||
path: AbsPathBuf,
|
||||
}
|
||||
|
||||
pub struct MacroDylib {
|
||||
|
|
@ -113,11 +114,18 @@ pub struct MacroPanic {
|
|||
impl ProcMacroServer {
|
||||
/// Spawns an external process as the proc macro server and returns a client connected to it.
|
||||
pub fn spawn(
|
||||
process_path: AbsPathBuf,
|
||||
process_path: &AbsPath,
|
||||
env: &FxHashMap<String, String>,
|
||||
) -> io::Result<ProcMacroServer> {
|
||||
let process = ProcMacroProcessSrv::run(process_path, env)?;
|
||||
Ok(ProcMacroServer { process: Arc::new(Mutex::new(process)) })
|
||||
Ok(ProcMacroServer {
|
||||
process: Arc::new(Mutex::new(process)),
|
||||
path: process_path.to_owned(),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn path(&self) -> &AbsPath {
|
||||
&self.path
|
||||
}
|
||||
|
||||
pub fn load_dylib(&self, dylib: MacroDylib) -> Result<Vec<ProcMacro>, ServerError> {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
sync::Arc,
|
||||
};
|
||||
|
||||
use paths::{AbsPath, AbsPathBuf};
|
||||
use paths::AbsPath;
|
||||
use rustc_hash::FxHashMap;
|
||||
use stdx::JodChild;
|
||||
|
||||
|
|
@ -28,11 +28,11 @@ pub(crate) struct ProcMacroProcessSrv {
|
|||
|
||||
impl ProcMacroProcessSrv {
|
||||
pub(crate) fn run(
|
||||
process_path: AbsPathBuf,
|
||||
process_path: &AbsPath,
|
||||
env: &FxHashMap<String, String>,
|
||||
) -> io::Result<ProcMacroProcessSrv> {
|
||||
let create_srv = |null_stderr| {
|
||||
let mut process = Process::run(process_path.clone(), env, null_stderr)?;
|
||||
let mut process = Process::run(process_path, env, null_stderr)?;
|
||||
let (stdin, stdout) = process.stdio().expect("couldn't access child stdio");
|
||||
|
||||
io::Result::Ok(ProcMacroProcessSrv {
|
||||
|
|
@ -153,11 +153,11 @@ struct Process {
|
|||
|
||||
impl Process {
|
||||
fn run(
|
||||
path: AbsPathBuf,
|
||||
path: &AbsPath,
|
||||
env: &FxHashMap<String, String>,
|
||||
null_stderr: bool,
|
||||
) -> io::Result<Process> {
|
||||
let child = JodChild(mk_child(&path, env, null_stderr)?);
|
||||
let child = JodChild(mk_child(path, env, null_stderr)?);
|
||||
Ok(Process { child })
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue