All files / services/core workspace-service.interface.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                                                                                                                                         
import * as vscode from 'vscode';
 
/**
 * Describes a VS Code workspace file discovered in the project directory.
 */
export interface WorkspaceDescriptor {
	/**
	 * A unique identifier derived from the workspace filename (without the `.code-workspace` extension).
	 */
	readonly id: string;
 
	/**
	 * The URI of the workspace file.
	 */
	readonly uri: vscode.Uri;
 
	/**
	 * The absolute file system path of the workspace file.
	 */
	readonly absolutePath: string;
 
	/**
	 * The file system path relative to the project root, using forward slashes.
	 */
	readonly relativePath: string;
 
	/**
	 * The `mentor.workspace.rootOffset` setting from the workspace file, if present.
	 * A relative path from the `.code-workspace` file's directory to the monorepo root.
	 * Defaults to `undefined` when no offset is configured.
	 */
	readonly rootOffset: string | undefined;
 
	/**
	 * The resolved monorepo root URI computed from the workspace file location and `rootOffset`.
	 * When `rootOffset` is `undefined`, this is `undefined` as well.
	 */
	readonly rootUri: vscode.Uri | undefined;
}
 
/**
 * Service for discovering VS Code workspace files in the project directory
 * and providing fast access to their identifiers and paths.
 */
export interface IWorkspaceService {
	/**
	 * The resolved monorepo root URI for the currently active workspace.
	 * Derived from the active `.code-workspace` file's location and its `rootOffset` setting.
	 * `undefined` when no workspace file is active or no `rootOffset` is configured.
	 */
	readonly activeRootUri: vscode.Uri | undefined;
 
	/**
	 * All discovered workspace descriptors.
	 */
	readonly workspaces: ReadonlyArray<WorkspaceDescriptor>;
 
	/**
	 * Returns the workspace descriptor for the given ID, or `undefined` if not found.
	 * @param id The workspace identifier.
	 */
	getWorkspaceById(id: string): WorkspaceDescriptor | undefined;
 
	/**
	 * Discovers all `.code-workspace` files in the project directory and parses their settings.
	 */
	discoverWorkspaces(): Promise<void>;
}