дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
A folder whose top level holds a .uproject is now an Unreal project. The Project tool window switches to an Unreal view: Source is a source root, Config a resources root, and Binaries, Intermediate, Saved and DerivedDataCache are excluded from the tree, index, search and file watching even before Unreal creates them. The root label names the engine the project's EngineAssociation resolves to (HKCU Builds / HKLM InstalledDirectory on Windows; a registered directory that no longer exists is dropped), and three run configurations start UnrealEditor with the project as the editor, as a game (-game) or as a dedicated server (-server), debugged through lldb-dap. Nested projects are detected like Godot and Flutter ones, and the .NET detector skips the same generated directories case-insensitively. Also sets the new field in the remote_dev test ProjectInfo and keeps "Unreal Engine" and the .uproject placeholder in English in the catalogs. Co-authored-by: fengling375 <[email protected]>
61 рядки
3.0 KiB
TypeScript
61 рядки
3.0 KiB
TypeScript
/** Root build/SDK markers only; no dependency parsing or tool execution. */
|
|
import type { IconName } from "./icons";
|
|
|
|
type Marker = string | RegExp;
|
|
interface ProjectTypeDefinition {
|
|
name: string;
|
|
icon: IconName;
|
|
markers: readonly Marker[];
|
|
requires?: readonly string[];
|
|
}
|
|
|
|
// Add project types here: icons, detection, sorting and refresh all use this registry.
|
|
// The first match wins; put specific SDK/build markers before their generic fallback.
|
|
export const PROJECT_TYPES = {
|
|
flutter: { name: "Flutter", icon: "project-flutter", markers: ["pubspec.yaml"], requires: [".metadata"] },
|
|
dart: { name: "Dart", icon: "file-dart", markers: ["pubspec.yaml"] },
|
|
vite: { name: "Vite", icon: "project-vite", markers: [/^vite\.config\.[cm]?[jt]s$/], requires: ["package.json"] },
|
|
gradle: {
|
|
name: "Gradle",
|
|
icon: "gradle-project",
|
|
markers: ["build.gradle.kts", "build.gradle", "settings.gradle.kts", "settings.gradle"],
|
|
},
|
|
maven: { name: "Maven", icon: "maven-project", markers: ["pom.xml"] },
|
|
go: { name: "Go", icon: "file-go", markers: ["go.mod", "go.work"] },
|
|
cargo: { name: "Cargo", icon: "file-cargo", markers: ["Cargo.toml"] },
|
|
python: {
|
|
name: "Python",
|
|
icon: "file-python",
|
|
markers: ["pyproject.toml", "requirements.txt", "Pipfile", "setup.py", "setup.cfg"],
|
|
},
|
|
node: { name: "Node.js", icon: "file-npm", markers: ["package.json"] },
|
|
php: { name: "PHP", icon: "file-php", markers: ["composer.json"] },
|
|
ruby: { name: "Ruby", icon: "file-ruby", markers: ["Gemfile"] },
|
|
swift: { name: "Swift", icon: "file-swift", markers: ["Package.swift"] },
|
|
zig: { name: "Zig", icon: "file-zig", markers: ["build.zig"] },
|
|
godot: { name: "Godot", icon: "file-godot", markers: ["project.godot"] },
|
|
cmake: { name: "CMake", icon: "file-cmake", markers: ["CMakeLists.txt"] },
|
|
make: { name: "Make", icon: "file-makefile", markers: ["Makefile", "makefile", "GNUmakefile"] },
|
|
// Before .NET: the `.sln` a UE project generates belongs to the project, not to C#.
|
|
unreal: { name: "Unreal Engine", icon: "file-cpp", markers: [/^[^/]+\.uproject$/i] },
|
|
dotnet: { name: ".NET", icon: "file-csharp", markers: [/^[^/]+\.(?:[cf]sproj|slnx?)$/i] },
|
|
} as const satisfies Record<string, ProjectTypeDefinition>;
|
|
|
|
export type ProjectType = keyof typeof PROJECT_TYPES;
|
|
const definitions = Object.entries(PROJECT_TYPES) as [ProjectType, ProjectTypeDefinition][];
|
|
const matches = (name: string, marker: Marker) => (typeof marker === "string" ? name === marker : marker.test(name));
|
|
|
|
export function isProjectMarker(name: string): boolean {
|
|
return definitions.some(
|
|
([, type]) => type.markers.some((marker) => matches(name, marker)) || type.requires?.includes(name),
|
|
);
|
|
}
|
|
|
|
export function detectProjectType(files: ReadonlySet<string>): ProjectType | null {
|
|
for (const [id, type] of definitions) {
|
|
if (type.requires?.some((name) => !files.has(name))) continue;
|
|
if (type.markers.some((marker) => [...files].some((name) => matches(name, marker)))) return id;
|
|
}
|
|
return null;
|
|
}
|