-
Notifications
You must be signed in to change notification settings - Fork 1.8k
internal: remove invocationLocation
in favor of invocationStrategy
#17888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,13 +80,6 @@ config_data! { | |
pub(crate) cargo_autoreload: bool = true, | ||
/// Run build scripts (`build.rs`) for more precise code analysis. | ||
cargo_buildScripts_enable: bool = true, | ||
/// Specifies the working directory for running build scripts. | ||
/// - "workspace": run build scripts for a workspace in the workspace's root directory. | ||
/// This is incompatible with `#rust-analyzer.cargo.buildScripts.invocationStrategy#` set to `once`. | ||
/// - "root": run build scripts in the project's root directory. | ||
/// This config only has an effect when `#rust-analyzer.cargo.buildScripts.overrideCommand#` | ||
/// is set. | ||
cargo_buildScripts_invocationLocation: InvocationLocation = InvocationLocation::Workspace, | ||
/// Specifies the invocation strategy to use when running the build scripts command. | ||
/// If `per_workspace` is set, the command will be executed for each workspace. | ||
/// If `once` is set, the command will be executed once. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should document the working directory that the command will be executed in, for both cases. |
||
|
@@ -101,8 +94,7 @@ config_data! { | |
/// If there are multiple linked projects/workspaces, this command is invoked for | ||
/// each of them, with the working directory being the workspace root | ||
/// (i.e., the folder containing the `Cargo.toml`). This can be overwritten | ||
/// by changing `#rust-analyzer.cargo.buildScripts.invocationStrategy#` and | ||
/// `#rust-analyzer.cargo.buildScripts.invocationLocation#`. | ||
/// by changing `#rust-analyzer.cargo.buildScripts.invocationStrategy#`. | ||
/// | ||
/// By default, a cargo invocation will be constructed for the configured | ||
/// targets and features, with the following base command line: | ||
|
@@ -182,14 +174,6 @@ config_data! { | |
/// | ||
/// For example for `cargo check`: `dead_code`, `unused_imports`, `unused_variables`,... | ||
check_ignore: FxHashSet<String> = FxHashSet::default(), | ||
/// Specifies the working directory for running checks. | ||
/// - "workspace": run checks for workspaces in the corresponding workspaces' root directories. | ||
// FIXME: Ideally we would support this in some way | ||
/// This falls back to "root" if `#rust-analyzer.check.invocationStrategy#` is set to `once`. | ||
/// - "root": run checks in the project's root directory. | ||
/// This config only has an effect when `#rust-analyzer.check.overrideCommand#` | ||
/// is set. | ||
check_invocationLocation | checkOnSave_invocationLocation: InvocationLocation = InvocationLocation::Workspace, | ||
/// Specifies the invocation strategy to use when running the check command. | ||
/// If `per_workspace` is set, the command will be executed for each workspace. | ||
/// If `once` is set, the command will be executed once. | ||
|
@@ -212,8 +196,7 @@ config_data! { | |
/// If there are multiple linked projects/workspaces, this command is invoked for | ||
/// each of them, with the working directory being the workspace root | ||
/// (i.e., the folder containing the `Cargo.toml`). This can be overwritten | ||
/// by changing `#rust-analyzer.check.invocationStrategy#` and | ||
/// `#rust-analyzer.check.invocationLocation#`. | ||
/// by changing `#rust-analyzer.check.invocationStrategy#`. | ||
/// | ||
/// If `$saved_file` is part of the command, rust-analyzer will pass | ||
/// the absolute path of the saved file to the provided command. This is | ||
|
@@ -1868,12 +1851,6 @@ impl Config { | |
InvocationStrategy::Once => project_model::InvocationStrategy::Once, | ||
InvocationStrategy::PerWorkspace => project_model::InvocationStrategy::PerWorkspace, | ||
}, | ||
invocation_location: match self.cargo_buildScripts_invocationLocation(None) { | ||
InvocationLocation::Root => { | ||
project_model::InvocationLocation::Root(self.root_path.clone()) | ||
} | ||
InvocationLocation::Workspace => project_model::InvocationLocation::Workspace, | ||
}, | ||
run_build_script_command: self.cargo_buildScripts_overrideCommand(None).clone(), | ||
extra_args: self.cargo_extraArgs(None).clone(), | ||
extra_env: self.cargo_extraEnv(None).clone(), | ||
|
@@ -1930,14 +1907,6 @@ impl Config { | |
crate::flycheck::InvocationStrategy::PerWorkspace | ||
} | ||
}, | ||
invocation_location: match self.check_invocationLocation(None) { | ||
InvocationLocation::Root => { | ||
crate::flycheck::InvocationLocation::Root(self.root_path.clone()) | ||
} | ||
InvocationLocation::Workspace => { | ||
crate::flycheck::InvocationLocation::Workspace | ||
} | ||
}, | ||
} | ||
} | ||
Some(_) | None => FlycheckConfig::CargoCommand { | ||
|
@@ -2348,13 +2317,6 @@ pub(crate) enum InvocationStrategy { | |
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
struct CheckOnSaveTargets(#[serde(with = "single_or_array")] Vec<String>); | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
#[serde(rename_all = "snake_case")] | ||
enum InvocationLocation { | ||
Root, | ||
Workspace, | ||
} | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone)] | ||
#[serde(rename_all = "snake_case")] | ||
enum LifetimeElisionDef { | ||
|
@@ -3196,14 +3158,6 @@ fn field_props(field: &str, ty: &str, doc: &[&str], default: &str) -> serde_json | |
"The command will be executed once." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be good to also mention the effect on the working directory here. |
||
], | ||
}, | ||
"InvocationLocation" => set! { | ||
"type": "string", | ||
"enum": ["workspace", "root"], | ||
"enumDescriptions": [ | ||
"The command will be executed in the corresponding workspace root.", | ||
"The command will be executed in the project root." | ||
], | ||
}, | ||
"Option<CheckOnSaveTargets>" => set! { | ||
"anyOf": [ | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am surprised by this;
once
should not be per-workspace... or does this refer to the vscode concept of a workspace rather than the cargo concent?The argument list for this function is quite confusing since there are multiple "workspaces" but then just a single "workspace_root"...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name here is a bit misleading (should be renamed into
current_dir
/working_dir
, the sole caller of this passes the actual root here.