mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Fix extern_process args
This commit is contained in:
parent
177becea98
commit
b4c5ee33ae
2 changed files with 22 additions and 8 deletions
|
@ -12,6 +12,7 @@ pub mod msg;
|
||||||
use process::{ProcMacroProcessSrv, ProcMacroProcessThread};
|
use process::{ProcMacroProcessSrv, ProcMacroProcessThread};
|
||||||
use ra_tt::{SmolStr, Subtree};
|
use ra_tt::{SmolStr, Subtree};
|
||||||
use std::{
|
use std::{
|
||||||
|
ffi::OsStr,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
};
|
};
|
||||||
|
@ -56,10 +57,14 @@ pub struct ProcMacroClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProcMacroClient {
|
impl ProcMacroClient {
|
||||||
pub fn extern_process<T: AsRef<str>>(
|
pub fn extern_process<I, S>(
|
||||||
process_path: &Path,
|
process_path: &Path,
|
||||||
args: &[T],
|
args: I,
|
||||||
) -> Result<ProcMacroClient, std::io::Error> {
|
) -> Result<ProcMacroClient, std::io::Error>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = S>,
|
||||||
|
S: AsRef<OsStr>,
|
||||||
|
{
|
||||||
let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?;
|
let (thread, process) = ProcMacroProcessSrv::run(process_path, args)?;
|
||||||
Ok(ProcMacroClient {
|
Ok(ProcMacroClient {
|
||||||
kind: ProcMacroClientKind::Process { process: Arc::new(process), thread },
|
kind: ProcMacroClientKind::Process { process: Arc::new(process), thread },
|
||||||
|
|
|
@ -9,6 +9,7 @@ use crate::rpc::{ExpansionResult, ExpansionTask, ListMacrosResult, ListMacrosTas
|
||||||
use io::{BufRead, BufReader};
|
use io::{BufRead, BufReader};
|
||||||
use std::{
|
use std::{
|
||||||
convert::{TryFrom, TryInto},
|
convert::{TryFrom, TryInto},
|
||||||
|
ffi::OsStr,
|
||||||
io::{self, Write},
|
io::{self, Write},
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::{Child, Command, Stdio},
|
process::{Child, Command, Stdio},
|
||||||
|
@ -44,9 +45,13 @@ impl Drop for Process {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Process {
|
impl Process {
|
||||||
fn run<T: AsRef<str>>(process_path: &Path, args: &[T]) -> Result<Process, io::Error> {
|
fn run<I, S>(process_path: &Path, args: I) -> Result<Process, io::Error>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = S>,
|
||||||
|
S: AsRef<OsStr>,
|
||||||
|
{
|
||||||
let child = Command::new(process_path.clone())
|
let child = Command::new(process_path.clone())
|
||||||
.args(args.iter().map(|it| it.as_ref()))
|
.args(args)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stderr(Stdio::null())
|
.stderr(Stdio::null())
|
||||||
|
@ -75,10 +80,14 @@ impl Process {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ProcMacroProcessSrv {
|
impl ProcMacroProcessSrv {
|
||||||
pub fn run<T: AsRef<str>>(
|
pub fn run<I, S>(
|
||||||
process_path: &Path,
|
process_path: &Path,
|
||||||
args: &[T],
|
args: I,
|
||||||
) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error> {
|
) -> Result<(ProcMacroProcessThread, ProcMacroProcessSrv), io::Error>
|
||||||
|
where
|
||||||
|
I: IntoIterator<Item = S>,
|
||||||
|
S: AsRef<OsStr>,
|
||||||
|
{
|
||||||
let process = Process::run(process_path, args)?;
|
let process = Process::run(process_path, args)?;
|
||||||
|
|
||||||
let (task_tx, task_rx) = bounded(0);
|
let (task_tx, task_rx) = bounded(0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue