mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-22 23:56:05 -10:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c45e20b6da | ||
|
|
1bb9f8d07c | ||
|
|
a539baec37 | ||
|
|
7dff6e1852 | ||
|
|
fc7fa85850 |
No files matched your search
@@ -0,0 +1,71 @@
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, test } from "./fixtures";
|
||||
|
||||
async function show(page: Page, action: string) {
|
||||
await page.evaluate(async (action) => {
|
||||
const actions = "/src/platform/actions.ts";
|
||||
if (!(await (await import(/* @vite-ignore */ actions)).executeAction(action))) throw Error(action);
|
||||
}, action);
|
||||
}
|
||||
|
||||
test("analysis scope fields align with their radio choices and retain their values", async ({ workbench: page }) => {
|
||||
await page.evaluate(async () => {
|
||||
const search = "/src/platform/search.ts";
|
||||
(await import(/* @vite-ignore */ search)).saveCustomScopes([
|
||||
{ name: "Frontend", pattern: "file:src//*" },
|
||||
{ name: "Tests", pattern: "file:tests//*" },
|
||||
]);
|
||||
});
|
||||
await show(page, "analyze.inspectCode");
|
||||
const dialog = page.getByRole("dialog", { name: "Specify Inspection Scope" });
|
||||
const scope = dialog.getByRole("group", { name: "Scope" });
|
||||
const directory = scope.getByRole("textbox", { name: "Directory" });
|
||||
const custom = scope.getByRole("button", { name: "Custom scope", exact: true });
|
||||
const radio = scope.getByRole("radio", { name: "Module or directory" });
|
||||
const label = scope.getByText("Module or directory", { exact: true });
|
||||
|
||||
await radio.check();
|
||||
const path = (await directory.boundingBox())!;
|
||||
const choice = (await label.boundingBox())!;
|
||||
expect(path.y + path.height / 2).toBeCloseTo(choice.y + choice.height / 2, 0);
|
||||
await directory.fill("/dev/acme-api/src");
|
||||
await expect(custom).toBeDisabled();
|
||||
await scope.getByRole("radio", { name: "Custom scope", exact: true }).check();
|
||||
await expect(directory).toBeDisabled();
|
||||
expect((await custom.boundingBox())!.x).toBeCloseTo(path.x, 0);
|
||||
await custom.click();
|
||||
await page.getByRole("option", { name: /^Tests/ }).click();
|
||||
await expect(custom).toContainText("Tests");
|
||||
|
||||
await radio.check();
|
||||
await expect(directory).toHaveValue("/dev/acme-api/src");
|
||||
await scope.getByRole("radio", { name: "Custom scope", exact: true }).check();
|
||||
await expect(custom).toContainText("Tests");
|
||||
await page.setViewportSize({ width: 400, height: 640 });
|
||||
const stacked = (await directory.boundingBox())!;
|
||||
const customBox = (await custom.boundingBox())!;
|
||||
const radioBox = (await label.boundingBox())!;
|
||||
const next = (await scope.getByText("Current file", { exact: true }).boundingBox())!;
|
||||
expect(stacked.y).toBeGreaterThan(radioBox.y + radioBox.height);
|
||||
expect(stacked.y + stacked.height).toBeLessThan(next.y);
|
||||
expect(stacked.x).toBeCloseTo(customBox.x, 0);
|
||||
expect(await scope.evaluate((el) => el.scrollWidth - el.clientWidth)).toBeLessThanOrEqual(1);
|
||||
});
|
||||
|
||||
for (const [action, title] of [
|
||||
["code.cleanup", "Run Code Cleanup"],
|
||||
["analyze.locateDuplicates", "Locate Duplicates"],
|
||||
["find.structural", "Structural Search"],
|
||||
["find.replaceStructural", "Structural Replace"],
|
||||
] as const) {
|
||||
test(`${title} keeps directory options with their scope choice`, async ({ workbench: page }) => {
|
||||
await show(page, action);
|
||||
const dialog = page.getByRole("dialog", { name: title });
|
||||
const scope = dialog.getByRole("group", { name: "Scope" });
|
||||
const directory = scope.getByRole("textbox", { name: "Directory" });
|
||||
await expect(directory).toBeDisabled();
|
||||
await scope.getByRole("radio", { name: "Module or directory" }).check();
|
||||
await expect(directory).toBeEnabled();
|
||||
await expect(scope.getByRole("button", { name: "Browse…" })).toBeEnabled();
|
||||
});
|
||||
}
|
||||
@@ -1,11 +1,12 @@
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
import type { Page } from "@playwright/test";
|
||||
import { expect, PROJECT, stubDesktop, test } from "./fixtures";
|
||||
|
||||
test("Coverage keeps sortable statistics aligned next to the file tree at sidebar widths", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
async function importCoverage(page: Page, width: number) {
|
||||
await page.setViewportSize({ width: 1050, height: 550 });
|
||||
await expect(page.getByRole("tree", { name: "Project" }).getByRole("treeitem", { name: PROJECT })).toBeVisible();
|
||||
await expect(page.locator("#splash")).toHaveCount(0);
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async () => {
|
||||
await page.evaluate(async (width) => {
|
||||
const projectModule = "/src/platform/project.ts";
|
||||
const actionsModule = "/src/platform/actions.ts";
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
@@ -26,10 +27,15 @@ test("Coverage keeps sortable statistics aligned next to the file tree at sideba
|
||||
hasBranches: path === "/tmp/coverage.lcov",
|
||||
files,
|
||||
});
|
||||
setToolWindowSize("right", 280);
|
||||
setToolWindowSize("right", width);
|
||||
await executeAction("coverage.importReport", "/tmp/coverage.lcov");
|
||||
});
|
||||
}, width);
|
||||
}
|
||||
|
||||
test("Coverage keeps sortable statistics aligned next to the file tree at sidebar widths", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await importCoverage(page, 280);
|
||||
const coverage = page.getByRole("region", { name: "Coverage", exact: true });
|
||||
const tree = coverage.getByRole("tree", { name: "Coverage" });
|
||||
const line = coverage.getByRole("columnheader", { name: "Line, %" });
|
||||
@@ -70,3 +76,58 @@ test("Coverage keeps sortable statistics aligned next to the file tree at sideba
|
||||
await expect(line).toBeVisible();
|
||||
expect((await ready.getByTitle("100% (20/20)").boundingBox())!.x).toBeCloseTo((await line.boundingBox())!.x, 0);
|
||||
});
|
||||
|
||||
test("Coverage column widths follow the dividers and survive a narrower dock and reload", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
await importCoverage(page, 460);
|
||||
const coverage = page.getByRole("region", { name: "Coverage", exact: true });
|
||||
const line = coverage.getByRole("columnheader", { name: "Line, %" });
|
||||
const branch = coverage.getByRole("columnheader", { name: "Branch, %" });
|
||||
const lineDivider = coverage.getByRole("separator", { name: "Resize Line, % column" });
|
||||
const branchDivider = coverage.getByRole("separator", { name: "Resize Branch, % column" });
|
||||
const ready = coverage.getByRole("treeitem", { name: /^Ready\.ts/ });
|
||||
const nameHeader = coverage.getByRole("columnheader", { name: "Element" });
|
||||
await expect(lineDivider).toBeVisible();
|
||||
const width = async (loc: typeof line) => (await loc.boundingBox())!.width;
|
||||
const originalLine = await width(line);
|
||||
const originalBranch = await width(branch);
|
||||
const originalName = await width(nameHeader);
|
||||
const drag = (await lineDivider.boundingBox())!;
|
||||
await page.mouse.move(drag.x + drag.width / 2, drag.y + drag.height / 2);
|
||||
await page.mouse.down();
|
||||
await page.mouse.move(drag.x + drag.width / 2 + 32, drag.y + drag.height / 2, { steps: 4 });
|
||||
await page.mouse.up();
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine - 32, 0);
|
||||
await expect.poll(() => width(nameHeader)).toBeCloseTo(originalName + 32, 0);
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch, 0);
|
||||
await expect(line).toHaveAttribute("aria-sort", "none");
|
||||
|
||||
await branchDivider.press("ArrowRight");
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch - 10, 0);
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine - 22, 0);
|
||||
expect((await ready.getByTitle("100% (20/20)").boundingBox())!.x).toBeCloseTo((await line.boundingBox())!.x, 0);
|
||||
|
||||
const resizeDock = (size: number) =>
|
||||
page.evaluate(async (size) => {
|
||||
const layoutModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { setToolWindowSize } = await import(/* @vite-ignore */ layoutModule);
|
||||
setToolWindowSize("right", size);
|
||||
}, size);
|
||||
await resizeDock(240);
|
||||
await expect.poll(() => width(line)).toBeLessThan(originalLine - 22);
|
||||
const tree = coverage.getByRole("tree", { name: "Coverage" });
|
||||
await expect.poll(() => tree.evaluate((el) => el.scrollWidth - el.clientWidth)).toBe(0);
|
||||
await expect(branchDivider).toBeInViewport({ ratio: 1 });
|
||||
await resizeDock(460);
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine - 22, 0);
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch - 10, 0);
|
||||
|
||||
await page.reload();
|
||||
await importCoverage(page, 460);
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine - 22, 0);
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch - 10, 0);
|
||||
await branchDivider.dblclick();
|
||||
await expect.poll(() => width(line)).toBeCloseTo(originalLine, 0);
|
||||
await expect.poll(() => width(branch)).toBeCloseTo(originalBranch, 0);
|
||||
});
|
||||
@@ -3,6 +3,7 @@
|
||||
* with its frames and variables, and stepping and resuming go back to the adapter. The adapter is
|
||||
* stubbed at the IPC layer; `crates/ide-dap/tests` drives real ones.
|
||||
*/
|
||||
import type { JvmMemoryResult } from "../src/platform/ipc";
|
||||
import { expect, ipcCalls, openFromTree, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const ROOT = "/dev/acme-api";
|
||||
@@ -114,6 +115,83 @@ test("stops at a breakpoint, shows frames and variables, steps and resumes", asy
|
||||
await expect(debug.getByText("CreateOrderRequest(sku='A-1', qty=2)")).toBeHidden();
|
||||
});
|
||||
|
||||
test("Memory gives class filtering the available toolbar width and exposes changed-only filtering", async ({
|
||||
workbench: page,
|
||||
}) => {
|
||||
const rows = [
|
||||
{ name: "OrderCache", instances: 64, deltaInstances: 12 },
|
||||
{ name: "OrderRepository", instances: 16, deltaInstances: 0 },
|
||||
].map((row) => ({ ...row, bytes: row.instances * 16, deltaBytes: null, module: null, ambiguous: false }));
|
||||
const result: JvmMemoryResult = {
|
||||
status: "ready",
|
||||
snapshot: {
|
||||
rows,
|
||||
totalInstances: 80,
|
||||
totalBytes: 1280,
|
||||
javaVersion: "21",
|
||||
takenWhileSuspended: true,
|
||||
hasBaseline: true,
|
||||
elapsedMs: 5,
|
||||
source: "debugger",
|
||||
},
|
||||
};
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(
|
||||
async ({ result, id }) => {
|
||||
const caps = { jvmMemory: true, jvmHeap: true };
|
||||
window.__ipc.handlers.debug_capabilities = () => caps;
|
||||
window.__ipc.handlers.debug_jvm_memory_classes = () => result;
|
||||
const debugPath = "/src/features/debugger/state.ts";
|
||||
const { adoptSession } = await import(/* @vite-ignore */ debugPath);
|
||||
adoptSession(id, { adapter: "java-debug", name: "Billing Service", status: "paused", caps });
|
||||
const dockPath = "/src/workbench/toolwindows/store.ts";
|
||||
const layout = await import(/* @vite-ignore */ dockPath);
|
||||
layout.moveToolWindow("debug", "bottom");
|
||||
layout.setToolWindowSize("bottom", 300);
|
||||
layout.showToolWindow("debug", true);
|
||||
},
|
||||
{ result, id: SESSION },
|
||||
);
|
||||
|
||||
const debug = page.getByRole("region", { name: "Debug", exact: true });
|
||||
await debug.getByRole("tab", { name: "Memory" }).click();
|
||||
const toolbar = debug.getByRole("toolbar", { name: "Memory", exact: true });
|
||||
const filter = toolbar.getByRole("textbox", { name: "Filter classes" });
|
||||
const options = toolbar.getByRole("button", { name: "View Options" });
|
||||
const grid = debug.getByRole("grid", { name: "Memory", exact: true });
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
|
||||
expect((await filter.boundingBox())!.width).toBeGreaterThan((await toolbar.boundingBox())!.width / 2);
|
||||
|
||||
await page.evaluate(async () => {
|
||||
const dockPath = "/src/workbench/toolwindows/store.ts";
|
||||
const layout = await import(/* @vite-ignore */ dockPath);
|
||||
layout.moveToolWindow("debug", "right");
|
||||
layout.setToolWindowSize("right", 330);
|
||||
});
|
||||
await expect.poll(async () => (await toolbar.boundingBox())!.width).toBeCloseTo(330, 0);
|
||||
const bar = (await toolbar.boundingBox())!;
|
||||
const gear = (await options.boundingBox())!;
|
||||
const input = (await filter.boundingBox())!;
|
||||
expect(input.width).toBeGreaterThan(bar.width / 2);
|
||||
expect(input.x + input.width).toBeLessThan(gear.x);
|
||||
expect(gear.x + gear.width).toBeLessThanOrEqual(bar.x + bar.width);
|
||||
|
||||
await filter.fill("cache");
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
|
||||
await toolbar.getByRole("button", { name: "Clear", exact: true }).click();
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeVisible();
|
||||
|
||||
await options.press("Enter");
|
||||
const changed = page.getByRole("menuitemcheckbox", { name: "Changed only" });
|
||||
await expect(changed).not.toBeChecked();
|
||||
await changed.press("Enter");
|
||||
await expect(grid.getByText("OrderRepository", { exact: true })).toBeHidden();
|
||||
await expect(options).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(options).toBeFocused();
|
||||
await options.press("Enter");
|
||||
await expect(changed).toBeChecked();
|
||||
});
|
||||
|
||||
test("Evaluate keeps a multiline expression and its result visible in a short dialog", async ({ workbench: page }) => {
|
||||
await page.setViewportSize({ width: 580, height: 420 });
|
||||
await stubDesktop(page);
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import type { MavenModel } from "../src/platform/ipc";
|
||||
import { expect, stubDesktop, test } from "./fixtures";
|
||||
|
||||
const maven: MavenModel = {
|
||||
projects: [
|
||||
{
|
||||
pom: "pom.xml",
|
||||
dir: "",
|
||||
groupId: "dev.acme",
|
||||
artifactId: "billing",
|
||||
version: "1.0.0",
|
||||
packaging: "jar",
|
||||
displayName: "Billing",
|
||||
parent: null,
|
||||
modules: [],
|
||||
aggregated: false,
|
||||
plugins: [
|
||||
{
|
||||
groupId: "org.apache.maven.plugins",
|
||||
artifactId: "maven-surefire-plugin",
|
||||
version: "3.2.5",
|
||||
prefix: "surefire",
|
||||
goals: ["test"],
|
||||
},
|
||||
],
|
||||
dependencies: [],
|
||||
profiles: [],
|
||||
javaVersion: 21,
|
||||
command: "mvn",
|
||||
options: [],
|
||||
env: {},
|
||||
},
|
||||
],
|
||||
profiles: [],
|
||||
syncedAt: 1,
|
||||
stale: false,
|
||||
syncError: null,
|
||||
};
|
||||
|
||||
test("Maven plugin rows give the name priority over coordinates in narrow docks", async ({ workbench: page }) => {
|
||||
await stubDesktop(page);
|
||||
await page.evaluate(async (maven) => {
|
||||
window.__ipc.handlers.build_model = () => ({ maven, gradle: [] });
|
||||
const buildModule = "/src/features/build-tools/store.ts";
|
||||
const { loadModel, setExpanded } = await import(/* @vite-ignore */ buildModule);
|
||||
await loadModel();
|
||||
setExpanded("maven", new Set(["mvn:pom.xml", "mvn:pom.xml:plugins"]));
|
||||
const dockModule = "/src/workbench/toolwindows/store.ts";
|
||||
const { showToolWindow, setToolWindowSize } = await import(/* @vite-ignore */ dockModule);
|
||||
showToolWindow("maven", true);
|
||||
setToolWindowSize("right", 190);
|
||||
}, maven);
|
||||
|
||||
const tree = page.getByRole("tree", { name: "Maven projects" });
|
||||
const coordinates = "(org.apache.maven.plugins:maven-surefire-plugin:3.2.5)";
|
||||
const plugin = tree.getByRole("treeitem", { name: `surefire ${coordinates}`, exact: true });
|
||||
const name = plugin.getByText("surefire", { exact: true });
|
||||
const metadata = plugin.getByText(coordinates, { exact: true });
|
||||
await expect(name).toBeVisible();
|
||||
await expect(metadata).toHaveAttribute("title", coordinates);
|
||||
const fit = (el: Element) => {
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(el);
|
||||
return range.getBoundingClientRect().width <= el.getBoundingClientRect().width;
|
||||
};
|
||||
expect(await name.evaluate(fit)).toBe(true);
|
||||
expect(await metadata.evaluate(fit)).toBe(false);
|
||||
expect(await metadata.evaluate((el) => getComputedStyle(el).color)).not.toBe(
|
||||
await name.evaluate((el) => getComputedStyle(el).color),
|
||||
);
|
||||
|
||||
await plugin.locator("[data-tree-toggle]").click();
|
||||
await expect(tree.getByRole("treeitem", { name: "surefire:test", exact: true })).toBeVisible();
|
||||
});
|
||||
@@ -121,7 +121,10 @@ test("Git Log settings group display and column options with aligned checkboxes"
|
||||
|
||||
for (const width of [1000, 520]) {
|
||||
await page.setViewportSize({ width, height: 760 });
|
||||
expect((await tagNames.boundingBox())!.x).toBeCloseTo((await hash.boundingBox())!.x, 0);
|
||||
// Read both rows together once the dialog has finished opening and relaid out.
|
||||
await expect
|
||||
.poll(async () => Math.abs((await tagNames.boundingBox())!.x - (await hash.boundingBox())!.x))
|
||||
.toBeLessThan(0.5);
|
||||
}
|
||||
|
||||
await expect(hash).not.toBeChecked();
|
||||
|
||||
@@ -161,34 +161,51 @@
|
||||
padding: 14px;
|
||||
}
|
||||
.scope {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--space-0-5);
|
||||
container: analysis-scope / inline-size;
|
||||
min-inline-size: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
}
|
||||
.scopeOptions {
|
||||
display: grid;
|
||||
grid-template-columns: fit-content(45%) minmax(0, 1fr);
|
||||
align-items: center;
|
||||
gap: var(--space-0-5) var(--space-2);
|
||||
}
|
||||
.fieldLabel {
|
||||
padding: 0 0 4px;
|
||||
color: var(--fg-secondary);
|
||||
font-size: var(--fs-small);
|
||||
}
|
||||
.radioRow {
|
||||
grid-column: 1 / -1;
|
||||
min-width: 0;
|
||||
padding-block: var(--space-0-5);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.scopeWithField {
|
||||
grid-column: 1;
|
||||
}
|
||||
.scopeControl {
|
||||
grid-column: 2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-2);
|
||||
padding: 3px 0;
|
||||
color: var(--fg);
|
||||
cursor: default;
|
||||
}
|
||||
.radioRow input {
|
||||
margin: 0;
|
||||
accent-color: var(--accent);
|
||||
}
|
||||
.dirRow {
|
||||
display: flex;
|
||||
gap: var(--space-1-5);
|
||||
padding: 4px 0 0 22px;
|
||||
min-width: 0;
|
||||
}
|
||||
.scopeControl > button:last-child {
|
||||
flex: none;
|
||||
}
|
||||
@container analysis-scope (max-width: 336px) {
|
||||
.scopeOptions {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
.scopeControl {
|
||||
grid-column: 1;
|
||||
padding-inline-start: calc(16px + var(--space-2));
|
||||
margin-block-end: var(--space-1);
|
||||
}
|
||||
}
|
||||
.grow {
|
||||
flex: 1;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/** Dialog stack of the analysis feature and the shared "Specify Scope" fields. */
|
||||
import { Fragment, type ReactNode } from "react";
|
||||
import clsx from "clsx";
|
||||
import { create } from "zustand";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { isTauri } from "@/platform/ipc";
|
||||
import { EDIT_SCOPES_ACTION, useCustomScopeList } from "@/platform/search";
|
||||
import { Button, IconButton, Input, Select, T } from "@/ui";
|
||||
import { Button, IconButton, Input, Radio, Select, T } from "@/ui";
|
||||
import { SCOPE_LABELS, currentFile, type ScopeChoice, type ScopeKind } from "./scope";
|
||||
import styles from "./Analysis.module.css";
|
||||
|
||||
@@ -62,57 +63,69 @@ export function ScopeFields({
|
||||
}) {
|
||||
const file = currentFile();
|
||||
const scopes = useCustomScopeList();
|
||||
const custom = value.custom ?? scopes[0]?.name;
|
||||
return (
|
||||
<fieldset className={styles.scope}>
|
||||
<legend className={styles.fieldLabel}>
|
||||
<T>Scope</T>
|
||||
</legend>
|
||||
{kinds.map((kind) => (
|
||||
<label key={kind} className={styles.radioRow}>
|
||||
<input
|
||||
type="radio"
|
||||
name={name}
|
||||
checked={value.kind === kind}
|
||||
disabled={kind === "file" && !file}
|
||||
onChange={() =>
|
||||
onChange({ ...value, kind, custom: kind === "custom" ? (value.custom ?? scopes[0]?.name) : value.custom })
|
||||
}
|
||||
/>
|
||||
<span>{kind === "file" && file ? tx`File '${file.split("/").pop()}'` : tx(SCOPE_LABELS[kind])}</span>
|
||||
</label>
|
||||
))}
|
||||
{value.kind === "directory" && (
|
||||
<div className={styles.dirRow}>
|
||||
<Input
|
||||
aria-label="Directory"
|
||||
value={value.directory}
|
||||
onChange={(e) => onChange({ ...value, directory: e.target.value })}
|
||||
className={styles.grow}
|
||||
/>
|
||||
<Button
|
||||
onClick={() => void browseDirectory(value.directory).then((d) => d && onChange({ ...value, directory: d }))}
|
||||
>
|
||||
<T>Browse…</T>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{value.kind === "custom" && (
|
||||
<div className={styles.dirRow}>
|
||||
<Select<string>
|
||||
className={styles.grow}
|
||||
value={value.custom ?? null}
|
||||
options={scopes.map((s) => ({ value: s.name, label: s.name, detail: s.pattern }))}
|
||||
placeholder="No custom scopes"
|
||||
onChange={(custom) => onChange({ ...value, custom })}
|
||||
aria-label="Custom scope"
|
||||
/>
|
||||
<IconButton
|
||||
icon="more-horizontal"
|
||||
title="Edit Scopes…"
|
||||
onClick={() => void executeAction(EDIT_SCOPES_ACTION, value.custom ? { select: value.custom } : undefined)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<div className={styles.scopeOptions}>
|
||||
{kinds.map((kind) => {
|
||||
const selected = value.kind === kind;
|
||||
return (
|
||||
<Fragment key={kind}>
|
||||
<Radio
|
||||
name={name}
|
||||
checked={selected}
|
||||
disabled={kind === "file" && !file}
|
||||
onChange={() => onChange({ ...value, kind, custom: kind === "custom" ? custom : value.custom })}
|
||||
label={
|
||||
kind === "file" && file ? <span>{tx`File '${file.split("/").pop()}'`}</span> : SCOPE_LABELS[kind]
|
||||
}
|
||||
className={clsx(styles.radioRow, (kind === "directory" || kind === "custom") && styles.scopeWithField)}
|
||||
/>
|
||||
{kind === "directory" && (
|
||||
<div className={styles.scopeControl}>
|
||||
<Input
|
||||
aria-label="Directory"
|
||||
value={value.directory}
|
||||
disabled={!selected}
|
||||
onChange={(e) => onChange({ ...value, directory: e.target.value })}
|
||||
className={styles.grow}
|
||||
/>
|
||||
<Button
|
||||
disabled={!selected}
|
||||
onClick={() =>
|
||||
void browseDirectory(value.directory).then((d) => d && onChange({ ...value, directory: d }))
|
||||
}
|
||||
>
|
||||
<T>Browse…</T>
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{kind === "custom" && (
|
||||
<div className={styles.scopeControl}>
|
||||
<Select<string>
|
||||
className={styles.grow}
|
||||
value={(selected ? value.custom : custom) ?? null}
|
||||
options={scopes.map((s) => ({ value: s.name, label: s.name, detail: s.pattern }))}
|
||||
placeholder={scopes.length ? "Choose a scope" : "No custom scopes"}
|
||||
disabled={!selected}
|
||||
onChange={(custom) => onChange({ ...value, custom })}
|
||||
aria-label="Custom scope"
|
||||
/>
|
||||
<IconButton
|
||||
icon="more-horizontal"
|
||||
title="Edit Scopes…"
|
||||
disabled={!selected}
|
||||
onClick={() => void executeAction(EDIT_SCOPES_ACTION, custom ? { select: custom } : undefined)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
mavenRoots,
|
||||
nodeIcon,
|
||||
nodeLabel,
|
||||
pluginCoordinates,
|
||||
profileChecked,
|
||||
withGradleOptions,
|
||||
gradleHasTestTask,
|
||||
@@ -310,6 +311,8 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
|
||||
</span>
|
||||
);
|
||||
}
|
||||
const plugin = node.kind === "plugin" ? node.plugin : null;
|
||||
const coordinates = plugin && `(${pluginCoordinates(plugin)})`;
|
||||
const detail =
|
||||
node.kind === "profiles" && node.projectRoot
|
||||
? node.projectRoot.split("/").pop()
|
||||
@@ -321,12 +324,24 @@ function NodeRow({ node, state }: { node: BuildNode; state: TreeRowState }) {
|
||||
const skipped =
|
||||
(mavenSkipTests && node.kind === "phase" && node.phase === "test") ||
|
||||
(gradleSkipTests && node.kind === "task" && node.task.name === "test");
|
||||
const label = (
|
||||
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
|
||||
{plugin?.prefix ?? nodeLabel(node)}
|
||||
</span>
|
||||
);
|
||||
return (
|
||||
<span className={styles.row}>
|
||||
<Icon name={nodeIcon(node)} size={16} className={styles.icon} />
|
||||
<span className={clsx(styles.label, state.selected && styles.selectedLabel, skipped && styles.skippedGoal)}>
|
||||
{nodeLabel(node)}
|
||||
</span>
|
||||
{coordinates ? (
|
||||
<span className={styles.pluginText}>
|
||||
{label}
|
||||
<span className={styles.detail} title={coordinates}>
|
||||
{coordinates}
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
label
|
||||
)}
|
||||
{detail && <span className={styles.detail}>{detail}</span>}
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -96,6 +96,18 @@
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.pluginText {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: var(--space-1-5);
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.pluginText > .label {
|
||||
flex: none;
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
.profile {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ export function dependencyLabel(d: MavenDependency): string {
|
||||
return parts.join(":");
|
||||
}
|
||||
|
||||
export function pluginLabel(p: MavenPlugin): string {
|
||||
return `${p.prefix} (${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""})`;
|
||||
export function pluginCoordinates(p: MavenPlugin): string {
|
||||
return `${p.groupId}:${p.artifactId}${p.version ? `:${p.version}` : ""}`;
|
||||
}
|
||||
|
||||
/** Profile choices in different workspace members are independent. */
|
||||
@@ -363,7 +363,7 @@ export function nodeLabel(node: BuildNode): string {
|
||||
case "plugins":
|
||||
return tx("Plugins");
|
||||
case "plugin":
|
||||
return pluginLabel(node.plugin);
|
||||
return `${node.plugin.prefix} (${pluginCoordinates(node.plugin)})`;
|
||||
case "goal":
|
||||
return `${node.plugin.prefix}:${node.goal}`;
|
||||
case "dependencies":
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { tx, txPart } from "@/platform/i18n";
|
||||
import { lockDragCursor } from "@/ui/dragCursor";
|
||||
import styles from "./Coverage.module.css";
|
||||
|
||||
export function ColumnDivider({
|
||||
title,
|
||||
width,
|
||||
min,
|
||||
max,
|
||||
onResize,
|
||||
onReset,
|
||||
}: {
|
||||
title: string;
|
||||
width: number;
|
||||
min: number;
|
||||
max: number;
|
||||
onResize: (width: number) => void;
|
||||
onReset: () => void;
|
||||
}) {
|
||||
const drag = useRef<{ x: number; width: number; pointerId: number; unlock: () => void } | null>(null);
|
||||
const stop = () => {
|
||||
drag.current?.unlock();
|
||||
drag.current = null;
|
||||
};
|
||||
useEffect(() => stop, []);
|
||||
|
||||
const resize = (next: number) => {
|
||||
const fitted = Math.round(Math.max(min, Math.min(max, next)));
|
||||
if (fitted !== width) onResize(fitted);
|
||||
};
|
||||
|
||||
return (
|
||||
<span
|
||||
className={styles.divider}
|
||||
role="separator"
|
||||
aria-orientation="vertical"
|
||||
aria-label={tx`Resize ${txPart(title)} column`}
|
||||
aria-valuemin={min}
|
||||
aria-valuemax={max}
|
||||
aria-valuenow={width}
|
||||
tabIndex={0}
|
||||
onPointerDown={(event) => {
|
||||
if (event.button !== 0 || drag.current) return;
|
||||
event.currentTarget.setPointerCapture(event.pointerId);
|
||||
drag.current = { x: event.clientX, width, pointerId: event.pointerId, unlock: lockDragCursor("col-resize") };
|
||||
}}
|
||||
onPointerMove={(event) => {
|
||||
const start = drag.current;
|
||||
if (start?.pointerId === event.pointerId) resize(start.width + start.x - event.clientX);
|
||||
}}
|
||||
onLostPointerCapture={stop}
|
||||
onDoubleClick={onReset}
|
||||
onKeyDown={(event) => {
|
||||
let next: number;
|
||||
switch (event.key) {
|
||||
case "ArrowLeft":
|
||||
next = width + 10;
|
||||
break;
|
||||
case "ArrowRight":
|
||||
next = width - 10;
|
||||
break;
|
||||
case "Home":
|
||||
next = min;
|
||||
break;
|
||||
case "End":
|
||||
next = max;
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
resize(next);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
.view {
|
||||
--coverage-metrics: 2;
|
||||
--coverage-metric-width: min(29cqi, 128px);
|
||||
--coverage-tracks: minmax(0, 1fr) var(--coverage-lines-width) var(--coverage-branches-width);
|
||||
--coverage-column-gap: var(--space-2);
|
||||
container-type: inline-size;
|
||||
height: 100%;
|
||||
@@ -10,6 +10,7 @@
|
||||
}
|
||||
.noBranches {
|
||||
--coverage-metrics: 1;
|
||||
--coverage-tracks: minmax(0, 1fr) var(--coverage-lines-width);
|
||||
}
|
||||
.tabs {
|
||||
min-width: 0;
|
||||
@@ -25,7 +26,7 @@
|
||||
.header,
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) repeat(var(--coverage-metrics), var(--coverage-metric-width));
|
||||
grid-template-columns: var(--coverage-tracks);
|
||||
align-items: center;
|
||||
column-gap: var(--coverage-column-gap);
|
||||
font-size: var(--fs-ui);
|
||||
@@ -44,9 +45,16 @@
|
||||
.header::-webkit-scrollbar {
|
||||
width: 10px;
|
||||
}
|
||||
.heading {
|
||||
position: relative;
|
||||
min-width: 0;
|
||||
height: 100%;
|
||||
}
|
||||
.headerCell {
|
||||
display: inline-flex;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
gap: var(--space-0-5);
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
@@ -63,13 +71,33 @@
|
||||
.headerCell svg {
|
||||
flex: none;
|
||||
}
|
||||
.divider {
|
||||
position: absolute;
|
||||
inset-block: 0;
|
||||
inset-inline-start: calc(-1 * var(--coverage-column-gap));
|
||||
width: var(--coverage-column-gap);
|
||||
cursor: col-resize;
|
||||
touch-action: none;
|
||||
}
|
||||
.divider::after {
|
||||
position: absolute;
|
||||
inset: var(--space-1) 50% var(--space-1) auto;
|
||||
width: 1px;
|
||||
background: var(--border);
|
||||
content: "";
|
||||
}
|
||||
.divider:hover::after,
|
||||
.divider:focus-visible::after,
|
||||
.divider:active::after {
|
||||
background: var(--accent);
|
||||
}
|
||||
.tree {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
/* Keep the chevron and icon in the name column at deeper levels. */
|
||||
--coverage-max-row-inset: max(
|
||||
4px,
|
||||
calc(100% - var(--coverage-metrics) * (var(--coverage-metric-width) + var(--coverage-column-gap)) - 72px)
|
||||
calc(100% - var(--coverage-stats-width) - var(--coverage-metrics) * var(--coverage-column-gap) - 72px)
|
||||
);
|
||||
}
|
||||
.row {
|
||||
@@ -99,16 +127,15 @@
|
||||
@container (width < 360px) {
|
||||
.header,
|
||||
.tree {
|
||||
--coverage-metric-width: min(23cqi, 65px);
|
||||
--coverage-column-gap: var(--space-1);
|
||||
}
|
||||
.count {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
}
|
||||
}
|
||||
.compactCount {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
}
|
||||
.link {
|
||||
padding: 0;
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
/** Coverage tool window: one tab per recent suite, a sortable tree of directories and files. */
|
||||
import { useMemo, useState } from "react";
|
||||
import { useEffect, useMemo, useState, type CSSProperties } from "react";
|
||||
import clsx from "clsx";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { EmptyState, Icon, IconButton, Tabs, Tree, fileIconName, T } from "@/ui";
|
||||
import { editorService } from "@/workbench/contributions";
|
||||
import { ColumnDivider } from "./ColumnDivider";
|
||||
import { coverageColumns, readCoverageWidths, saveCoverageWidths } from "./columns";
|
||||
import { coverageTree, formatPercent, sortTree, type CoverageNode, type SortKey } from "./model";
|
||||
import { activeSuite, closeSuite, selectSuite, setCoverageVisible, useCoverage } from "./store";
|
||||
import styles from "./Coverage.module.css";
|
||||
@@ -50,13 +52,13 @@ export function CoverageHeaderActions() {
|
||||
);
|
||||
}
|
||||
|
||||
function Metric({ covered, total }: { covered: number; total: number }) {
|
||||
function Metric({ covered, total, compact }: { covered: number; total: number; compact: boolean }) {
|
||||
const value = formatPercent(covered, total);
|
||||
const [percentage, count] = value.split(" ", 2);
|
||||
return (
|
||||
<span className={styles.value} title={value}>
|
||||
{percentage}
|
||||
{count && <span className={styles.count}> {count}</span>}
|
||||
{count && <span className={compact ? styles.compactCount : undefined}> {count}</span>}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
@@ -74,6 +76,16 @@ export function CoverageView() {
|
||||
const root = useProject((s) => s.project?.root ?? "");
|
||||
const [sort, setSort] = useState<{ key: SortKey; ascending: boolean }>({ key: "name", ascending: true });
|
||||
const [expanded, setExpanded] = useState<Set<string> | null>(null);
|
||||
const [pane, setPane] = useState<HTMLDivElement | null>(null);
|
||||
const [paneWidth, setPaneWidth] = useState(0);
|
||||
const [preferred, setPreferred] = useState(readCoverageWidths);
|
||||
useEffect(() => {
|
||||
if (!pane) return;
|
||||
const observer = new ResizeObserver(() => setPaneWidth(pane.clientWidth));
|
||||
observer.observe(pane);
|
||||
return () => observer.disconnect();
|
||||
}, [pane]);
|
||||
useEffect(() => saveCoverageWidths(preferred), [preferred]);
|
||||
|
||||
const roots = useMemo(
|
||||
() => (suite ? sortTree(coverageTree(suite.data, root), sort.key, sort.ascending) : []),
|
||||
@@ -103,11 +115,21 @@ export function CoverageView() {
|
||||
}
|
||||
const branches = suite.data.hasBranches;
|
||||
const columns = branches ? COLUMNS : COLUMNS.slice(0, 2);
|
||||
const { min, budget, widths } = coverageColumns(paneWidth, branches, preferred);
|
||||
const statsWidth = widths.lines + widths.branches;
|
||||
const columnStyle = {
|
||||
"--coverage-lines-width": `${widths.lines}px`,
|
||||
"--coverage-branches-width": `${widths.branches}px`,
|
||||
"--coverage-stats-width": `${statsWidth}px`,
|
||||
} as CSSProperties;
|
||||
const toggleSort = (key: SortKey) =>
|
||||
setSort((s) => (s.key === key ? { key, ascending: !s.ascending } : { key, ascending: key === "name" }));
|
||||
const resizeLines = (lines: number) =>
|
||||
setPreferred((old) => ({ ...old, lines, ...(branches && { branches: widths.branches }) }));
|
||||
const resizeBranches = (width: number) => setPreferred({ lines: statsWidth - width, branches: width });
|
||||
|
||||
return (
|
||||
<div className={clsx(styles.view, !branches && styles.noBranches)}>
|
||||
<div ref={setPane} className={clsx(styles.view, !branches && styles.noBranches)} style={columnStyle}>
|
||||
{!visible && (
|
||||
<div className={styles.banner}>
|
||||
<T>Coverage is hidden in editors and the project view.</T>
|
||||
@@ -115,18 +137,29 @@ export function CoverageView() {
|
||||
)}
|
||||
<div className={styles.header} role="row">
|
||||
{columns.map((c) => (
|
||||
<button
|
||||
key={c.key}
|
||||
type="button"
|
||||
role="columnheader"
|
||||
aria-sort={sort.key === c.key ? (sort.ascending ? "ascending" : "descending") : "none"}
|
||||
className={styles.headerCell}
|
||||
title={tx(c.label)}
|
||||
onClick={() => toggleSort(c.key)}
|
||||
>
|
||||
<span className={styles.label}>{tx(c.label)}</span>
|
||||
{sort.key === c.key && <Icon name={sort.ascending ? "chevron-up" : "chevron-down"} size={12} />}
|
||||
</button>
|
||||
<div className={styles.heading} key={c.key}>
|
||||
<button
|
||||
type="button"
|
||||
role="columnheader"
|
||||
aria-sort={sort.key === c.key ? (sort.ascending ? "ascending" : "descending") : "none"}
|
||||
className={styles.headerCell}
|
||||
title={tx(c.label)}
|
||||
onClick={() => toggleSort(c.key)}
|
||||
>
|
||||
<span className={styles.label}>{tx(c.label)}</span>
|
||||
{sort.key === c.key && <Icon name={sort.ascending ? "chevron-up" : "chevron-down"} size={12} />}
|
||||
</button>
|
||||
{c.key !== "name" && paneWidth > 0 && (
|
||||
<ColumnDivider
|
||||
title={c.label}
|
||||
width={widths[c.key]}
|
||||
min={min}
|
||||
max={c.key === "lines" ? budget - widths.branches : statsWidth - min}
|
||||
onResize={c.key === "lines" ? resizeLines : resizeBranches}
|
||||
onReset={() => setPreferred(branches ? {} : { branches: preferred.branches })}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Tree<CoverageNode>
|
||||
@@ -152,8 +185,8 @@ export function CoverageView() {
|
||||
{n.name}
|
||||
</span>
|
||||
</span>
|
||||
<Metric covered={n.linesCovered} total={n.linesTotal} />
|
||||
{branches && <Metric covered={n.branchesCovered} total={n.branchesTotal} />}
|
||||
<Metric covered={n.linesCovered} total={n.linesTotal} compact={widths.lines < 92} />
|
||||
{branches && <Metric covered={n.branchesCovered} total={n.branchesTotal} compact={widths.branches < 92} />}
|
||||
</span>
|
||||
)}
|
||||
empty={<EmptyState title="The report covers no files" />}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
type PreferredWidths = Partial<Record<"lines" | "branches", number>>;
|
||||
|
||||
const KEY = "openidea.coverage.columns";
|
||||
|
||||
export function readCoverageWidths(): PreferredWidths {
|
||||
try {
|
||||
const widths = JSON.parse(localStorage.getItem(KEY) ?? "null");
|
||||
const valid = (n: unknown) => (typeof n === "number" && Number.isFinite(n) && n > 0 ? n : undefined);
|
||||
return { lines: valid(widths?.lines), branches: valid(widths?.branches) };
|
||||
} catch {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
export function saveCoverageWidths(widths: PreferredWidths) {
|
||||
try {
|
||||
localStorage.setItem(KEY, JSON.stringify(widths));
|
||||
} catch {
|
||||
/* Storage may be unavailable. */
|
||||
}
|
||||
}
|
||||
|
||||
export function coverageColumns(pane: number, hasBranches: boolean, preferred: PreferredWidths) {
|
||||
const min = Math.min(52, Math.floor(pane / 5));
|
||||
const count = hasBranches ? 2 : 1;
|
||||
// Reserve space for the tree label, its icons and indentation, and the table gutters.
|
||||
const budget = Math.max(count * min, pane - 132);
|
||||
const auto = Math.round(pane < 360 ? Math.min(pane * 0.23, 65) : Math.min(pane * 0.29, 128));
|
||||
const lines = Math.min(budget, Math.max(min, preferred.lines ?? auto));
|
||||
const branches = hasBranches ? Math.min(budget, Math.max(min, preferred.branches ?? auto)) : 0;
|
||||
if (lines + branches <= budget) return { min, budget, widths: { lines, branches } };
|
||||
|
||||
// Fit saved widths proportionally on a smaller dock without changing the saved layout.
|
||||
const room = budget - min * count;
|
||||
const fittedLines = min + Math.round(((lines - min) / (lines + branches - min * count)) * room);
|
||||
return { min, budget, widths: { lines: fittedLines, branches: budget - fittedLines } };
|
||||
}
|
||||
@@ -241,7 +241,8 @@ describe("MemoryView", () => {
|
||||
expect(screen.getByRole("button", { name: "刷新内存视图" }).getAttribute("data-tooltip")).toBe("刷新内存视图");
|
||||
const filter = screen.getByRole("textbox", { name: "筛选类" });
|
||||
expect(filter.getAttribute("placeholder")).toBe("筛选类");
|
||||
expect(screen.getByRole("checkbox", { name: "仅显示有变化的" })).toBeTruthy();
|
||||
fireEvent.click(screen.getByRole("button", { name: "视图选项" }));
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: "仅显示有变化的" })).toBeInTheDocument();
|
||||
} finally {
|
||||
await setLocale("en");
|
||||
}
|
||||
@@ -299,10 +300,15 @@ describe("MemoryView", () => {
|
||||
expect(screen.getByText("Cache$Entry")).toBeTruthy();
|
||||
|
||||
fireEvent.change(screen.getByRole("textbox", { name: "Filter classes" }), { target: { value: "" } });
|
||||
fireEvent.click(screen.getByRole("checkbox", { name: "Changed only" }));
|
||||
const options = screen.getByRole("button", { name: "View Options" });
|
||||
fireEvent.click(options);
|
||||
fireEvent.click(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: false }));
|
||||
expect(screen.getByText("Heap$Live")).toBeTruthy();
|
||||
expect(screen.queryByText("Cache$Entry")).toBeNull();
|
||||
expect(screen.queryByText("Dup")).toBeNull();
|
||||
expect(options).toHaveAttribute("aria-pressed", "true");
|
||||
fireEvent.click(options);
|
||||
expect(screen.getByRole("menuitemcheckbox", { name: "Changed only", checked: true })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("sorts by the clicked column and reports it with aria-sort", async () => {
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
}
|
||||
|
||||
.filter {
|
||||
flex: 0 1 240px;
|
||||
min-width: 80px;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.banner,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** Memory tab of the Debug tool window: live instance counts per class of the debugged JVM, and heap capture. */
|
||||
import { useEffect, useMemo } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import { Checkbox, Icon, IconButton, Input, List, T } from "@/ui";
|
||||
import { Icon, IconButton, List, Menu, SearchField, T } from "@/ui";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import type { JvmClassRow, JvmMemorySnapshot } from "@/platform/ipc";
|
||||
@@ -112,6 +112,8 @@ export function MemoryView({ session }: { session: DebugSession }) {
|
||||
const id = session.id;
|
||||
const entry = useMemory((s) => s.bySession[id]);
|
||||
const query = entry?.query ?? DEFAULT_QUERY;
|
||||
const optionsButton = useRef<HTMLButtonElement>(null);
|
||||
const [optionsOpen, setOptionsOpen] = useState(false);
|
||||
const result = entry?.result ?? null;
|
||||
const snapshot = entry?.snapshot ?? null;
|
||||
const source = snapshot?.source ?? "histogram";
|
||||
@@ -161,17 +163,37 @@ export function MemoryView({ session }: { session: DebugSession }) {
|
||||
disabled={entry?.loading || !canRefresh}
|
||||
/>
|
||||
<HeapCaptureButton session={session} />
|
||||
<Input
|
||||
<SearchField
|
||||
className={styles.filter}
|
||||
value={query.filter}
|
||||
onChange={(e) => setMemoryQuery(id, { filter: e.target.value })}
|
||||
onChange={(filter) => setMemoryQuery(id, { filter })}
|
||||
placeholder="Filter classes"
|
||||
aria-label="Filter classes"
|
||||
/>
|
||||
<Checkbox
|
||||
checked={query.changedOnly}
|
||||
onChange={(changedOnly) => setMemoryQuery(id, { changedOnly })}
|
||||
label="Changed only"
|
||||
<IconButton
|
||||
ref={optionsButton}
|
||||
icon="settings"
|
||||
title="View Options"
|
||||
size="small"
|
||||
iconSize={16}
|
||||
pressed={query.changedOnly}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={optionsOpen}
|
||||
onClick={() => setOptionsOpen(!optionsOpen)}
|
||||
/>
|
||||
<Menu
|
||||
open={optionsOpen}
|
||||
onClose={() => setOptionsOpen(false)}
|
||||
anchor={optionsButton}
|
||||
placement="bottom-end"
|
||||
aria-label="View Options"
|
||||
items={[
|
||||
{
|
||||
label: "Changed only",
|
||||
checked: query.changedOnly,
|
||||
run: () => setMemoryQuery(id, { changedOnly: !query.changedOnly }),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
{backend && (
|
||||
|
||||
Reference in new issue
Block a user