Remove unnecessary file_id argument

This commit is contained in:
vsrs 2021-02-27 19:07:14 +03:00
parent 5d23d8bc29
commit 31f5f816e3
2 changed files with 7 additions and 10 deletions

View file

@ -555,7 +555,7 @@ pub(crate) fn handle_runnables(
if should_skip_target(&runnable, cargo_spec.as_ref()) { if should_skip_target(&runnable, cargo_spec.as_ref()) {
continue; continue;
} }
let mut runnable = to_proto::runnable(&snap, file_id, runnable)?; let mut runnable = to_proto::runnable(&snap, runnable)?;
if expect_test { if expect_test {
runnable.label = format!("{} + expect", runnable.label); runnable.label = format!("{} + expect", runnable.label);
runnable.args.expect_test = Some(true); runnable.args.expect_test = Some(true);
@ -773,7 +773,7 @@ pub(crate) fn handle_hover(
contents: HoverContents::Markup(to_proto::markup_content(info.info.markup)), contents: HoverContents::Markup(to_proto::markup_content(info.info.markup)),
range: Some(range), range: Some(range),
}, },
actions: prepare_hover_actions(&snap, position.file_id, &info.info.actions), actions: prepare_hover_actions(&snap, &info.info.actions),
}; };
Ok(Some(hover)) Ok(Some(hover))
@ -1438,17 +1438,16 @@ fn show_impl_command_link(
fn runnable_action_links( fn runnable_action_links(
snap: &GlobalStateSnapshot, snap: &GlobalStateSnapshot,
file_id: FileId,
runnable: Runnable, runnable: Runnable,
) -> Option<lsp_ext::CommandLinkGroup> { ) -> Option<lsp_ext::CommandLinkGroup> {
let cargo_spec = CargoTargetSpec::for_file(&snap, file_id).ok()?; let cargo_spec = CargoTargetSpec::for_file(&snap, runnable.nav.file_id).ok()?;
let hover_config = snap.config.hover(); let hover_config = snap.config.hover();
if !hover_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) { if !hover_config.runnable() || should_skip_target(&runnable, cargo_spec.as_ref()) {
return None; return None;
} }
let action: &'static _ = runnable.action(); let action: &'static _ = runnable.action();
to_proto::runnable(snap, file_id, runnable).ok().map(|r| { to_proto::runnable(snap, runnable).ok().map(|r| {
let mut group = lsp_ext::CommandLinkGroup::default(); let mut group = lsp_ext::CommandLinkGroup::default();
if hover_config.run { if hover_config.run {
@ -1487,7 +1486,6 @@ fn goto_type_action_links(
fn prepare_hover_actions( fn prepare_hover_actions(
snap: &GlobalStateSnapshot, snap: &GlobalStateSnapshot,
file_id: FileId,
actions: &[HoverAction], actions: &[HoverAction],
) -> Vec<lsp_ext::CommandLinkGroup> { ) -> Vec<lsp_ext::CommandLinkGroup> {
if snap.config.hover().none() || !snap.config.hover_actions() { if snap.config.hover().none() || !snap.config.hover_actions() {
@ -1498,7 +1496,7 @@ fn prepare_hover_actions(
.iter() .iter()
.filter_map(|it| match it { .filter_map(|it| match it {
HoverAction::Implementation(position) => show_impl_command_link(snap, position), HoverAction::Implementation(position) => show_impl_command_link(snap, position),
HoverAction::Runnable(r) => runnable_action_links(snap, file_id, r.clone()), HoverAction::Runnable(r) => runnable_action_links(snap, r.clone()),
HoverAction::GoToType(targets) => goto_type_action_links(snap, targets), HoverAction::GoToType(targets) => goto_type_action_links(snap, targets),
}) })
.collect() .collect()

View file

@ -828,11 +828,10 @@ pub(crate) fn resolved_code_action(
pub(crate) fn runnable( pub(crate) fn runnable(
snap: &GlobalStateSnapshot, snap: &GlobalStateSnapshot,
file_id: FileId,
runnable: Runnable, runnable: Runnable,
) -> Result<lsp_ext::Runnable> { ) -> Result<lsp_ext::Runnable> {
let config = snap.config.runnables(); let config = snap.config.runnables();
let spec = CargoTargetSpec::for_file(snap, file_id)?; let spec = CargoTargetSpec::for_file(snap, runnable.nav.file_id)?;
let workspace_root = spec.as_ref().map(|it| it.workspace_root.clone()); let workspace_root = spec.as_ref().map(|it| it.workspace_root.clone());
let target = spec.as_ref().map(|s| s.target.clone()); let target = spec.as_ref().map(|s| s.target.clone());
let (cargo_args, executable_args) = let (cargo_args, executable_args) =
@ -865,7 +864,7 @@ pub(crate) fn code_lens(
let annotation_range = range(&line_index, annotation.range); let annotation_range = range(&line_index, annotation.range);
let action = run.action(); let action = run.action();
let r = runnable(&snap, run.nav.file_id, run)?; let r = runnable(&snap, run)?;
let command = if debug { let command = if debug {
command::debug_single(&r) command::debug_single(&r)