дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-08 19:02:17 +02:00
feat(java): add the "Serializable class without 'serialVersionUID'" inspection (#1401)
Settings › Editor › Inspections › Java gets the inspection, off by default. When on, jdtls's compiler reports the missing field and offers the add default/generated ID quick fixes. Built-in inspections can now be off by default, the backend resolves the profile in effect, the compiler-defaults file is named after the variant so jdtls restarts with it, and saving inspection settings reconfigures language servers. Fixes #1199
Цей коміт міститься в:
1 джерело
8a884b6362
коміт
11fd64f399
9 files changed
+156
-15
No files matched your search
@@ -15,7 +15,7 @@ import {
|
||||
type InspectionNode,
|
||||
} from "../pages/editor/inspectionsModel";
|
||||
import { splitPageTarget } from "../model/staging";
|
||||
import { validateInspections } from "@/platform/inspections";
|
||||
import { JAVA_SERIAL_VERSION_INSPECTION, validateInspections } from "@/platform/inspections";
|
||||
import { NATURAL_LANGUAGES_PAGE, SPELLING_PAGE } from "../pages/editor/spelling";
|
||||
import { INSPECTIONS_PAGE } from "../pages/editor/inspections";
|
||||
import { EDITOR_PAGES } from "../pages/editor";
|
||||
@@ -69,6 +69,7 @@ describe("inspections tree", () => {
|
||||
expect(tree.map((g) => g.name)).toEqual([
|
||||
"Cargo",
|
||||
"General",
|
||||
"Java",
|
||||
"JavaScript",
|
||||
"Other",
|
||||
"Proofreading",
|
||||
@@ -109,6 +110,19 @@ describe("inspections tree", () => {
|
||||
expect(checkState(o, python)).toBe("on");
|
||||
});
|
||||
|
||||
it("keeps an inspection that is off by default off until turned on", () => {
|
||||
const serial = find(tree, `Java/${JAVA_SERIAL_VERSION_INSPECTION}`)!;
|
||||
expect(checkState({}, serial)).toBe("off");
|
||||
let o = setEnabled({}, serial, true);
|
||||
expect(o).toEqual({ [JAVA_SERIAL_VERSION_INSPECTION]: { enabled: true } });
|
||||
expect(checkState(o, serial)).toBe("on");
|
||||
o = setEnabled(o, serial, false);
|
||||
expect(o).toEqual({});
|
||||
// Turning a whole group on or off only records what differs from each default.
|
||||
const java = find(tree, "group:Java")!;
|
||||
expect(setEnabled({}, java, true)).toEqual({ [JAVA_SERIAL_VERSION_INSPECTION]: { enabled: true } });
|
||||
});
|
||||
|
||||
it("keeps severity and enabled overrides independent", () => {
|
||||
let o = setLevel({}, "lsp:ruff", "error");
|
||||
o = setEnabled(o, find(tree, "Python/lsp:ruff")!, false);
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
INSPECTION_LEVELS,
|
||||
codeInspectionId,
|
||||
customProfileId,
|
||||
enabledByDefault,
|
||||
newProfileKey,
|
||||
overridesOf,
|
||||
producerInspectionId,
|
||||
@@ -159,7 +160,7 @@ export function inspectionIds(node: InspectionNode): string[] {
|
||||
return [...(node.id ? [node.id] : []), ...node.children.flatMap(inspectionIds)];
|
||||
}
|
||||
|
||||
export const isEnabled = (o: ProfileOverrides, id: string) => o[id]?.enabled !== false;
|
||||
export const isEnabled = (o: ProfileOverrides, id: string) => o[id]?.enabled ?? enabledByDefault(id);
|
||||
|
||||
export type CheckState = "on" | "off" | "mixed";
|
||||
|
||||
@@ -181,9 +182,12 @@ function withOverride(o: ProfileOverrides, id: string, patch: Partial<Inspection
|
||||
return next;
|
||||
}
|
||||
|
||||
/** Turns a node and all its descendants on or off (on is the default, so it removes the override). */
|
||||
/** Turns a node and all its descendants on or off; an inspection back at its default drops the override. */
|
||||
export function setEnabled(o: ProfileOverrides, node: InspectionNode, enabled: boolean): ProfileOverrides {
|
||||
return inspectionIds(node).reduce((acc, id) => withOverride(acc, id, { enabled: enabled ? undefined : false }), o);
|
||||
return inspectionIds(node).reduce(
|
||||
(acc, id) => withOverride(acc, id, { enabled: enabled === enabledByDefault(id) ? undefined : enabled }),
|
||||
o,
|
||||
);
|
||||
}
|
||||
|
||||
/** `undefined` restores the default ("As reported"). */
|
||||
|
||||
Reference in new issue
Заблокувати користувача