diff --git a/desktop/internal/i18n/shared.generated.go b/desktop/internal/i18n/shared.generated.go index 5895784881..c8ba27bc0f 100644 --- a/desktop/internal/i18n/shared.generated.go +++ b/desktop/internal/i18n/shared.generated.go @@ -1778,12 +1778,15 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.title.cloneLater": "Cloning repositories comes later", "desktop.title.configurationNotStartable": "{name} cannot be started: no build plugin runs it.", "desktop.title.currentFileNotRunnable": "The current file cannot run on its own. Choose a project run configuration from the run configuration menu.", + "desktop.title.hiddenRunConfigurations": "{count} saved configurations hidden (not runnable)", "desktop.title.keymapLater": "The keymap page comes later", "desktop.title.logsUnavailable": "The log could not be opened when Lithe started", "desktop.title.newProjectLater": "Creating projects comes later", "desktop.title.noRecentProjects": "No recent projects", "desktop.title.noRunConfigurations": "No run configurations", "desktop.title.notDebuggable": "{name} cannot be debugged: its plugin declares no debug adapter for this run.", + "desktop.title.nothingToEdit": "This project has no run configurations to edit. Build plugins create them from the project model, and none of the enabled build plugins declares a runnable entry for this project.", + "desktop.title.nothingToEditHidden": "This project has no run configurations to edit. Build plugins create them from the project model, and none of the enabled build plugins declares a runnable entry for this project. {count} saved run configurations are hidden because no build plugin runs them, for example entries an earlier version of Lithe saved in .lithe/run.", "desktop.title.pluginsLater": "The plugins page comes later", "desktop.title.projectMenu": "Project menu", "desktop.title.runBusy": "The Run window is still running another operation. Wait for it to finish or stop it first.", @@ -4592,12 +4595,15 @@ var sharedCatalogs = map[string]map[string]string{ "desktop.title.cloneLater": "克隆仓库稍后提供", "desktop.title.configurationNotStartable": "无法启动 {name}:没有构建插件负责运行它。", "desktop.title.currentFileNotRunnable": "当前文件不能单独运行。请在运行配置菜单里选择一个项目运行配置。", + "desktop.title.hiddenRunConfigurations": "已隐藏 {count} 条无法运行的已保存配置", "desktop.title.keymapLater": "快捷键页稍后提供", "desktop.title.logsUnavailable": "Lithe 启动时未能打开日志", "desktop.title.newProjectLater": "新建项目稍后提供", "desktop.title.noRecentProjects": "无最近项目", "desktop.title.noRunConfigurations": "没有运行配置", "desktop.title.notDebuggable": "无法调试 {name}:它所属的插件没有为这个运行声明调试适配器。", + "desktop.title.nothingToEdit": "这个项目没有可编辑的运行配置。运行配置由构建插件根据项目模型生成,当前启用的构建插件没有为这个项目声明可运行的入口。", + "desktop.title.nothingToEditHidden": "这个项目没有可编辑的运行配置。运行配置由构建插件根据项目模型生成,当前启用的构建插件没有为这个项目声明可运行的入口。另有 {count} 条保存的运行配置没有构建插件负责运行,已隐藏,例如旧版 Lithe 保存在 .lithe/run 中的配置。", "desktop.title.pluginsLater": "插件页稍后提供", "desktop.title.projectMenu": "项目菜单", "desktop.title.runBusy": "运行窗口还在执行其他操作。请等它结束,或者先停止它。", diff --git a/desktop/internal/pluginservice/builds.go b/desktop/internal/pluginservice/builds.go index e6dfe67258..194942201f 100644 --- a/desktop/internal/pluginservice/builds.go +++ b/desktop/internal/pluginservice/builds.go @@ -27,8 +27,10 @@ type BuildPlugin struct { type BuildSystemDeclaration struct { ID string DisplayName string - // Provider is true when this system answers model and task requests through - // a plugin process instead of a command line. + // Provider is true when this system declares a plugin process. Each request still names + // its own source: a provider system may read its model or dependencies with a command, so + // the model's source (BuildInstance.ModelSource) and Dependencies.Source decide how a + // request runs, not this. Provider bool Tasks []BuildTaskDeclaration Runs []BuildRunDeclaration @@ -46,6 +48,9 @@ type BuildSystemDeclaration struct { // (plugin.build.invalidSelection), so the window offers the tree only where it is declared. type BuildDependenciesDeclaration struct { Scopes []string + // Source is "command" or "provider": where the tree comes from. A system with a provider + // process may still read its tree with a command, so this, not Provider, picks the path. + Source string } // BuildTestDeclaration is one build system's declared test entry. @@ -78,9 +83,30 @@ type BuildTaskDeclaration struct { Source string } +// EntryName is the run configuration of the run on target: the run's declared name before the +// target's, or the target's name alone when the run declares none, as the contract's run.name +// says. +func (r BuildRunDeclaration) EntryName(target string) string { + if r.Name == "" { + return target + } + return r.Name + " " + target +} + +// ActionName is what a menu entry that runs the run on target says: the run's declared name, or +// the target's name when the run declares none. +func (r BuildRunDeclaration) ActionName(target string) string { + if r.Name == "" { + return target + } + return r.Name +} + // BuildRunDeclaration is one provider-owned application, service, or task run. type BuildRunDeclaration struct { - ID string + ID string + // Name is the entry name the run declares, empty when it declares none: the contract then + // names each entry after its target (EntryName, ActionName). Name string Execution string Tags []string @@ -160,6 +186,7 @@ type rawBuildManifest struct { } `json:"test"` Dependencies *struct { Scopes []string `json:"scopes"` + Source string `json:"source"` } `json:"dependencies"` } `json:"buildSystems"` } @@ -200,13 +227,9 @@ func parseBuildSystems(manifest json.RawMessage) (map[string]BuildSystemDeclarat if run.ID == "" || run.Source != "provider" || run.FromTargets == nil { continue } - name := run.Name - if name == "" { - name = run.ID - } declaration := BuildRunDeclaration{ ID: run.ID, - Name: name, + Name: run.Name, Execution: run.Execution, Tags: append([]string(nil), run.FromTargets.Tags...), } @@ -224,7 +247,7 @@ func parseBuildSystems(manifest json.RawMessage) (map[string]BuildSystemDeclarat } } if deps := raw.Dependencies; deps != nil && len(deps.Scopes) > 0 { - system.Dependencies = &BuildDependenciesDeclaration{Scopes: append([]string(nil), deps.Scopes...)} + system.Dependencies = &BuildDependenciesDeclaration{Scopes: append([]string(nil), deps.Scopes...), Source: deps.Source} } systems[raw.ID] = system } diff --git a/desktop/internal/pluginservice/builds_test.go b/desktop/internal/pluginservice/builds_test.go index 4acac699b8..48641456d6 100644 --- a/desktop/internal/pluginservice/builds_test.go +++ b/desktop/internal/pluginservice/builds_test.go @@ -159,7 +159,7 @@ func TestParseBuildSystemsKeepsTaskPresentationAndDependencyScopes(t *testing.T) if goModules.Provider { t.Fatal("a command model reads as a provider") } - if goModules.Dependencies == nil || len(goModules.Dependencies.Scopes) != 1 || goModules.Dependencies.Scopes[0] != "project" { + if goModules.Dependencies == nil || len(goModules.Dependencies.Scopes) != 1 || goModules.Dependencies.Scopes[0] != "project" || goModules.Dependencies.Source != "command" { t.Fatalf("dependencies = %+v", goModules.Dependencies) } if len(goModules.Tasks) != 2 { @@ -179,3 +179,36 @@ func TestParseBuildSystemsKeepsTaskPresentationAndDependencyScopes(t *testing.T) t.Fatal("a system without dependencies offers them") } } + +// A provider system may read its model and dependencies with commands and use its provider only +// for runs; the dependency declaration keeps its own source. A run +// without a name is called after its target, as the contract's run.name says, not after its ID. +func TestParseBuildSystemsKeepsDependencySourceAndUnnamedRuns(t *testing.T) { + systems, err := parseBuildSystems(json.RawMessage(`{"buildSystems": [{ + "id": "engine", + "provider": {"launch": {"kind": "packaged", "path": "provider"}}, + "model": {"source": "command"}, + "dependencies": {"source": "command", "scopes": ["workspace", "project"], "arguments": [], "output": "outputFile"}, + "run": [ + {"id": "service", "source": "provider", "fromTargets": {"tags": ["service"]}, "execution": "service"}, + {"id": "tool", "name": "Tool", "source": "provider", "fromTargets": {"tags": ["tool"]}, "execution": "application"} + ] + }]}`)) + if err != nil { + t.Fatal(err) + } + engine := systems["engine"] + if !engine.Provider || engine.Dependencies == nil || engine.Dependencies.Source != "command" { + t.Fatalf("system = %+v, dependencies = %+v", engine, engine.Dependencies) + } + if len(engine.Runs) != 2 { + t.Fatalf("runs = %+v", engine.Runs) + } + unnamed, named := engine.Runs[0], engine.Runs[1] + if unnamed.Name != "" || unnamed.EntryName("ServerMain") != "ServerMain" || unnamed.ActionName("ServerMain") != "ServerMain" { + t.Fatalf("the unnamed run is %+v, entry %q, action %q", unnamed, unnamed.EntryName("ServerMain"), unnamed.ActionName("ServerMain")) + } + if named.EntryName("Main") != "Tool Main" || named.ActionName("Main") != "Tool" { + t.Fatalf("the named run's entry %q, action %q", named.EntryName("Main"), named.ActionName("Main")) + } +} diff --git a/desktop/internal/workbench/build.go b/desktop/internal/workbench/build.go index 15d828f2b2..4023d9b503 100644 --- a/desktop/internal/workbench/build.go +++ b/desktop/internal/workbench/build.go @@ -611,14 +611,7 @@ func (a *App) loadBuildModelWith(p *project, index int, refresh bool) { a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { ctx, cancel := feed.bind(ctx) defer cancel() - var model core.BuildModel - var err error - // Core names where the model comes from; a static model arrived with detection. - if captured.ModelSource == "command" { - model, err = a.commandModel(ctx, p, captured, kernel, feed, a.text.Build) - } else { - model, err = a.providerModel(ctx, p, captured, kernel, feed, refresh) - } + model, err := a.buildModel(ctx, p, captured, kernel, feed, a.text.Build, refresh) if err != nil && feed.stopRequested() { err = errBuildModelStopped } @@ -643,6 +636,17 @@ func (a *App) reloadBuildModel(p *project, index int) { a.loadBuildModelWith(p, index, true) } +// buildModel loads instance's model from the source Core named for it at detection: a command +// the host runs, or the plugin's provider process. A system that declares a provider process may +// still read its model with a command, so the model's source decides, not the provider. resolved, +// when given, is the build executable the caller already resolved. +func (a *App) buildModel(ctx context.Context, p *project, instance buildInstance, kernel Kernel, feed *buildSyncFeed, messages i18n.BuildMessages, refresh bool, resolved ...buildExecution) (core.BuildModel, error) { + if instance.ModelSource == "command" { + return a.commandModel(ctx, p, instance, kernel, feed, messages, resolved...) + } + return a.providerModel(ctx, p, instance, kernel, feed, refresh, resolved...) +} + // commandModel runs a command-sourced model plan and decodes its output. The // output file, when the plan uses one, is host-allocated under the plugin's // writable state and removed after decoding. No plugin process runs the command, so the @@ -1123,6 +1127,22 @@ func (a *App) runCommandTask(ctx, prepare context.Context, p *project, op *build return nil } +// addBuildToolHint gives a provider's run or debug preparation the build executable the host +// resolves for instance, as dependency and test requests already carry it, so a provider that +// builds with the user's tool (a Maven wrapper, the configured executable) uses the same one. +// The hint is optional in the contract: when nothing resolves, the request goes without it, the +// provider reports what it misses, and the reason is logged here. +func (a *App) addBuildToolHint(ctx context.Context, p *project, instance buildInstance, request *core.BuildPlanRequest) { + execution, err := a.resolveBuildExecutable(ctx, p, instance, a.text.Build) + if err != nil { + a.backgroundFailedIn(ctx, "build_run_tool", err) + return + } + if execution.Executable != "" { + request.Tool = &core.BuildTool{Executable: execution.Executable, Environment: execution.Environment} + } +} + // resolveBuildExecutable asks Core for the ordered candidates, checks them in // that order, and probes the declared minimum version. It never falls back to // a guessed tool name. @@ -1464,6 +1484,7 @@ func (a *App) debugProviderTarget(p *project, index int, projectID, targetID, ru return } a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { + a.addBuildToolHint(ctx, p, captured, &request) plan, err := kernel.PlanBuildDebug(ctx, captured.Manifest, captured.BuildSystemID, request) if err != nil { return fail(err) @@ -1581,7 +1602,7 @@ func (a *App) runBuildTargetWith(p *project, op *buildOperation, instance *build a.background(p, buildRequestTimeout, func(ctx context.Context) func(*App) { prepare, release := op.bind(ctx) defer release() - plan, err := kernel.PlanBuildRun(prepare, captured.Manifest, captured.BuildSystemID, core.BuildPlanRequest{ + request := core.BuildPlanRequest{ Root: captured.Root, Options: captured.Options, WorkspaceRoot: p.root, @@ -1589,7 +1610,9 @@ func (a *App) runBuildTargetWith(p *project, op *buildOperation, instance *build Project: &core.BuildSelection{Name: project.Name, Path: project.Path, Properties: project.Properties}, Target: &core.BuildSelection{Name: target.Name, Path: target.Path, Tags: target.Tags, Properties: target.Properties}, LaunchOptions: options, - }) + } + a.addBuildToolHint(prepare, p, captured, &request) + plan, err := kernel.PlanBuildRun(prepare, captured.Manifest, captured.BuildSystemID, request) if err != nil { return func(a *App) { a.finishBuildError(p, op, err) } } @@ -1605,7 +1628,9 @@ func (a *App) runBuildTargetWith(p *project, op *buildOperation, instance *build return func(a *App) { a.finishBuildError(p, op, err) } } a.post(func(a *App) { a.attachRequest(p, op, client, operation, false) }) - result, err := operation.Wait(prepare) + // The provider builds before it answers; what it prints meanwhile, such as a compile + // error, is the run's console output, which the user reads when the preparation fails. + result, _, err := a.awaitProviderOperation(prepare, p, op, operation) if err != nil { return func(a *App) { a.finishBuildError(p, op, err) } } @@ -1690,15 +1715,35 @@ func (a *App) runProviderOperation(ctx, prepare context.Context, p *project, op return } a.post(func(a *App) { a.attachRequest(p, op, client, operation, true) }) - sawProgress := false + result, sawProgress, err := a.awaitProviderOperation(ctx, p, op, operation) + if err != nil { + a.post(func(a *App) { a.finishBuildError(p, op, err) }) + return + } + if !sawProgress { + var execution struct { + Output string `json:"output"` + } + if json.Unmarshal(result, &execution) == nil && execution.Output != "" { + a.streamBuildOutput(p, op, execution.Output) + } + } + a.post(func(a *App) { a.finishBuildTask(p, op, result) }) +} + +// awaitProviderOperation waits for the provider's answer to operation and meanwhile shows its +// progress as op's: output in op's console, messages as the window's status. sawOutput says +// whether any progress carried output. It runs off the window thread. +func (a *App) awaitProviderOperation(ctx context.Context, p *project, op *buildOperation, operation *buildprovider.Operation) (result json.RawMessage, sawOutput bool, err error) { for { select { case progress, ok := <-operation.Progress(): if !ok { - goto done + result, err = operation.Wait(ctx) + return result, sawOutput, err } if progress.Output != "" { - sawProgress = true + sawOutput = true a.streamBuildOutput(p, op, progress.Output) } if progress.Message != "" { @@ -1709,25 +1754,9 @@ func (a *App) runProviderOperation(ctx, prepare context.Context, p *project, op }) } case <-ctx.Done(): - a.post(func(a *App) { a.finishBuildError(p, op, ctx.Err()) }) - return + return nil, sawOutput, ctx.Err() } } -done: - result, err := operation.Wait(ctx) - if err != nil { - a.post(func(a *App) { a.finishBuildError(p, op, err) }) - return - } - if !sawProgress { - var execution struct { - Output string `json:"output"` - } - if json.Unmarshal(result, &execution) == nil && execution.Output != "" { - a.streamBuildOutput(p, op, execution.Output) - } - } - a.post(func(a *App) { a.finishBuildTask(p, op, result) }) } // endBuildOperation clears op as the window's operation, records how it ended in its session and diff --git a/desktop/internal/workbench/build_command_record_test.go b/desktop/internal/workbench/build_command_record_test.go index d13bcb07f6..2f6444aba6 100644 --- a/desktop/internal/workbench/build_command_record_test.go +++ b/desktop/internal/workbench/build_command_record_test.go @@ -4,10 +4,12 @@ import ( "context" "encoding/json" "errors" + "flag" "fmt" "os" "path/filepath" "runtime" + "strings" "testing" "time" @@ -54,6 +56,49 @@ const buildCommandManifest = `{ }] }` +// buildCommandProviderManifest is a build system that declares a provider process and still +// reads its model and its dependency tree with commands: its provider only prepares runs. The dependency command writes its tree to the file the host allocates. +const buildCommandProviderManifest = `{ + "schemaVersion": 0, + "id": "dev.lithe.test.build-command", + "displayName": "Build Command Fixture", + "version": "1.0.0", + "pluginAPIVersion": 0, + "requires": {"buildSystems": 0, "buildProviders": 0}, + "vendor": {"id": "dev.lithe.test", "displayName": "Test", "signatureRequirement": "publisherPackage"}, + "permissions": ["languageServer.launch", "process.build"], + "activationEvents": ["onBuildSystem:fixture"], + "languages": [], + "buildSystems": [{ + "id": "fixture", + "displayName": "Fixture", + "detection": {"markers": ["build.fixture"]}, + "invocation": {"executables": [{"kind": "command", "command": "fixture-build"}]}, + "provider": { + "launch": {"kind": "packaged", "path": "provider"}, + "executesProjectCode": false, + "mayUseNetwork": false + }, + "model": { + "source": "command", + "arguments": ["-test.run=^TestBuildCommandRunner$"], + "decoder": "litheBuildModel", + "executesProjectCode": false, + "mayUseNetwork": false + }, + "dependencies": { + "source": "command", + "scopes": ["workspace"], + "arguments": ["-test.run=^TestBuildCommandRunner$", "--", "${outputFile}"], + "output": "outputFile", + "decoder": "litheDependencies", + "executesProjectCode": false, + "mayUseNetwork": false + }, + "run": [{"id": "application", "source": "provider", "fromTargets": {"tags": ["app"]}, "execution": "application"}] + }] +}` + // buildCommandMarker names the file in the command's working directory that tells the runner // what to do: print a model or a tree, exit with a failure, print what is no document, log a // download before the model or before it hangs, or hang. @@ -74,6 +119,17 @@ func TestBuildCommandRunner(t *testing.T) { fmt.Print(`{"format":"litheBuildModel","version":0,"projects":[{"name":"fixture"}]}`) case "dependencies": fmt.Print(`{"format":"litheDependencies","version":0,"dependencies":[{"name":"fixture-dependency","children":[]}]}`) + case "dependencies-file": + // The tree goes to the output file named after "--", and stdout stays free for the log. + arguments := flag.Args() + if len(arguments) == 0 { + os.Exit(4) + } + fmt.Print("[INFO] writing the dependency tree\n") + tree := `{"format":"litheDependencies","version":0,"dependencies":[{"name":"fixture-dependency","children":[]}]}` + if err := os.WriteFile(arguments[len(arguments)-1], []byte(tree), 0o600); err != nil { + os.Exit(5) + } case "fail": os.Exit(3) case "explain": @@ -154,7 +210,10 @@ func buildCommandInstance(root string, provider bool) buildInstance { PluginID: buildCommandPluginID, Version: "1.0.0", Manifest: json.RawMessage(buildCommandManifest), - System: pluginservice.BuildSystemDeclaration{Provider: provider}, + System: pluginservice.BuildSystemDeclaration{ + Provider: provider, + Dependencies: &pluginservice.BuildDependenciesDeclaration{Scopes: []string{"workspace"}, Source: "command"}, + }, } } @@ -270,18 +329,63 @@ func TestBuildCommandDependencyLoadIsRecordedAtTheStageItEnded(t *testing.T) { } } -// A provider system that fails before its plan names a command never ran a command, and what -// its provider does is the plugin's own to log. +// A provider-sourced dependency request that fails before its plan never ran a command, and +// what its provider does is the plugin's own to log. func TestBuildProviderSystemFailingBeforeItsPlanIsNotRecorded(t *testing.T) { h, plugins, p := buildCommandHarness(t) kernel := h.app.kernel.(buildDependencyKernel) ctx := buildLoadContext(t, "action-52", pluginOperationWait) - if _, err := h.app.buildDependencyTree(ctx, p, buildCommandInstance(".", true), kernel, nil, false); err == nil { + instance := buildCommandInstance(".", true) + instance.System.Dependencies.Source = "provider" + if _, err := h.app.buildDependencyTree(ctx, p, instance, kernel, nil, false); err == nil { t.Fatal("a provider system without its build tool loaded a tree") } plugins.none(t) } +// A system with a provider process may still read its tree with a command that writes to a +// file. The declaration's source, not the provider process, decides: +// the host allocates the output file and runs the command itself, where it used to send the +// plan request without the file, which Core refused with "pass outputFile". +func TestBuildProviderSystemReadsItsTreeWithAFileCommand(t *testing.T) { + h, plugins, p := buildCommandHarness(t) + installBuildTool(t) + kernel := h.app.kernel.(buildDependencyKernel) + writeBuildCommandMarker(t, p.root, "dependencies-file") + instance := buildCommandInstance(".", true) + instance.Manifest = json.RawMessage(buildCommandProviderManifest) + tree, err := h.app.buildDependencyTree(buildLoadContext(t, "action-53", pluginOperationWait), p, instance, kernel, nil, false) + if err != nil { + t.Fatalf("the provider system's file command failed: %v", err) + } + if len(tree.Dependencies) != 1 || tree.Dependencies[0].Name != "fixture-dependency" { + t.Fatalf("tree = %+v, want the fixture dependency from the output file", tree) + } + wantPluginOperation(t, plugins.next(t, "file command"), core.PluginOperation{PluginID: buildCommandPluginID, Operation: core.OperationBuildDependencies, Outcome: "finished", OperationID: "action-53"}) + plugins.none(t) +} + +// The model of a system that declares a provider process but reads its model with a command +// comes from the command: the Build window and the settings source editor both load it through +// buildModel, which follows the model's source. The settings editor used to ask the provider +// process, which serves no model, so a source settings page could not read the plugin's modules. +func TestBuildProviderSystemReadsItsModelWithItsCommand(t *testing.T) { + h, plugins, p := buildCommandHarness(t) + installBuildTool(t) + writeBuildCommandMarker(t, p.root, "model") + instance := buildCommandInstance(".", true) + instance.Manifest = json.RawMessage(buildCommandProviderManifest) + model, err := h.app.buildModel(buildLoadContext(t, "action-54", pluginOperationWait), p, instance, h.app.kernel, nil, h.app.text.Build, false) + if err != nil { + t.Fatalf("the provider system's model command failed: %v", err) + } + if len(model.Projects) != 1 || model.Projects[0].Name != "fixture" { + t.Fatalf("model = %+v, want the command's project", model) + } + wantPluginOperation(t, plugins.next(t, "model command"), core.PluginOperation{PluginID: buildCommandPluginID, Operation: core.OperationBuildModel, Outcome: "finished", OperationID: "action-54"}) + plugins.none(t) +} + func TestBuildCommandStage(t *testing.T) { launch := &buildLaunchError{cause: errors.New("buildprocess: start fixture-build: no such directory")} for _, tc := range []struct { @@ -302,3 +406,23 @@ func TestBuildCommandStage(t *testing.T) { t.Fatalf("a start failure changed its text or cause: %q", launch.Error()) } } + +// Run and debug preparation carry the build executable the host resolves, as dependency and +// test requests do, so a provider that builds before launching uses the user's tool; without +// one the request goes out without the hint and the provider says what it misses. +func TestBuildRunPreparationCarriesTheResolvedTool(t *testing.T) { + h, _, p := buildCommandHarness(t) + withoutTool := installBuildTool(t) + ctx := buildLoadContext(t, "action-61", pluginOperationWait) + var request core.BuildPlanRequest + h.app.addBuildToolHint(ctx, p, buildCommandInstance(".", true), &request) + if request.Tool == nil || !strings.HasPrefix(filepath.Base(request.Tool.Executable), "fixture-build") { + t.Fatalf("tool = %+v, want the fixture build tool", request.Tool) + } + t.Setenv("PATH", withoutTool) + request = core.BuildPlanRequest{} + h.app.addBuildToolHint(ctx, p, buildCommandInstance(".", true), &request) + if request.Tool != nil { + t.Fatalf("tool = %+v without a build tool on PATH", request.Tool) + } +} diff --git a/desktop/internal/workbench/build_dependencies.go b/desktop/internal/workbench/build_dependencies.go index 7cdc6f4bf9..a0f3608ab3 100644 --- a/desktop/internal/workbench/build_dependencies.go +++ b/desktop/internal/workbench/build_dependencies.go @@ -104,10 +104,10 @@ func (a *App) loadBuildDependencies(p *project, instance *buildInstance, project }) } -// buildDependencyTree plans, runs and decodes one dependency request. A command plan has no -// plugin process to log it, so the host records it as the plugin's lithe/build/dependencies -// operation, at the stages buildCommandStage describes; a provider request is the plugin's own -// to log, and so is a provider system's failure before its plan says it is a command. +// buildDependencyTree plans, runs and decodes one dependency request, by the source the +// dependency declaration names. A command plan has no plugin process to log it, so the host +// records it as the plugin's lithe/build/dependencies operation, at the stages +// buildCommandStage describes; a provider request is the plugin's own to log. func (a *App) buildDependencyTree(ctx context.Context, p *project, instance buildInstance, kernel buildDependencyKernel, selection *core.BuildSelection, refresh bool) (core.BuildDependencyTree, error) { attempt := core.StartPluginAttempt(instance.PluginID, core.OperationBuildDependencies, core.OriginOf(ctx).Operation) defer attempt.Abandon() @@ -115,9 +115,12 @@ func (a *App) buildDependencyTree(ctx context.Context, p *project, instance buil a.plugins.EndAttempt(ctx, attempt, stage, err) return core.BuildDependencyTree{}, err } + // The declaration's source decides: a system with a provider process may still read its + // tree with a command, which needs the host's output file and the host's operation record. + provider := instance.System.Dependencies != nil && instance.System.Dependencies.Source == "provider" execution, err := a.resolveBuildExecutable(ctx, p, instance, a.text.Build) if err != nil { - if instance.System.Provider { + if provider { return core.BuildDependencyTree{}, err } return fail(core.StageResolve, err) @@ -128,7 +131,7 @@ func (a *App) buildDependencyTree(ctx context.Context, p *project, instance buil if selection != nil { decode.Project = selection.Path } - if instance.System.Provider { + if provider { if execution.Executable != "" { request.Tool = &core.BuildTool{Executable: execution.Executable, Environment: execution.Environment} } @@ -138,7 +141,7 @@ func (a *App) buildDependencyTree(ctx context.Context, p *project, instance buil return core.BuildDependencyTree{}, err } if plan.Provider == nil { - return a.commandDependencies(ctx, p, instance, kernel, attempt, plan, execution, decode, "") + return core.BuildDependencyTree{}, errors.New("the build system answered with a command plan") } client, err := a.buildProvider(ctx, p, instance) if err != nil { diff --git a/desktop/internal/workbench/build_menus.go b/desktop/internal/workbench/build_menus.go index 1fe5c1055a..8314171dbb 100644 --- a/desktop/internal/workbench/build_menus.go +++ b/desktop/internal/workbench/build_menus.go @@ -49,7 +49,7 @@ func (a *App) buildRowMenu(c ui.C, row ui.Box, p *project, instance *buildInstan continue } runID := run.ID - if menu.Item(a.text.Build.RunTarget(run.Name)).Disabled(b.operation != nil || instance.modelLoading).Clicked() { + if menu.Item(a.text.Build.RunTarget(run.ActionName(spec.target.Name))).Disabled(b.operation != nil || instance.modelLoading).Clicked() { c.After(func() { a.performed("build.target.run", surfaceContextMenu) choose() diff --git a/desktop/internal/workbench/build_tree.go b/desktop/internal/workbench/build_tree.go index 6c72d6258f..643e9d6b6c 100644 --- a/desktop/internal/workbench/build_tree.go +++ b/desktop/internal/workbench/build_tree.go @@ -516,7 +516,7 @@ func buildPrimaryAction(instance *buildInstance, target *core.BuildTarget) (buil } for _, run := range instance.System.Runs { if buildRunApplies(run, *target) { - return buildTargetAction{runID: run.ID, name: run.Name, debug: run.DebugAdapter != ""}, true + return buildTargetAction{runID: run.ID, name: run.ActionName(target.Name), debug: run.DebugAdapter != ""}, true } } if entries := buildTargetRunEntries(instance, target.ID); len(entries) != 0 { diff --git a/desktop/internal/workbench/runconfig.go b/desktop/internal/workbench/runconfig.go index f92ce5e5e7..68fc6c8f7f 100644 --- a/desktop/internal/workbench/runconfig.go +++ b/desktop/internal/workbench/runconfig.go @@ -21,6 +21,11 @@ type runConfigState struct { list []core.RunConfiguration selected string failure string + // hidden counts the saved configurations left out of list because no build plugin starts + // them, so an empty list can say so: user entries of another provider, and saved entries + // Core reports as orphaned because they no longer match a generated configuration, such as + // the java.main entries an earlier version generated. + hidden int // editor is the dialog that edits one configuration's saved options. editor runConfigEditor // browser is the list that shows the configurations by scope and build system. @@ -67,13 +72,9 @@ func providerRuns(instances []buildInstance) ([]core.RunProviderRun, bool) { if !buildRunApplies(run, target) { continue } - name := target.Name - if run.Name != "" { - name = run.Name + " " + target.Name - } runs = append(runs, core.RunProviderRun{ ProjectPath: path.Clean(path.Join(instance.Root, project.Path)), - Name: name, + Name: run.EntryName(target.Name), Reference: core.RunProviderReference{ PluginID: instance.PluginID, BuildSystemID: instance.BuildSystemID, Root: instance.Root, Run: run.ID, ProjectID: project.ID, TargetID: target.ID, Execution: run.Execution, UserArguments: []string{}, @@ -132,8 +133,17 @@ func (a *App) finishRunConfigurations(p *project, generation uint64, resolved co s.failure = "" // Only build provider runs can start here; the host has no launcher for the other // providers Core detects. + s.hidden = 0 + for _, diagnostic := range resolved.Diagnostics { + if diagnostic.Code == "orphanedOverride" { + s.hidden++ + } + } s.list = slices.DeleteFunc(resolved.Configurations, func(c core.RunConfiguration) bool { _, ok := c.BuildReference() + if !ok && !c.Disabled { + s.hidden++ + } return !ok || c.Disabled }) if s.configuration(s.selected) == nil { diff --git a/desktop/internal/workbench/settings_plugin_sources.go b/desktop/internal/workbench/settings_plugin_sources.go index 66c5ee2770..68d71d0252 100644 --- a/desktop/internal/workbench/settings_plugin_sources.go +++ b/desktop/internal/workbench/settings_plugin_sources.go @@ -219,12 +219,7 @@ func (s pluginSettingsSources) sourceSettingsContext(ctx context.Context, editor if err != nil { return result, err } - var model core.BuildModel - if instance.System.Provider { - model, err = s.app.providerModel(ctx, current.project, instance, s.app.kernel, nil, refresh, execution) - } else { - model, err = s.app.commandModel(ctx, current.project, instance, s.app.kernel, nil, current.messages, execution) - } + model, err := s.app.buildModel(ctx, current.project, instance, s.app.kernel, nil, current.messages, refresh, execution) if err != nil { return result, err } diff --git a/desktop/internal/workbench/tests_provider_test.go b/desktop/internal/workbench/tests_provider_test.go index bea0e14441..ca2a4f9858 100644 --- a/desktop/internal/workbench/tests_provider_test.go +++ b/desktop/internal/workbench/tests_provider_test.go @@ -7,6 +7,7 @@ import ( "io" "os" "path/filepath" + "runtime" "strconv" "strings" "testing" @@ -217,6 +218,15 @@ func TestProviderTestRunner(t *testing.T) { }, }, }) + case "lithe/build/prepareRun": + // A provider builds before it answers: it streams the build's output, here the + // compile error that makes the preparation fail. + notify("lithe/build/progress", map[string]any{ + "operationID": request.ID, + "message": "compiling libapp", + "output": "[ERROR] lib/App.java:[3,1] class, interface, enum, or record expected\n", + }) + fail(request.ID, -32603, "The build failed.") case "shutdown": reply(request.ID, nil) case "exit": @@ -390,3 +400,68 @@ func TestTestsPanelProviderCloseProjectStops(t *testing.T) { t.Fatal("closing the project left the provider run marked running") } } + +// providerRunManifest is the provider fixture with an application run of the targets tagged app. +var providerRunManifest = strings.Replace(providerTestsManifest, `"model": {"source": "provider"},`, + `"model": {"source": "provider"}, + "run": [{"id": "application", "source": "provider", "fromTargets": {"tags": ["app"]}, "execution": "application"}],`, 1) + +// What a provider prints while it prepares a run, such as the compile error that ends the +// preparation, is the run's console output: the user reads it there when the run fails. The +// host used to wait for the answer without reading the progress, so the console stayed empty. +func TestProviderRunPreparationShowsItsBuildOutput(t *testing.T) { + h := providerTestsHarnessWith(t, providerRunManifest) + root := t.TempDir() + for _, marker := range []string{"fixture.marker", "discovery.marker"} { + if err := os.WriteFile(filepath.Join(root, marker), []byte("fixture\n"), 0o600); err != nil { + t.Fatal(err) + } + } + if err := os.MkdirAll(filepath.Join(root, "lib"), 0o700); err != nil { + t.Fatal(err) + } + // The host resolves the provider's build tool before it starts the provider; the fixture + // provider never runs it. + bin := t.TempDir() + tool := filepath.Join(bin, "fixture-tool") + if runtime.GOOS == "windows" { + tool += ".exe" + t.Setenv("PATHEXT", ".EXE") + } + if err := writeFakeExecutable(tool); err != nil { + t.Fatal(err) + } + t.Setenv("PATH", bin+string(filepath.ListSeparator)+os.Getenv("PATH")) + h.open(root) + p := h.app.project + h.app.post(func(a *App) { a.loadBuildSystems(p) }) + awaitStateWithin(t, h, time.Minute, "the provider model", func() bool { + return len(p.build.instances) == 1 && (p.build.instances[0].modelLoaded || p.build.instances[0].modelError != "") + }) + instance := &p.build.instances[0] + if instance.modelError != "" { + t.Fatalf("the provider model failed: %s", instance.modelError) + } + targetID := "" + for _, target := range instance.Model.Targets { + if target.Name == "libapp" { + targetID = target.ID + } + } + if targetID == "" { + t.Fatalf("no libapp target in %+v", instance.Model.Targets) + } + var op *buildOperation + h.app.post(func(a *App) { + a.runBuildTarget(p, targetID, "application") + op = p.build.operation + }) + awaitStateWithin(t, h, time.Minute, "the run operation", func() bool { return op != nil }) + awaitStateWithin(t, h, time.Minute, "the failed preparation", func() bool { return p.build.operation == nil }) + if console := op.session.output.all(); !strings.Contains(console, "class, interface, enum, or record expected") { + t.Fatalf("the run console = %q, want the provider's build output", console) + } + if op.session.outcome != runFailed { + t.Fatalf("a failed preparation ended as %d, want failed", op.session.outcome) + } +} diff --git a/desktop/internal/workbench/title_run.go b/desktop/internal/workbench/title_run.go index ca639ce001..9c76af2778 100644 --- a/desktop/internal/workbench/title_run.go +++ b/desktop/internal/workbench/title_run.go @@ -3,6 +3,7 @@ package workbench import ( "context" "errors" + "strconv" "github.com/1lck/Lithe-IDEA/desktop/internal/core" "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" @@ -51,6 +52,29 @@ func (p *project) runConfigsSettled() bool { return true } +// noRunConfigurationsNotice explains an empty run configuration list once it is final, and +// is empty while there is something to edit, the list is still read, or reading it failed +// (the menu and the Run window show that failure). +func (p *project) noRunConfigurationsNotice(language i18n.Language) string { + s := &p.runConfigs + if !p.runConfigsSettled() || s.failure != "" || len(s.list) > 0 { + return "" + } + if p.build.failed != "" { + return p.build.failed + } + if s.hidden > 0 { + return i18n.SharedFormat(language, "desktop.title.nothingToEditHidden", map[string]string{"count": strconv.Itoa(s.hidden)}) + } + return i18n.Shared(language, "desktop.title.nothingToEdit") +} + +// hiddenRunConfigurations says how many saved configurations the list leaves out because no +// build plugin starts them. +func hiddenRunConfigurations(language i18n.Language, count int) string { + return i18n.SharedFormat(language, "desktop.title.hiddenRunConfigurations", map[string]string{"count": strconv.Itoa(count)}) +} + // loadTitleRunConfigs reads what the title bar lists. Detection runs once; after it every // detected instance loads its model, since each offers its own runs, where the Build window // only loads the instance it shows. @@ -97,11 +121,16 @@ func (a *App) chooseTitleConfiguration(p *project, id string) { } // editRunConfigurations opens the Run window, which lists the configurations, and the editor -// of the one the title bar runs. +// of the one the title bar runs. Once the configurations are read and there is none, it says +// why instead: the Run window would show nothing, so the press looked like it did nothing. func (a *App) editRunConfigurations(p *project) { if p == nil { return } + if notice := p.noRunConfigurationsNotice(a.language()); notice != "" { + a.notifyInfo(notice) + return + } a.openToolWindow(itemRun) if configuration := p.titleConfiguration(); configuration != nil { a.openRunConfigEditor(p, configuration.ID) diff --git a/desktop/internal/workbench/title_run_empty_visual_test.go b/desktop/internal/workbench/title_run_empty_visual_test.go new file mode 100644 index 0000000000..9773990d82 --- /dev/null +++ b/desktop/internal/workbench/title_run_empty_visual_test.go @@ -0,0 +1,92 @@ +//go:build vivahead + +package workbench + +import ( + "encoding/json" + "os" + "path/filepath" + "testing" + "time" + + "github.com/1lck/Lithe-IDEA/desktop/internal/core" + "github.com/1lck/Lithe-IDEA/desktop/internal/i18n" + "github.com/1lck/Lithe-IDEA/desktop/internal/store" + "github.com/vivaui/viva/app" + "github.com/vivaui/viva/headless" +) + +// TestVisualTitleRunWithoutConfigurations captures the run configuration menu of a project +// whose build plugin declares no run while two saved configurations are hidden, and the notice +// Edit Configuration… shows there (#2028). +func TestVisualTitleRunWithoutConfigurations(t *testing.T) { + out := os.Getenv("LITHE_VISUAL_OUTPUT_DIR") + if out == "" { + t.Skip("set LITHE_VISUAL_OUTPUT_DIR") + } + if err := os.MkdirAll(out, 0755); err != nil { + t.Fatal(err) + } + for _, scene := range []struct{ theme, language string }{{"light", "zh-CN"}, {"dark", "en-US"}} { + name := scene.theme + "-" + scene.language + t.Run(name, func(t *testing.T) { + prefs := store.At(t.TempDir()) + if err := prefs.Save(settingsFile, map[string]string{"theme": scene.theme}); err != nil { + t.Fatal(err) + } + root := runConfigRoot(t) + local := map[string]any{"version": 2, "configurations": []any{ + map[string]any{"id": "java.main:app/server:Main", "name": "Main", "provider": "java.main", "command": "java"}, + map[string]any{"id": "user:boot", "name": "Boot", "provider": "spring-boot.maven", "command": "mvn"}, + }} + data, err := json.Marshal(local) + if err != nil { + t.Fatal(err) + } + if err := os.MkdirAll(filepath.Join(root, ".lithe", "run"), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(filepath.Join(root, ".lithe", "run", "local.json"), data, 0o600); err != nil { + t.Fatal(err) + } + var session *headless.Session + h := newHarnessWithDriver(t, Options{Kernel: &testKernel{Client: core.NewClient()}, Store: prefs, Languages: []string{scene.language}}, func(config app.Config) (*app.Driver, func(), error) { + config.Width, config.Height = 1280, 800 + var err error + session, err = headless.Open(config, nil, headless.Options{Scale: 1}) + if err != nil { + return nil, nil, err + } + return session.Driver(), session.Close, nil + }) + h.open(root) + p := h.app.project + h.app.post(func(a *App) { + instance := runConfigInstance("app") + instance.System.Runs = nil + p.build.loaded = true + p.build.instances = []buildInstance{instance} + a.refreshRunConfigurations(p) + }) + awaitStateWithin(t, h, 10*time.Second, "the run configurations", func() bool { return p.runConfigs.generation > 0 && !p.runConfigs.loading }) + language := h.app.language() + h.click(center(h.button(itemRunConfig))) + h.settle() + if err := session.Screenshot(filepath.Join(out, "title-run-empty-menu-"+name+".png")); err != nil { + t.Fatal(err) + } + if !h.shows(hiddenRunConfigurations(language, 2)) { + t.Fatal("the menu did not paint the hidden configurations") + } + h.clickNamed(i18n.Shared(language, "native.editConfiguration")) + h.settle() + if err := session.Screenshot(filepath.Join(out, "title-run-empty-edit-"+name+".png")); err != nil { + t.Fatal(err) + } + want := i18n.SharedFormat(language, "desktop.title.nothingToEditHidden", map[string]string{"count": "2"}) + if got := lastNotice(h); got != want { + t.Fatalf("notice = %q, want %q", got, want) + } + }) + } +} diff --git a/desktop/internal/workbench/title_run_test.go b/desktop/internal/workbench/title_run_test.go index 4e8fdb90d1..10a19799a7 100644 --- a/desktop/internal/workbench/title_run_test.go +++ b/desktop/internal/workbench/title_run_test.go @@ -211,3 +211,84 @@ func TestTitleRunOnAConfigurationNoProviderStartsSaysSo(t *testing.T) { t.Fatalf("%d run requests, pending %v", len(gate.requests), p.runConfigs.pending) } } + +// emptyRunConfigHarness opens root with one detected instance whose model declares no run, +// and returns once Core resolved the project's configurations. +func emptyRunConfigHarness(t *testing.T, root string) (*harness, *project) { + t.Helper() + h := newHarness(t, &testKernel{Client: core.NewClient()}) + h.open(root) + p := h.app.project + h.app.post(func(a *App) { + instance := runConfigInstance("app") + instance.System.Runs = nil + p.build.loaded = true + p.build.instances = []buildInstance{instance} + a.refreshRunConfigurations(p) + }) + awaitStateWithin(t, h, 10*time.Second, "the run configurations", func() bool { return p.runConfigs.generation > 0 && !p.runConfigs.loading }) + if len(p.runConfigs.list) != 0 || p.runConfigs.failure != "" { + t.Fatalf("configurations = %+v failure %q", p.runConfigs.list, p.runConfigs.failure) + } + return h, p +} + +// Edit Configuration on a project without configurations used to open a Run window that showed +// nothing, which looked like no reaction (#2028); it now says why the list is empty. +func TestEditRunConfigurationsWithoutAnyExplainsWhy(t *testing.T) { + h, p := emptyRunConfigHarness(t, runConfigRoot(t)) + h.app.post(func(a *App) { a.editRunConfigurations(p) }) + h.settle() + want := i18n.Shared(h.app.language(), "desktop.title.nothingToEdit") + if got := lastNotice(h); got != want { + t.Fatalf("notice = %q, want %q", got, want) + } + if p.runConfigs.editor.open { + t.Fatal("an editor opened without a configuration") + } +} + +// Saved configurations that no build plugin starts, such as the java.main entries an earlier +// version wrote into .lithe/run/local.json, stay out of the list; the explanation counts them +// instead of dropping them silently (#2028). +func TestEditRunConfigurationsCountsTheConfigurationsNoBuildPluginStarts(t *testing.T) { + root := runConfigRoot(t) + local := map[string]any{"version": 2, "configurations": []any{ + // A generated entry of an earlier version: Core no longer generates it and reports it orphaned. + map[string]any{"id": "java.main:app/server:Main", "name": "Main", "provider": "java.main", "command": "java", "args": []string{"Main"}}, + // A user entry of a provider no build plugin answers: Core resolves it, the list leaves it out. + map[string]any{"id": "user:boot", "name": "Boot", "provider": "spring-boot.maven", "command": "mvn", "args": []string{"spring-boot:run"}}, + }} + data, err := json.Marshal(local) + if err != nil { + t.Fatal(err) + } + if err := os.MkdirAll(filepath.Join(root, ".lithe", "run"), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(filepath.Join(root, ".lithe", "run", "local.json"), data, 0o600); err != nil { + t.Fatal(err) + } + h, p := emptyRunConfigHarness(t, root) + if p.runConfigs.hidden != 2 { + t.Fatalf("hidden = %d, want 2", p.runConfigs.hidden) + } + h.app.post(func(a *App) { a.editRunConfigurations(p) }) + h.settle() + language := h.app.language() + want := i18n.SharedFormat(language, "desktop.title.nothingToEditHidden", map[string]string{"count": "2"}) + if got := lastNotice(h); got != want { + t.Fatalf("notice = %q, want %q", got, want) + } +} + +// With configurations to show, Edit Configuration keeps opening the Run window and the editor +// of the chosen one. +func TestEditRunConfigurationsOpensTheChosenOnesEditor(t *testing.T) { + h, p := titleRunHarness(t, &testKernel{Client: core.NewClient()}, pluginservice.BuildRunDeclaration{ID: "application", Name: "Run", Tags: []string{"app"}}) + h.app.post(func(a *App) { a.editRunConfigurations(p) }) + awaitStateWithin(t, h, 10*time.Second, "the editor", func() bool { return p.runConfigs.editor.open }) + if !h.app.chrome.isOpen(catalogIndex[itemRun]) || lastNotice(h) != "" { + t.Fatalf("Run window open %v, notice %q", h.app.chrome.isOpen(catalogIndex[itemRun]), lastNotice(h)) + } +} diff --git a/desktop/internal/workbench/title_run_view.go b/desktop/internal/workbench/title_run_view.go index ca7fb87417..1bf06615ac 100644 --- a/desktop/internal/workbench/title_run_view.go +++ b/desktop/internal/workbench/title_run_view.go @@ -49,6 +49,9 @@ func (a *App) titleRunConfigMenu(c ui.C, anchor ui.Box) { menu.Item(p.build.failed).Disabled(true) case len(s.list) == 0: menu.Item(i18n.Shared(lang, "desktop.title.noRunConfigurations")).Disabled(true) + if s.hidden > 0 { + menu.Item(hiddenRunConfigurations(lang, s.hidden)).Disabled(true) + } } menu.Separator() if menu.Item(i18n.Shared(lang, "native.editConfiguration")).Icon(icons.Pencil).Clicked() { diff --git a/docs/assets/run-config-empty/title-run-empty-edit-dark-en-US.png b/docs/assets/run-config-empty/title-run-empty-edit-dark-en-US.png new file mode 100644 index 0000000000..715501cb84 Binary files /dev/null and b/docs/assets/run-config-empty/title-run-empty-edit-dark-en-US.png differ diff --git a/docs/assets/run-config-empty/title-run-empty-edit-light-zh-CN.png b/docs/assets/run-config-empty/title-run-empty-edit-light-zh-CN.png new file mode 100644 index 0000000000..6705391f4d Binary files /dev/null and b/docs/assets/run-config-empty/title-run-empty-edit-light-zh-CN.png differ diff --git a/docs/assets/run-config-empty/title-run-empty-menu-dark-en-US.png b/docs/assets/run-config-empty/title-run-empty-menu-dark-en-US.png new file mode 100644 index 0000000000..f555d42503 Binary files /dev/null and b/docs/assets/run-config-empty/title-run-empty-menu-dark-en-US.png differ diff --git a/docs/assets/run-config-empty/title-run-empty-menu-light-zh-CN.png b/docs/assets/run-config-empty/title-run-empty-menu-light-zh-CN.png new file mode 100644 index 0000000000..71441e8b71 Binary files /dev/null and b/docs/assets/run-config-empty/title-run-empty-menu-light-zh-CN.png differ diff --git a/shared/i18n/locales/en-US.json b/shared/i18n/locales/en-US.json index 0fecb4c2cb..eed64395ef 100644 --- a/shared/i18n/locales/en-US.json +++ b/shared/i18n/locales/en-US.json @@ -11274,6 +11274,9 @@ "desktop.plugins.commandInstallError": "Could not install: {reason}", "desktop.title.configurationNotStartable": "{name} cannot be started: no build plugin runs it.", "desktop.title.currentFileNotRunnable": "The current file cannot run on its own. Choose a project run configuration from the run configuration menu.", + "desktop.title.hiddenRunConfigurations": "{count} saved configurations hidden (not runnable)", + "desktop.title.nothingToEdit": "This project has no run configurations to edit. Build plugins create them from the project model, and none of the enabled build plugins declares a runnable entry for this project.", + "desktop.title.nothingToEditHidden": "This project has no run configurations to edit. Build plugins create them from the project model, and none of the enabled build plugins declares a runnable entry for this project. {count} saved run configurations are hidden because no build plugin runs them, for example entries an earlier version of Lithe saved in .lithe/run.", "desktop.title.noRunConfigurations": "No run configurations", "desktop.title.notDebuggable": "{name} cannot be debugged: its plugin declares no debug adapter for this run.", "desktop.title.runBusy": "The Run window is still running another operation. Wait for it to finish or stop it first.", diff --git a/shared/i18n/locales/zh-CN.json b/shared/i18n/locales/zh-CN.json index c35d934b35..614e80bd48 100644 --- a/shared/i18n/locales/zh-CN.json +++ b/shared/i18n/locales/zh-CN.json @@ -11274,6 +11274,9 @@ "desktop.plugins.commandInstallError": "无法安装:{reason}", "desktop.title.configurationNotStartable": "无法启动 {name}:没有构建插件负责运行它。", "desktop.title.currentFileNotRunnable": "当前文件不能单独运行。请在运行配置菜单里选择一个项目运行配置。", + "desktop.title.hiddenRunConfigurations": "已隐藏 {count} 条无法运行的已保存配置", + "desktop.title.nothingToEdit": "这个项目没有可编辑的运行配置。运行配置由构建插件根据项目模型生成,当前启用的构建插件没有为这个项目声明可运行的入口。", + "desktop.title.nothingToEditHidden": "这个项目没有可编辑的运行配置。运行配置由构建插件根据项目模型生成,当前启用的构建插件没有为这个项目声明可运行的入口。另有 {count} 条保存的运行配置没有构建插件负责运行,已隐藏,例如旧版 Lithe 保存在 .lithe/run 中的配置。", "desktop.title.noRunConfigurations": "没有运行配置", "desktop.title.notDebuggable": "无法调试 {name}:它所属的插件没有为这个运行声明调试适配器。", "desktop.title.runBusy": "运行窗口还在执行其他操作。请等它结束,或者先停止它。", diff --git a/shared/i18n/messages.json b/shared/i18n/messages.json index 7ccff90a37..91f2776fd5 100644 --- a/shared/i18n/messages.json +++ b/shared/i18n/messages.json @@ -18627,6 +18627,16 @@ "desktop" ] }, + { + "id": "desktop.title.hiddenRunConfigurations", + "description": "Desktop title bar: a short disabled line of the run configuration menu saying how many saved run configurations it leaves out because no build plugin starts them, such as entries an earlier version saved; Edit Configuration explains it in full", + "platforms": [ + "desktop" + ], + "parameters": { + "count": "unsignedInteger" + } + }, { "id": "desktop.title.keymapLater", "description": "Desktop title bar: KeymapLater", @@ -18662,6 +18672,23 @@ "desktop" ] }, + { + "id": "desktop.title.nothingToEdit", + "description": "Desktop title bar: Edit Configuration chosen when the project has no run configuration; build plugins generate them from the project model and none declared a runnable entry", + "platforms": [ + "desktop" + ] + }, + { + "id": "desktop.title.nothingToEditHidden", + "description": "Desktop title bar: Edit Configuration chosen when the project has no run configuration that a build plugin starts, while count saved ones are hidden because no build plugin runs them", + "platforms": [ + "desktop" + ], + "parameters": { + "count": "unsignedInteger" + } + }, { "id": "desktop.title.notDebuggable", "description": "Desktop title bar: Debug pressed on a run configuration whose plugin declares no debug adapter for its run", diff --git a/shared/platform-feature-matrix/features/viva-title-run-debug.json b/shared/platform-feature-matrix/features/viva-title-run-debug.json index f8bacf1e6a..2e2e895f05 100644 --- a/shared/platform-feature-matrix/features/viva-title-run-debug.json +++ b/shared/platform-feature-matrix/features/viva-title-run-debug.json @@ -2,7 +2,7 @@ "id": "viva-title-run-debug", "area": "运行与调试", "group": "运行配置", - "capability": "标题栏右上角的运行配置下拉、运行和调试按钮:下拉列出构建提供者检测到的运行配置并可选择“当前文件”,运行按所选配置交给提供者启动并打开运行窗口,调试让提供者准备该运行声明的调试适配器后在调试窗口启动会话;配置尚未读出时按下会等读出后再执行;按下后做什么(等待、先加载模型、运行、调试或提示)由 Core 判定", + "capability": "标题栏右上角的运行配置下拉、运行和调试按钮:下拉列出构建提供者检测到的运行配置并可选择“当前文件”,运行按所选配置交给提供者启动并打开运行窗口,调试让提供者准备该运行声明的调试适配器后在调试窗口启动会话;配置尚未读出时按下会等读出后再执行;按下后做什么(等待、先加载模型、运行、调试或提示)由 Core 判定;没有运行配置时,下拉说明被隐藏的已保存配置数,“编辑运行配置…”提示原因而不是无反应;未声明名称的提供者运行以目标名命名;提供者准备运行时输出的构建日志(如编译错误)显示在该运行的控制台;声明了提供者进程、但用命令读取模型和依赖的构建系统按各自声明的来源读取", "macos": { "implementationStatus": "implemented", "verificationStatus": "pending", @@ -14,7 +14,10 @@ "desktop/internal/workbench/build.go", "desktop/internal/pluginservice/builds.go", "desktop/internal/core/build.go", - "desktop/internal/core/run_config.go" + "desktop/internal/core/run_config.go", + "desktop/internal/workbench/build_dependencies.go", + "desktop/internal/workbench/tests_provider_test.go", + "desktop/internal/workbench/build_command_record_test.go" ] }, "windows": { @@ -28,10 +31,13 @@ "desktop/internal/workbench/build.go", "desktop/internal/pluginservice/builds.go", "desktop/internal/core/build.go", - "desktop/internal/core/run_config.go" + "desktop/internal/core/run_config.go", + "desktop/internal/workbench/build_dependencies.go", + "desktop/internal/workbench/tests_provider_test.go", + "desktop/internal/workbench/build_command_record_test.go" ] }, "owner": "Run", - "verification": "打开带构建提供者的项目(测试内联的合成 Build Provider 即可):标题栏下拉列出检测到的运行配置并记住所选项;运行按钮启动所选配置并打开运行窗口;调试按钮对声明了调试适配器的运行准备并启动调试会话、打开调试窗口,未声明时提示该配置不能调试;准备失败时结束“准备中”并显示原因;选择“当前文件”时提示需要运行配置。单元测试覆盖等待配置读出后运行、当前文件提示、无适配器提示、不经构建提供者启动的配置提示、提供者准备请求、按名称选择适配器和拒绝插件未安装的适配器。", - "notes": "Viva 标题栏按钮此前只有外观。运行忙碌时仅提示,不排队;当前文件运行尚未实现,只提示需要配置;提供者调试暂不携带运行配置的启动选项。macOS、Windows 原生窗口验收 pending。" + "verification": "打开带构建提供者的项目(测试内联的合成 Build Provider 即可):标题栏下拉列出检测到的运行配置并记住所选项;运行按钮启动所选配置并打开运行窗口;调试按钮对声明了调试适配器的运行准备并启动调试会话、打开调试窗口,未声明时提示该配置不能调试;准备失败时结束“准备中”并显示原因;选择“当前文件”时提示需要运行配置;项目没有运行配置时点“编辑运行配置…”提示原因,有旧版或其他提供方的已保存配置时说明隐藏了几条。提供者运行准备失败时,运行控制台显示提供者输出的构建日志;未声明名称的运行,配置名就是目标名。单元测试覆盖等待配置读出后运行、没有配置时编辑入口的提示和隐藏条数、当前文件提示、无适配器提示、不经构建提供者启动的配置提示、提供者准备请求、按名称选择适配器和拒绝插件未安装的适配器、准备运行时转发提供者输出、未命名运行按目标命名,以及声明提供者进程但用命令读取模型和写文件的依赖命令。", + "notes": "Viva 标题栏按钮此前只有外观。运行忙碌时仅提示,不排队;当前文件运行尚未实现,只提示需要配置;提供者调试暂不携带运行配置的启动选项;按配置类型连接的服务运行调试(`run[].debug.configurationType`)尚未实现,这类运行点调试时提示不能调试(#2107)。macOS、Windows 原生窗口验收 pending。" }