mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
feat(run): import Flutter/Dart run configurations from JetBrains and VS Code (#4460)
Importing run configurations skipped every Flutter/Dart entry. JetBrains FlutterRunConfigurationType (filePath, additionalArgs, buildFlavor, envs) and VS Code dart launches (deviceId, flutterMode, toolArgs, args as --dart-entrypoint-args; plain Dart projects as dart run) now become Flutter configurations run from the owning pubspec.yaml's directory. An imported entry identical to an existing configuration is skipped with the new sameAs reason, and compounds point to the existing one. Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com>
This commit is contained in:
co-authored by
wildcatDownstairs
parent
2129efd196
commit
282f1fd482
@@ -4,15 +4,15 @@
|
||||
//! than one place is taken from the first, in that order.
|
||||
//!
|
||||
//! Python, Django server, Django tests, pytest, npm, Jest, Vitest, Node.js, Shell Script,
|
||||
//! Application, JAR Application, Spring Boot, Go Application / Go Test and compound configurations become the
|
||||
//! Application, JAR Application, Spring Boot, Go Application / Go Test, Flutter and compound configurations become the
|
||||
//! matching kinds; other types are skipped with their type.
|
||||
//! `$PROJECT_DIR$` (and `$MODULE_DIR$`, `$MODULE_WORKING_DIR$`, `$ContentRoot$`,
|
||||
//! `$ProjectFileDir$`, all the project directory here) and `$USER_HOME$` are replaced; another
|
||||
//! path variable skips the configuration.
|
||||
|
||||
use super::{
|
||||
Entry, Found, SkipReason, command_name, config, env_var, normalize, path_from, project_python, relative_to,
|
||||
working_dir,
|
||||
Entry, Found, SkipReason, command_name, config, dart_package, env_var, flutter_run, normalize, path_from,
|
||||
project_python, relative_to, working_dir,
|
||||
};
|
||||
use crate::RunConfig;
|
||||
use ide_core::IdeResult;
|
||||
@@ -168,6 +168,7 @@ const JAR_APPLICATION: &str = "JarApplication";
|
||||
const SPRING_BOOT: &str = "SpringBootApplicationConfigurationType";
|
||||
const GO_APPLICATION: &str = "GoApplicationRunConfiguration";
|
||||
const GO_TEST: &str = "GoTestRunConfiguration";
|
||||
const FLUTTER: &str = "FlutterRunConfigurationType";
|
||||
|
||||
type Res<T> = Result<T, SkipReason>;
|
||||
|
||||
@@ -349,6 +350,7 @@ impl Cx<'_> {
|
||||
SPRING_BOOT => self.java_app(name, c, true, &mut ignored)?,
|
||||
GO_APPLICATION => self.go_config(name, c, false, &mut ignored)?,
|
||||
GO_TEST => self.go_config(name, c, true, &mut ignored)?,
|
||||
FLUTTER => self.flutter(name, c, &mut ignored)?,
|
||||
COMPOUND => {
|
||||
members = c.children_named("toRun").filter_map(|t| t.attr("name")).map(str::to_owned).collect();
|
||||
config(name, "compound", String::new(), Vec::new(), None)
|
||||
@@ -437,6 +439,32 @@ impl Cx<'_> {
|
||||
Ok(rc)
|
||||
}
|
||||
|
||||
/// The Flutter plugin's configuration (its `SdkFields`): `flutter run` in the entry's package,
|
||||
/// `additionalArgs` then `--flavor=<buildFlavor>` after the entry, as the plugin passes them.
|
||||
fn flutter(&self, name: &str, c: &El, ignored: &mut Vec<String>) -> Res<RunConfig> {
|
||||
let Some(entry) = self.path(c.option("filePath"))? else {
|
||||
return Err(SkipReason::NothingToRun);
|
||||
};
|
||||
let entry = normalize(&self.root.join(entry));
|
||||
let Some((package, _)) = dart_package(self.root, &entry) else {
|
||||
return Err(SkipReason::MissingFile { file: "pubspec.yaml".into() });
|
||||
};
|
||||
let mut extra = self.words(c.option("additionalArgs"))?;
|
||||
extra.extend(self.text(c.option("buildFlavor"))?.map(|f| format!("--flavor={f}")));
|
||||
let mut rc = flutter_run(name, self.root, &package, &entry, extra);
|
||||
// `<option name="envs"><map><entry key=… value=…/></map></option>`.
|
||||
let envs = c.children_named("option").filter(|o| o.attr("name") == Some("envs"));
|
||||
for e in envs.flat_map(|o| o.children.iter()).flat_map(|m| m.children_named("entry")) {
|
||||
if let Some(key) = e.attr("key").filter(|k| !k.is_empty()) {
|
||||
rc.env.insert(key.to_owned(), e.attr("value").unwrap_or_default().to_owned());
|
||||
}
|
||||
}
|
||||
if self.text(c.option("attachArgs"))?.is_some() {
|
||||
ignored.push("attachArgs".into());
|
||||
}
|
||||
Ok(rc)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- Python
|
||||
|
||||
/// The interpreter (`SDK_HOME` when the configuration doesn't use the module's), its
|
||||
|
||||
@@ -73,6 +73,8 @@ pub struct SkippedRunConfig {
|
||||
pub enum SkipReason {
|
||||
/// A configuration with this name already exists.
|
||||
NameTaken,
|
||||
/// An existing configuration (a detected one, say) runs the same command.
|
||||
SameAs { existing: String },
|
||||
/// The configuration type has no equivalent here: a VS Code debugger (`cppdbg`), a JetBrains type (`Application`).
|
||||
UnsupportedType {
|
||||
#[serde(rename = "type")]
|
||||
@@ -174,6 +176,13 @@ pub(crate) fn finish(source: RunImportSource, entries: Vec<Entry>, existing: &[R
|
||||
compounds.push((i, e.name, found));
|
||||
}
|
||||
Ok(mut found) => {
|
||||
// ponytail: only against the project's configurations; entries of one file may differ in ignored keys.
|
||||
if let Some(same) = existing.iter().find(|c| same_run(c, &found.config)) {
|
||||
// A compound naming it starts the one there is.
|
||||
by_name.insert(e.name.clone(), same.id.clone());
|
||||
skipped.push((i, skip(e.name, SkipReason::SameAs { existing: same.name.clone() })));
|
||||
continue;
|
||||
}
|
||||
found.config.id = unique_id(&e.name, &mut ids);
|
||||
by_name.insert(e.name.clone(), found.config.id.clone());
|
||||
imported.push((i, ImportedRunConfig { config: found.config, ignored: found.ignored }));
|
||||
@@ -205,8 +214,40 @@ pub(crate) fn finish(source: RunImportSource, entries: Vec<Entry>, existing: &[R
|
||||
}
|
||||
}
|
||||
|
||||
/// `a` and `b` start the same process (`flutter run -t lib/main.dart` detected and imported as `main.dart`).
|
||||
fn same_run(a: &RunConfig, b: &RunConfig) -> bool {
|
||||
a.kind == b.kind
|
||||
&& a.command == b.command
|
||||
&& a.args == b.args
|
||||
&& a.cwd == b.cwd
|
||||
&& a.is_test == b.is_test
|
||||
&& a.debug_adapter == b.debug_adapter
|
||||
&& a.env == b.env
|
||||
&& a.extras.params == b.extras.params
|
||||
&& a.extras.env_files == b.extras.env_files
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- shared by the sources
|
||||
|
||||
/// The Dart package `file` belongs to (the closest directory with a `pubspec.yaml`, inside the
|
||||
/// project) and whether it is a Flutter app.
|
||||
pub(crate) fn dart_package(root: &Path, file: &Path) -> Option<(PathBuf, bool)> {
|
||||
let dir =
|
||||
file.ancestors().skip(1).take_while(|d| d.starts_with(root)).find(|d| d.join("pubspec.yaml").is_file())?;
|
||||
let flutter = std::fs::read_to_string(dir.join("pubspec.yaml")).is_ok_and(|p| p.contains("sdk: flutter"));
|
||||
Some((dir.to_path_buf(), flutter))
|
||||
}
|
||||
|
||||
/// `flutter run -t <entry>` in `package` (absolute), as detection writes it; `extra` after the entry.
|
||||
pub(crate) fn flutter_run(name: &str, root: &Path, package: &Path, entry: &Path, extra: Vec<String>) -> RunConfig {
|
||||
let entry = relative_to(entry, package).unwrap_or_else(|| entry.to_string_lossy().into_owned());
|
||||
let mut args = vec!["run".to_owned(), "-t".to_owned(), entry];
|
||||
args.extend(extra);
|
||||
let mut c = config(name, "flutter", "flutter".into(), args, Some("dart"));
|
||||
c.cwd = working_dir(root, &package.to_string_lossy()).1.map(Into::into);
|
||||
c
|
||||
}
|
||||
|
||||
/// The variable `name` of `env`; Windows names ignore case (`${env:PATH}` finds `Path`).
|
||||
pub(crate) fn env_var(env: &BTreeMap<String, String>, name: &str, windows: bool) -> Option<String> {
|
||||
match env.get(name) {
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
//! `${input:…}`, `${command:…}`) is skipped.
|
||||
|
||||
use super::{
|
||||
Entry, Found, SkipReason, command_name, config, env_var, normalize, path_from, project_python, split_args,
|
||||
working_dir,
|
||||
Entry, Found, SkipReason, command_name, config, dart_package, env_var, flutter_run, normalize, path_from,
|
||||
project_python, split_args, working_dir,
|
||||
};
|
||||
use crate::RunConfig;
|
||||
use ide_core::{IdeError, IdeResult};
|
||||
@@ -48,6 +48,7 @@ const NODE_LAUNCH: &[&str] = &["program", "args", "runtimeExecutable", "runtimeA
|
||||
const NODE_ATTACH: &[&str] = &["address", "port", "localRoot", "remoteRoot"];
|
||||
const NODE_TERMINAL: &[&str] = &["command"];
|
||||
const BROWSER_LAUNCH: &[&str] = &["url", "webRoot"];
|
||||
const DART_LAUNCH: &[&str] = &["program", "args", "toolArgs", "deviceId", "flutterMode"];
|
||||
const COMPOUND: &[&str] = &["configurations"];
|
||||
|
||||
const PACKAGE_MANAGERS: &[&str] = &["npm", "pnpm", "yarn", "bun"];
|
||||
@@ -226,9 +227,10 @@ impl Cx<'_> {
|
||||
("chrome" | "pwa-chrome" | "msedge" | "pwa-msedge", "launch") => {
|
||||
(self.browser_launch(name, obj, ty)?, BROWSER_LAUNCH)
|
||||
}
|
||||
("dart", "launch") => (self.dart_launch(name, obj)?, DART_LAUNCH),
|
||||
(
|
||||
"debugpy" | "python" | "node" | "pwa-node" | "node-terminal" | "chrome" | "pwa-chrome" | "msedge"
|
||||
| "pwa-msedge",
|
||||
| "pwa-msedge" | "dart",
|
||||
other,
|
||||
) => {
|
||||
return Err(SkipReason::UnsupportedRequest { request: other.to_owned() });
|
||||
@@ -236,7 +238,9 @@ impl Cx<'_> {
|
||||
(other, _) => return Err(SkipReason::UnsupportedType { type_: other.to_owned() }),
|
||||
};
|
||||
if request == "launch" {
|
||||
config.cwd = self.cwd(obj)?.1.map(Into::into);
|
||||
if config.cwd.is_none() {
|
||||
config.cwd = self.cwd(obj)?.1.map(Into::into);
|
||||
}
|
||||
self.environment(obj, &mut config)?;
|
||||
}
|
||||
let mut ignored: Vec<String> = obj
|
||||
@@ -366,6 +370,43 @@ impl Cx<'_> {
|
||||
Ok(c)
|
||||
}
|
||||
|
||||
/// Dart Code's launch: `flutter run` in a Flutter app's package, as the Flutter debug adapter
|
||||
/// starts it (`args` go to the app), else `dart run`.
|
||||
fn dart_launch(&self, name: &str, obj: &Map<String, Value>) -> Res<RunConfig> {
|
||||
let (dir, _) = self.cwd(obj)?;
|
||||
let program = self.string(obj, "program")?;
|
||||
// Relative to `cwd`, or to the workspace folder as Dart Code resolves it.
|
||||
let file = |p: &str| {
|
||||
let base = [&dir, self.root].into_iter().find(|b| b.join(p).is_file()).unwrap_or(&dir);
|
||||
normalize(&base.join(p))
|
||||
};
|
||||
let entry = file(program.as_deref().unwrap_or("lib/main.dart"));
|
||||
let tool_args = self.words(obj, "toolArgs")?;
|
||||
let args = self.words(obj, "args")?;
|
||||
match dart_package(self.root, &entry) {
|
||||
Some((package, true)) => {
|
||||
let mut extra = Vec::new();
|
||||
if let Some(device) = self.string(obj, "deviceId")? {
|
||||
extra.extend(["-d".to_owned(), device]);
|
||||
}
|
||||
if let Some(mode @ ("profile" | "release")) = self.string(obj, "flutterMode")?.as_deref() {
|
||||
extra.push(format!("--{mode}"));
|
||||
}
|
||||
extra.extend(tool_args);
|
||||
extra.extend(args.into_iter().flat_map(|a| ["--dart-entrypoint-args".to_owned(), a]));
|
||||
Ok(flutter_run(name, self.root, &package, &entry, extra))
|
||||
}
|
||||
_ if program.is_none() => Err(SkipReason::NothingToRun),
|
||||
_ => {
|
||||
let mut words = vec!["run".to_owned()];
|
||||
words.extend(tool_args);
|
||||
words.push(self.path_from(entry.to_string_lossy().into_owned(), &dir));
|
||||
words.extend(args.into_iter().map(|a| self.path_from(a, &dir)));
|
||||
Ok(config(name, "dart", "dart".into(), words, Some("dart")))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `localRoot` (relative to the project root, empty for the root itself) and `remoteRoot`.
|
||||
fn roots(&self, obj: &Map<String, Value>, c: &mut RunConfig) -> Res<()> {
|
||||
if let Some(local) = self.string(obj, "localRoot")? {
|
||||
|
||||
@@ -1150,3 +1150,67 @@ fn imports_go_application_and_test_configurations() {
|
||||
assert_eq!(test.extras.params["pattern"], "TestLogin");
|
||||
assert_eq!(test.extras.params["module"], "pkg");
|
||||
}
|
||||
|
||||
// What `flutter create` writes to `.idea/runConfigurations/main_dart.xml`; the Flutter plugin's
|
||||
// `SdkFields` serializes `filePath`, `additionalArgs`, `buildFlavor`, `attachArgs` and `envs` as options:
|
||||
// https://github.com/flutter/flutter-intellij/blob/main/src/io/flutter/run/SdkFields.java
|
||||
const FLUTTER_MAIN: &str = r#"<configuration default="false" name="NAME" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="filePath" value="$PROJECT_DIR$/lib/main.dart" />
|
||||
<method v="2" />
|
||||
</configuration>"#;
|
||||
|
||||
const PUBSPEC_FLUTTER: &str = "name: my_app\ndependencies:\n flutter:\n sdk: flutter\n";
|
||||
|
||||
#[test]
|
||||
fn flutter_main_dart_from_flutter_create_is_the_detected_configuration() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
write(root, "pubspec.yaml", PUBSPEC_FLUTTER);
|
||||
write(root, "lib/main.dart", "void main() {}\n");
|
||||
write(root, ".idea/runConfigurations/main_dart.xml", &run_file("main.dart", FLUTTER_MAIN));
|
||||
|
||||
let alone = import_from(root, &[]);
|
||||
let c = get(&alone, "main.dart");
|
||||
assert_eq!((c.kind.as_str(), c.command.as_str()), ("flutter", "flutter"));
|
||||
assert_eq!(c.args, s(&["run", "-t", "lib/main.dart"]));
|
||||
assert_eq!((cwd(c), c.debug_adapter.as_deref()), (None, Some("dart")));
|
||||
|
||||
// Next to the detected `flutter run`, the same run is not listed twice.
|
||||
let r = import_from(root, &ide_run::detect(root));
|
||||
assert!(r.imported.is_empty(), "{r:#?}");
|
||||
assert_eq!(reason(&r, "main.dart"), &SkipReason::SameAs { existing: "flutter run".into() });
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flutter_flavors_entry_points_arguments_and_envs() {
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let root = dir.path();
|
||||
write(root, "app/pubspec.yaml", PUBSPEC_FLUTTER);
|
||||
write(root, "app/lib/main_dev.dart", "void main() {}\n");
|
||||
let dev = r#"<configuration name="Dev" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="additionalArgs" value="--dart-define=API="https://dev.example" --verbose" />
|
||||
<option name="attachArgs" value="--debug-port 9000" />
|
||||
<option name="buildFlavor" value="dev" />
|
||||
<option name="envs"><map><entry key="FLUTTER_LOG" value="1" /></map></option>
|
||||
<option name="filePath" value="$PROJECT_DIR$/app/lib/main_dev.dart" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="Gone" type="FlutterRunConfigurationType" factoryName="Flutter">
|
||||
<option name="filePath" value="$PROJECT_DIR$/elsewhere/main.dart" />
|
||||
</configuration>
|
||||
<configuration name="No entry" type="FlutterRunConfigurationType" factoryName="Flutter" />"#;
|
||||
write(root, ".idea/workspace.xml", &workspace(dev));
|
||||
|
||||
let r = import_from(root, &ide_run::detect(root));
|
||||
let c = get(&r, "Dev");
|
||||
assert_eq!(c.kind, "flutter");
|
||||
assert_eq!(
|
||||
c.args,
|
||||
s(&["run", "-t", "lib/main_dev.dart", "--dart-define=API=https://dev.example", "--verbose", "--flavor=dev"])
|
||||
);
|
||||
assert_eq!(cwd(c), Some(PathBuf::from("app")));
|
||||
assert_eq!(c.env, BTreeMap::from([("FLUTTER_LOG".into(), "1".into())]));
|
||||
assert_eq!(ignored(&r, "Dev"), ["attachArgs"]);
|
||||
assert_eq!(reason(&r, "Gone"), &SkipReason::MissingFile { file: "pubspec.yaml".into() });
|
||||
assert_eq!(reason(&r, "No entry"), &SkipReason::NothingToRun);
|
||||
}
|
||||
|
||||
@@ -555,3 +555,108 @@ fn existing_names_match_without_surrounding_spaces() {
|
||||
let r = import_from(dir.path(), &[existing]);
|
||||
assert_eq!(reason(&r, "Django"), &SkipReason::NameTaken);
|
||||
}
|
||||
|
||||
const PUBSPEC_FLUTTER: &str = "name: my_app\ndependencies:\n flutter:\n sdk: flutter\n";
|
||||
|
||||
fn write(root: &Path, rel: &str, text: &str) {
|
||||
let path = root.join(rel);
|
||||
fs::create_dir_all(path.parent().unwrap()).unwrap();
|
||||
fs::write(path, text).unwrap();
|
||||
}
|
||||
|
||||
// The configurations Dart Code adds to a Flutter app's launch.json.
|
||||
const FLUTTER: &str = r#"{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{ "name": "my_app", "request": "launch", "type": "dart" },
|
||||
{ "name": "my_app (profile mode)", "request": "launch", "type": "dart", "flutterMode": "profile" },
|
||||
{ "name": "my_app (release mode)", "request": "launch", "type": "dart", "flutterMode": "release" },
|
||||
{ "name": "Attach", "request": "attach", "type": "dart" }
|
||||
],
|
||||
"compounds": [{ "name": "Both", "configurations": ["my_app", "my_app (profile mode)"] }]
|
||||
}"#;
|
||||
|
||||
#[test]
|
||||
fn flutter_launches_from_dart_code_next_to_the_detected_configuration() {
|
||||
let dir = project(FLUTTER);
|
||||
let root = dir.path();
|
||||
write(root, "pubspec.yaml", PUBSPEC_FLUTTER);
|
||||
write(root, "lib/main.dart", "void main() {}\n");
|
||||
let r = import_from(root, &ide_run::detect(root));
|
||||
assert_eq!(reason(&r, "my_app"), &SkipReason::SameAs { existing: "flutter run".into() });
|
||||
for (name, mode) in [("my_app (profile mode)", "--profile"), ("my_app (release mode)", "--release")] {
|
||||
let c = get(&r, name);
|
||||
assert_eq!(
|
||||
(c.kind.as_str(), c.command.as_str(), c.debug_adapter.as_deref()),
|
||||
("flutter", "flutter", Some("dart"))
|
||||
);
|
||||
assert_eq!(c.args, s(&["run", "-t", "lib/main.dart", mode]));
|
||||
assert_eq!(cwd(c), None);
|
||||
}
|
||||
assert_eq!(reason(&r, "Attach"), &SkipReason::UnsupportedRequest { request: "attach".into() });
|
||||
// A compound naming the left-out entry starts the detected configuration.
|
||||
assert_eq!(
|
||||
get(&r, "Both").extras.compound,
|
||||
["flutter:run".to_owned(), get(&r, "my_app (profile mode)").id.clone()]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flutter_entry_device_tool_and_app_arguments_in_a_subfolder() {
|
||||
let dir = project(
|
||||
r#"{ "configurations": [
|
||||
{ "name": "Dev", "request": "launch", "type": "dart", "cwd": "${workspaceFolder}/app",
|
||||
"program": "lib/main_dev.dart", "deviceId": "chrome", "args": ["--seed", "1"],
|
||||
"toolArgs": ["--flavor", "dev", "--dart-define=ENV=dev"], "vmAdditionalArgs": ["--x"] },
|
||||
{ "name": "From the root", "request": "launch", "type": "dart", "program": "app/lib/main_dev.dart" }
|
||||
] }"#,
|
||||
);
|
||||
let root = dir.path();
|
||||
write(root, "app/pubspec.yaml", PUBSPEC_FLUTTER);
|
||||
write(root, "app/lib/main_dev.dart", "void main() {}\n");
|
||||
let r = import_from(root, &[]);
|
||||
let c = get(&r, "Dev");
|
||||
assert_eq!(
|
||||
c.args,
|
||||
s(&[
|
||||
"run",
|
||||
"-t",
|
||||
"lib/main_dev.dart",
|
||||
"-d",
|
||||
"chrome",
|
||||
"--flavor",
|
||||
"dev",
|
||||
"--dart-define=ENV=dev",
|
||||
"--dart-entrypoint-args",
|
||||
"--seed",
|
||||
"--dart-entrypoint-args",
|
||||
"1",
|
||||
])
|
||||
);
|
||||
assert_eq!(cwd(c), Some(PathBuf::from("app")));
|
||||
assert_eq!(ignored(&r, "Dev"), ["vmAdditionalArgs"]);
|
||||
// A program path from the workspace folder runs in its package too.
|
||||
let c = get(&r, "From the root");
|
||||
assert_eq!((c.args.clone(), cwd(c)), (s(&["run", "-t", "lib/main_dev.dart"]), Some(PathBuf::from("app"))));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dart_programs_outside_flutter_run_with_dart() {
|
||||
let dir = project(
|
||||
r#"{ "configurations": [
|
||||
{ "name": "Server", "request": "launch", "type": "dart", "program": "bin/server.dart",
|
||||
"args": ["--port", "8080"], "toolArgs": ["--enable-asserts"] },
|
||||
{ "name": "Server (absolute)", "request": "launch", "type": "dart", "program": "${workspaceFolder}/bin/server.dart" },
|
||||
{ "name": "Nothing", "request": "launch", "type": "dart" }
|
||||
] }"#,
|
||||
);
|
||||
let root = dir.path();
|
||||
write(root, "pubspec.yaml", "name: server\n");
|
||||
write(root, "bin/server.dart", "void main() {}\n");
|
||||
let r = import_from(root, &[]);
|
||||
let c = get(&r, "Server");
|
||||
assert_eq!((c.kind.as_str(), c.command.as_str(), c.debug_adapter.as_deref()), ("dart", "dart", Some("dart")));
|
||||
assert_eq!(c.args, s(&["run", "--enable-asserts", "bin/server.dart", "--port", "8080"]));
|
||||
assert_eq!(get(&r, "Server (absolute)").args, s(&["run", "bin/server.dart"]));
|
||||
assert_eq!(reason(&r, "Nothing"), &SkipReason::NothingToRun);
|
||||
}
|
||||
|
||||
@@ -170,8 +170,8 @@ Each launch opens a tab in the **Run** tool window (bottom). The toolbar has **R
|
||||
|
||||
Two actions in Find Action (also linked from the dialog) import existing configurations:
|
||||
|
||||
- **Import Run Configurations from .vscode/launch.json**: Python and Node.js launches and attaches, plus compounds. Fixed variables such as `${workspaceFolder}` and `${env:NAME}` are replaced; entries that use `${file}`, `${input:…}` or `${command:…}` are skipped.
|
||||
- **Import Run Configurations from JetBrains (.run, .idea)**: reads `.run/*.run.xml`, `.idea/runConfigurations/*.xml` and `.idea/workspace.xml`. Python, Django, pytest, npm, Jest, Vitest, Node.js, Shell Script, Application, JAR Application, Spring Boot, Go and compound configurations are converted; other types are skipped.
|
||||
- **Import Run Configurations from .vscode/launch.json**: Python and Node.js launches and attaches, Dart launches (Flutter apps as Flutter configurations), plus compounds. Fixed variables such as `${workspaceFolder}` and `${env:NAME}` are replaced; entries that use `${file}`, `${input:…}` or `${command:…}` are skipped.
|
||||
- **Import Run Configurations from JetBrains (.run, .idea)**: reads `.run/*.run.xml`, `.idea/runConfigurations/*.xml` and `.idea/workspace.xml`. Python, Django, pytest, npm, Jest, Vitest, Node.js, Shell Script, Application, JAR Application, Spring Boot, Go, Flutter and compound configurations are converted; other types are skipped. An entry that runs the same command as an existing configuration, such as the detected `flutter run`, is skipped.
|
||||
|
||||
A notification says how many were imported and why others were left out.
|
||||
|
||||
|
||||
@@ -166,8 +166,8 @@ Maven 模块在 **自动** 和 **构建(Make)** 时由 jdtls(ECJ)构建
|
||||
|
||||
“查找操作”里有两个导入操作(对话框里也有入口):
|
||||
|
||||
- **从 .vscode/launch.json 导入运行配置**:导入 Python 和 Node.js 的 launch / attach 配置以及 compounds。`${workspaceFolder}`、`${env:NAME}` 这类含义固定的变量会被替换;用到 `${file}`、`${input:…}`、`${command:…}` 的条目会被跳过。
|
||||
- **从 JetBrains 导入运行配置(.run、.idea)**:读取 `.run/*.run.xml`、`.idea/runConfigurations/*.xml` 和 `.idea/workspace.xml`。Python、Django、pytest、npm、Jest、Vitest、Node.js、Shell Script、Application、JAR Application、Spring Boot、Go 和复合配置会被转换,其他类型跳过。
|
||||
- **从 .vscode/launch.json 导入运行配置**:导入 Python 和 Node.js 的 launch / attach 配置、Dart 的 launch 配置(Flutter 应用导入为 Flutter 配置)以及 compounds。`${workspaceFolder}`、`${env:NAME}` 这类含义固定的变量会被替换;用到 `${file}`、`${input:…}`、`${command:…}` 的条目会被跳过。
|
||||
- **从 JetBrains 导入运行配置(.run、.idea)**:读取 `.run/*.run.xml`、`.idea/runConfigurations/*.xml` 和 `.idea/workspace.xml`。Python、Django、pytest、npm、Jest、Vitest、Node.js、Shell Script、Application、JAR Application、Spring Boot、Go、Flutter 和复合配置会被转换,其他类型跳过。和已有配置(例如自动检测出的 `flutter run`)命令相同的条目会被跳过。
|
||||
|
||||
导入完成后会有通知告诉你导入了多少、哪些被跳过以及原因。
|
||||
|
||||
|
||||
@@ -11121,6 +11121,8 @@ export type SizeSource =
|
||||
export type SkipReason =
|
||||
/** A configuration with this name already exists. */
|
||||
{ kind: "nameTaken" } |
|
||||
/** An existing configuration (a detected one, say) runs the same command. */
|
||||
{ kind: "sameAs"; existing: string } |
|
||||
/** The configuration type has no equivalent here: a VS Code debugger (`cppdbg`), a JetBrains type (`Application`). */
|
||||
{ kind: "unsupportedType"; type: string } |
|
||||
/** A `request` other than `launch` and `attach`. */
|
||||
|
||||
@@ -46,6 +46,8 @@ export function skipReasonText(reason: SkipReason): string {
|
||||
switch (reason.kind) {
|
||||
case "nameTaken":
|
||||
return tx("A configuration with this name already exists");
|
||||
case "sameAs":
|
||||
return tx`Same as the existing configuration '${reason.existing}'`;
|
||||
case "unsupportedType":
|
||||
return tx`Type '${reason.type}' has no equivalent here`;
|
||||
case "unsupportedRequest":
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{
|
||||
"Same as the existing configuration '{existing}'": "Same as the existing configuration '{existing}'",
|
||||
"Windows file and folder names cannot end with a period or space": "Windows file and folder names cannot end with a period or space",
|
||||
"Use URL template": "Use URL template",
|
||||
"Use Driver": "Use Driver",
|
||||
|
||||
@@ -3747,6 +3747,7 @@
|
||||
"Left out of '{name}': {keys}": "'{name}' 中未导入的设置:{keys}",
|
||||
"Click OK or Apply to save them.": "点击“确定”或“应用”以保存。",
|
||||
"A configuration with this name already exists": "已存在同名配置",
|
||||
"Same as the existing configuration '{existing}'": "与已有配置 '{existing}' 相同",
|
||||
"Type '{type}' has no equivalent here": "此处没有与类型 '{type}' 对应的配置",
|
||||
"Request '{request}' isn't supported": "不支持请求 '{request}'",
|
||||
"Only attaching to a host and port is supported": "仅支持附加到主机和端口",
|
||||
|
||||
Reference in New Issue
Block a user