mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
9d4592c72f
## Summary - reject JS plugins whose normalized names collide - keep registered plugin names isolated per LSP workspace - add a CLI regression fixture covering two plugins that expose the same rule name Fixes #25164
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { setCwd } from "./context.ts";
|
|
import { setRegisteredPluginNames, setRegisteredRules } from "./load.ts";
|
|
import { setAllOptions } from "./options.ts";
|
|
import {
|
|
workspaces,
|
|
currentWorkspace,
|
|
currentWorkspaceUri,
|
|
setCurrentWorkspace,
|
|
} from "../workspace/index.ts";
|
|
import { debugAssertIsNonNull } from "../utils/asserts.ts";
|
|
|
|
export { currentWorkspace };
|
|
|
|
export function switchWorkspace(workspaceUri: string): void {
|
|
// If requested workspace is already the current one, nothing to do.
|
|
//
|
|
// This is a fast path for common cases:
|
|
// 1. Only a single workspace exists (most common).
|
|
// 2. When user does have multiple workspaces, but works in one workspace for a lengthy period.
|
|
if (currentWorkspaceUri === workspaceUri) return;
|
|
|
|
// Get workspace
|
|
const workspace = workspaces.get(workspaceUri);
|
|
debugAssertIsNonNull(workspace, `Workspace "${workspaceUri}" does not exist`);
|
|
|
|
// Change global state to that of the workspace
|
|
setCwd(workspace.cwd);
|
|
setRegisteredRules(workspace.rules);
|
|
setRegisteredPluginNames(workspace.pluginNames);
|
|
setAllOptions(workspace.allOptions);
|
|
|
|
// Set this workspace as the current one
|
|
setCurrentWorkspace(workspace, workspaceUri);
|
|
}
|