Файли
openidea/src/platform/ignoredNames.ts
T
l0ng-ai f179c970ba feat(python): Extract Method, Inline and Introduce Parameter through pylsp-rope (#3665)
pylsp with pylsp-rope runs next to the Python type checker for refactorings only (features = code-action, code-action-kinds = refactor, every pylsp plugin off): Extract Method, Inline, Introduce Parameter and module-level Introduce Constant in Python files, with rope's "including similar statements" as the all-occurrences choice. pylsp-rope is a managed companion tool, not offered for install when missing; .ropeproject is in the default ignored names.

Refs #901
2026-11-16 12:39:35 +08:00

51 рядки
1.4 KiB
TypeScript

/** "Ignored Files and Folders" (`files.ignoredNames`): names hidden everywhere; mirrors `ide_core::ignored`. */
import { useProject } from "./project";
/** Defaults of `ide_core::ignored::DEFAULT_IGNORED_NAMES`; used until settings load. */
export const DEFAULT_IGNORED_NAMES: readonly string[] = [
"*.pyc",
"*.pyo",
"*.rbc",
"*.yarb",
"*~",
".DS_Store",
".git",
".hg",
".jj",
".ropeproject",
".svn",
"CVS",
"__pycache__",
"_svn",
"vssver.scc",
"vssver2.scc",
"Thumbs.db",
"desktop.ini",
];
let cached: { names: readonly string[]; exact: Set<string>; wildcards: RegExp[] } | null = null;
function compile(names: readonly string[]) {
const exact = new Set<string>();
const wildcards: RegExp[] = [];
for (const raw of names) {
const n = raw.trim();
if (!n || n.includes("/")) continue;
if (!/[*?]/.test(n)) exact.add(n);
else {
const body = n
.replace(/[.+^${}()|[\]\\]/g, "\\$&")
.replace(/\*/g, ".*")
.replace(/\?/g, ".");
wildcards.push(new RegExp(`^${body}$`, "s"));
}
}
return { names, exact, wildcards };
}
export function isIgnoredName(name: string): boolean {
const names = useProject.getState().settings?.files?.ignoredNames ?? DEFAULT_IGNORED_NAMES;
const m = cached?.names === names ? cached : (cached = compile(names));
return m.exact.has(name) || m.wildcards.some((re) => re.test(name));
}