Skip to content

Commit

Permalink
workspace - make most properties readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Feb 9, 2022
1 parent 6578cb2 commit 99cfdd5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 42 deletions.
26 changes: 14 additions & 12 deletions src/vs/platform/workspace/common/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface IWorkspaceContextService extends IWorkspaceFolderProvider {
}

export interface IResolvedWorkspace extends IWorkspaceIdentifier, IBaseWorkspace {
folders: IWorkspaceFolder[];
readonly folders: IWorkspaceFolder[];
}

export interface IBaseWorkspace {
Expand All @@ -86,7 +86,7 @@ export interface IBaseWorkspace {
* If present, marks the window that opens the workspace
* as a remote window with the given authority.
*/
remoteAuthority?: string;
readonly remoteAuthority?: string;

/**
* Transient workspaces are meant to go away after being used
Expand All @@ -95,7 +95,7 @@ export interface IBaseWorkspace {
*
* See: https://github.com/microsoft/vscode/issues/119695
*/
transient?: boolean;
readonly transient?: boolean;
}

export interface IBaseWorkspaceIdentifier {
Expand All @@ -105,7 +105,7 @@ export interface IBaseWorkspaceIdentifier {
* has a unique identifier. It is not possible to open
* a workspace with the same `id` in multiple windows
*/
id: string;
readonly id: string;
}

/**
Expand All @@ -116,7 +116,7 @@ export interface ISingleFolderWorkspaceIdentifier extends IBaseWorkspaceIdentifi
/**
* Folder path as `URI`.
*/
uri: URI;
readonly uri: URI;
}

/**
Expand Down Expand Up @@ -169,11 +169,11 @@ export function isWorkspaceIdentifier(obj: unknown): obj is IWorkspaceIdentifier
}

export interface ISerializedSingleFolderWorkspaceIdentifier extends IBaseWorkspaceIdentifier {
uri: UriComponents;
readonly uri: UriComponents;
}

export interface ISerializedWorkspaceIdentifier extends IBaseWorkspaceIdentifier {
configPath: UriComponents;
readonly configPath: UriComponents;
}

export function reviveIdentifier(identifier: undefined): undefined;
Expand Down Expand Up @@ -210,9 +210,11 @@ export const enum WorkbenchState {
}

export interface IWorkspaceFoldersWillChangeEvent {
join(promise: Promise<void>): void;

readonly changes: IWorkspaceFoldersChangeEvent;
readonly fromCache: boolean;

join(promise: Promise<void>): void;
}

export interface IWorkspaceFoldersChangeEvent {
Expand Down Expand Up @@ -363,20 +365,20 @@ export class Workspace implements IWorkspace {
}

export interface IRawFileWorkspaceFolder {
path: string;
readonly path: string;
name?: string;
}

export interface IRawUriWorkspaceFolder {
uri: string;
readonly uri: string;
name?: string;
}

export class WorkspaceFolder implements IWorkspaceFolder {

readonly uri: URI;
name: string;
index: number;
readonly name: string;
readonly index: number;

constructor(
data: IWorkspaceFolderData,
Expand Down
60 changes: 30 additions & 30 deletions src/vs/platform/workspaces/common/workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,21 @@ export interface IRecentlyOpened {
export type IRecent = IRecentWorkspace | IRecentFolder | IRecentFile;

export interface IRecentWorkspace {
workspace: IWorkspaceIdentifier;
readonly workspace: IWorkspaceIdentifier;
label?: string;
remoteAuthority?: string;
readonly remoteAuthority?: string;
}

export interface IRecentFolder {
folderUri: URI;
readonly folderUri: URI;
label?: string;
remoteAuthority?: string;
readonly remoteAuthority?: string;
}

export interface IRecentFile {
fileUri: URI;
readonly fileUri: URI;
label?: string;
remoteAuthority?: string;
readonly remoteAuthority?: string;
}

export function isRecentWorkspace(curr: IRecent): curr is IRecentWorkspace {
Expand All @@ -86,13 +86,13 @@ export function isRecentFile(curr: IRecent): curr is IRecentFile {
//#region Backups

export interface IWorkspaceBackupInfo {
workspace: IWorkspaceIdentifier;
remoteAuthority?: string;
readonly workspace: IWorkspaceIdentifier;
readonly remoteAuthority?: string;
}

export interface IFolderBackupInfo {
folderUri: URI;
remoteAuthority?: string;
readonly folderUri: URI;
readonly remoteAuthority?: string;
}

export function isFolderBackupInfo(curr: IWorkspaceBackupInfo | IFolderBackupInfo): curr is IFolderBackupInfo {
Expand Down Expand Up @@ -130,18 +130,18 @@ export interface IStoredWorkspace extends IBaseWorkspace {
}

export interface IWorkspaceFolderCreationData {
uri: URI;
name?: string;
readonly uri: URI;
readonly name?: string;
}

export interface IUntitledWorkspaceInfo {
workspace: IWorkspaceIdentifier;
remoteAuthority?: string;
readonly workspace: IWorkspaceIdentifier;
readonly remoteAuthority?: string;
}

export interface IEnterWorkspaceResult {
workspace: IWorkspaceIdentifier;
backupPath?: string;
readonly workspace: IWorkspaceIdentifier;
readonly backupPath?: string;
}

/**
Expand Down Expand Up @@ -298,35 +298,35 @@ export function useSlashForPath(storedFolders: IStoredWorkspaceFolder[]): boolea
//#region Workspace Storage

interface ISerializedRecentWorkspace {
workspace: {
readonly workspace: {
id: string;
configPath: string;
};
label?: string;
remoteAuthority?: string;
readonly label?: string;
readonly remoteAuthority?: string;
}

interface ISerializedRecentFolder {
folderUri: string;
label?: string;
remoteAuthority?: string;
readonly folderUri: string;
readonly label?: string;
readonly remoteAuthority?: string;
}

interface ISerializedRecentFile {
fileUri: string;
label?: string;
remoteAuthority?: string;
readonly fileUri: string;
readonly label?: string;
readonly remoteAuthority?: string;
}

interface ISerializedRecentlyOpenedLegacy {
workspaces3: Array<{ id: string; configURIPath: string } | string>; // workspace or URI.toString() // added in 1.32
workspaceLabels?: Array<string | null>; // added in 1.33
files2: string[]; // files as URI.toString() // added in 1.32
fileLabels?: Array<string | null>; // added in 1.33
readonly workspaces3: Array<{ id: string; configURIPath: string } | string>; // workspace or URI.toString() // added in 1.32
readonly workspaceLabels?: Array<string | null>; // added in 1.33
readonly files2: string[]; // files as URI.toString() // added in 1.32
readonly fileLabels?: Array<string | null>; // added in 1.33
}

interface ISerializedRecentlyOpened {
entries: Array<ISerializedRecentWorkspace | ISerializedRecentFolder | ISerializedRecentFile>; // since 1.55
readonly entries: Array<ISerializedRecentWorkspace | ISerializedRecentFolder | ISerializedRecentFile>; // since 1.55
}

export type RecentlyOpenedStorageData = object;
Expand Down

0 comments on commit 99cfdd5

Please sign in to comment.