дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
Opening another project in the same window left the previous project's state in module-level stores: Amend and the commit message carried over, debug sessions kept running, and Git Log, usages, hierarchy, inspection, HTTP client, recent locations, navigation history and notifications still showed the old project. Reset each of them on a project root change, stop the old debug sessions, ask about unsaved changes before leaving a project, close the settings window (it would apply to the new project) and end the indexing task when a scan is cancelled.
83 рядки
2.7 KiB
TypeScript
83 рядки
2.7 KiB
TypeScript
/**
|
|
* Code analysis: Inspect Code (batch language-server diagnostics), Locate
|
|
* Duplicates and Search / Replace Structurally.
|
|
*/
|
|
import { registerActions } from "@/platform/actions";
|
|
import { useProject } from "@/platform/project";
|
|
import { registerOverlay, registerToolWindow } from "@/workbench/contributions";
|
|
import { showDuplicatesDialog, showInspectCodeDialog, showStructuralDialog } from "./AnalysisDialogs";
|
|
import { AnalysisDialogHost } from "./dialogs";
|
|
import { resetDuplicates } from "./duplicates";
|
|
import { DuplicatesHeaderActions, DuplicatesView } from "./DuplicatesView";
|
|
import { resetInspection } from "./inspect";
|
|
import { InspectionHeaderActions, InspectionView } from "./InspectionView";
|
|
|
|
export function activate(): () => void {
|
|
const disposers = [
|
|
useProject.subscribe((s, prev) => {
|
|
if (s.project?.root === prev.project?.root) return;
|
|
resetInspection();
|
|
resetDuplicates();
|
|
}),
|
|
registerOverlay({ id: "analysis.dialogs", component: AnalysisDialogHost }),
|
|
registerToolWindow({
|
|
id: "inspection",
|
|
title: "Inspection Results",
|
|
icon: "toolwindow-inspection",
|
|
anchor: "bottom",
|
|
stripe: "onUse",
|
|
order: 36,
|
|
component: InspectionView,
|
|
headerActions: InspectionHeaderActions,
|
|
}),
|
|
registerToolWindow({
|
|
id: "duplicates",
|
|
title: "Duplicates",
|
|
icon: "toolwindow-duplicates",
|
|
anchor: "bottom",
|
|
stripe: "onUse",
|
|
order: 37,
|
|
component: DuplicatesView,
|
|
headerActions: DuplicatesHeaderActions,
|
|
}),
|
|
registerActions([
|
|
{
|
|
id: "analyze.inspectCode",
|
|
title: "Inspect Code…",
|
|
category: "Code",
|
|
icon: "toolwindow-inspection",
|
|
when: "projectOpen",
|
|
keywords: ["inspection", "analyze", "diagnostics", "problems"],
|
|
run: () => void showInspectCodeDialog(),
|
|
},
|
|
{
|
|
id: "analyze.locateDuplicates",
|
|
title: "Locate Duplicates…",
|
|
category: "Code",
|
|
when: "projectOpen",
|
|
keywords: ["duplicates", "clones", "copy paste", "cpd"],
|
|
run: () => void showDuplicatesDialog(),
|
|
},
|
|
{
|
|
id: "find.structural",
|
|
title: "Search Structurally…",
|
|
category: "Find",
|
|
icon: "search",
|
|
when: "projectOpen",
|
|
keywords: ["ssr", "structural search", "pattern", "ast"],
|
|
run: () => void showStructuralDialog(false),
|
|
},
|
|
{
|
|
id: "find.replaceStructural",
|
|
title: "Replace Structurally…",
|
|
category: "Find",
|
|
icon: "replace",
|
|
when: "projectOpen",
|
|
keywords: ["ssr", "structural replace", "pattern", "ast"],
|
|
run: () => void showStructuralDialog(true),
|
|
},
|
|
]),
|
|
];
|
|
return () => disposers.reverse().forEach((d) => d());
|
|
}
|