mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 08:52:12 +00:00
Go settings, execution, debugging and test reporting were disconnected, leaving Go projects without editable build/test fields and workspace maintenance actions. - Add project build constraints that update gopls in place, and notices on excluded files. - Add editable Go Build and Go Test configurations with directory, package and file targets, separate tool and program arguments, modules, environment, output selection and build-only execution, and pass the same settings to Delve. - Decode Go JSON test output into the results view, with subtests, failures, skips and rerun failed. Add gutter targets for benchmarks and generate directives. - Add module environment and vendoring settings, read go.work members, and offer tidy, download, sync and use from file menus. - Add file and package generate actions, and format and organize imports through gopls on Save and Reformat. - Show what a Go program prints in the debug console: Delve's debuggee shares its stdio, which no DAP event carries. - Keep the default build output out of version control, and keep configurations produced by an earlier run out of the gutter choices. Fixes #507 Fixes #237
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import type { RunConfig } from "@/platform/ipc";
|
|
import type { MenuGroupContext } from "@/workbench/contributions";
|
|
|
|
export function goGenerateConfig(path: string, scope: "file" | "package", directive?: string): RunConfig | null {
|
|
if (!path.endsWith(".go") || path.includes("\0")) return null;
|
|
const slash = path.lastIndexOf("/");
|
|
const file = path.slice(slash + 1);
|
|
const pattern = directive ? `^${directive.trim().replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$` : null;
|
|
const target = scope === "package" ? "." : file.startsWith("-") ? `./${file}` : file;
|
|
return {
|
|
id: `go:generate:${scope}:${path}:${pattern ?? ""}`,
|
|
name: `go generate ${target}`,
|
|
kind: "go",
|
|
command: "go",
|
|
args: ["generate", ...(pattern ? ["-run", pattern] : []), target],
|
|
cwd: slash < 0 ? null : path.slice(0, slash) || "/",
|
|
env: {},
|
|
detected: true,
|
|
isTest: false,
|
|
debugAdapter: null,
|
|
params: { useTags: "true" },
|
|
};
|
|
}
|
|
|
|
export function goGenerateMenu(ctx: MenuGroupContext) {
|
|
const path = ctx.paths.length === 1 ? ctx.paths[0]! : "";
|
|
if (!path.endsWith(".go") || ctx.dirs?.[0]) return [];
|
|
return [
|
|
{ kind: "action" as const, action: "go.generate.file", arg: { path } },
|
|
{ kind: "action" as const, action: "go.generate.package", arg: { path } },
|
|
];
|
|
}
|