дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Clears the no-await-in-loop diagnostics in analysis, platform, project-tree, http-client and debugger and turns the rule on there. Independent directory walks (Reformat/cleanup targets, batches of 8; the result is sorted as before), Spring config reads (parsed in candidate order, so the first file with a value still wins) and Python package __init__.py creation now run in parallel; every other loop is intentionally sequential and carries a documented suppression. Co-authored-by: akbar1214 <[email protected]>
60 рядки
2.6 KiB
TypeScript
60 рядки
2.6 KiB
TypeScript
/** "Mark Directory as" (project view context menu): edits Settings › Project Structure. */
|
||
import { call, commands, isTauri } from "@/platform/ipc";
|
||
import {
|
||
PROJECT_STRUCTURE_KEYS,
|
||
effectiveRoots,
|
||
markFolder,
|
||
rootRole,
|
||
validateProjectStructure,
|
||
type FolderRole,
|
||
} from "@/platform/languageSettings";
|
||
import { attachedProjectOf, currentDetectedRoots, currentRoots } from "@/platform/projectRoots";
|
||
import { loadSettings, relativePath, useProject } from "@/platform/project";
|
||
|
||
/** Effective role of the folder: marked by the user or detected from a build file. */
|
||
export function directoryRole(path: string): FolderRole | null {
|
||
const { project } = useProject.getState();
|
||
if (!project) return null;
|
||
const attached = attachedProjectOf(path);
|
||
if (attached) {
|
||
return rootRole(effectiveRoots(attached.detected, attached.structure), relativePath(attached.root, path));
|
||
}
|
||
return rootRole(currentRoots(), relativePath(project.root, path));
|
||
}
|
||
|
||
/**
|
||
* Gives `path` the `role` (null = Unmark); written to the project's `.openidea/settings.toml`.
|
||
* Unmarking a root detected from a build file keeps it unmarked across re-detection.
|
||
*/
|
||
export async function markDirectory(path: string, role: FolderRole | null): Promise<void> {
|
||
const { project, settings } = useProject.getState();
|
||
if (!project || !isTauri()) return;
|
||
// A project attached to this one keeps its marks in its own settings.
|
||
const attached = attachedProjectOf(path);
|
||
if (attached) {
|
||
const rel = relativePath(attached.root, path);
|
||
if (rel === path) return;
|
||
const next = markFolder(attached.structure, rel, role, attached.detected);
|
||
for (const key of PROJECT_STRUCTURE_KEYS) {
|
||
if (JSON.stringify(attached.structure[key]) !== JSON.stringify(next[key])) {
|
||
// oxlint-disable-next-line no-await-in-loop -- settings keys are written in order to the same member settings
|
||
await call(
|
||
commands.projectWorkspaceMemberSet(attached.root, `projectStructure.${key}`, JSON.stringify(next[key])),
|
||
);
|
||
}
|
||
}
|
||
return;
|
||
}
|
||
const rel = relativePath(project.root, path);
|
||
if (rel === path) return;
|
||
const before = validateProjectStructure(settings?.projectStructure);
|
||
const next = markFolder(before, rel, role, currentDetectedRoots());
|
||
for (const key of PROJECT_STRUCTURE_KEYS) {
|
||
if (JSON.stringify(before[key]) !== JSON.stringify(next[key])) {
|
||
// oxlint-disable-next-line no-await-in-loop -- settings keys are written in order to the same project settings
|
||
await call(commands.settingsSet("project", `projectStructure.${key}`, JSON.stringify(next[key])));
|
||
}
|
||
}
|
||
await loadSettings();
|
||
}
|