From 81e1e9b8db5182056bc2a1966ea2f75c61465670 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Mon, 3 Jul 2017 17:07:05 +0200 Subject: [PATCH] getWorkspace2 => getWorkspace --- src/vs/base/common/labels.ts | 4 ++-- src/vs/editor/standalone/browser/simpleServices.ts | 4 ++-- .../storage/test/common/storageService.test.ts | 14 +++++++------- src/vs/platform/workspace/common/workspace.ts | 4 ++-- .../api/electron-browser/mainThreadWorkspace.ts | 4 ++-- .../browser/parts/titlebar/titlebarPart.ts | 2 +- src/vs/workbench/common/resources.ts | 2 +- src/vs/workbench/electron-browser/extensionHost.ts | 2 +- .../electron-browser/debugConfigurationManager.ts | 8 ++++---- .../parts/debug/electron-browser/debugService.ts | 4 ++-- .../parts/emmet/electron-browser/emmetActions.ts | 2 +- .../parts/extensions/browser/extensionsActions.ts | 2 +- .../parts/files/browser/explorerViewlet.ts | 2 +- .../files/browser/fileActions.contribution.ts | 2 +- .../parts/files/browser/views/explorerView.ts | 4 ++-- .../parts/files/browser/views/explorerViewer.ts | 6 +++--- .../workbench/parts/files/common/explorerModel.ts | 2 +- .../parts/output/common/outputLinkProvider.ts | 4 ++-- .../electron-browser/relauncher.contribution.ts | 4 ++-- .../parts/search/browser/openFileHandler.ts | 4 ++-- .../parts/search/browser/searchViewlet.ts | 6 +++--- .../tasks/electron-browser/task.contribution.ts | 2 +- .../parts/tasks/node/processRunnerDetector.ts | 2 +- .../electron-browser/terminalLinkHandler.ts | 4 ++-- .../welcome/page/electron-browser/welcomePage.ts | 2 +- .../services/configuration/node/configuration.ts | 4 ++-- .../node/configurationEditingService.ts | 2 +- .../node/configurationResolverService.ts | 2 +- .../services/files/electron-browser/fileService.ts | 2 +- .../workbench/services/files/node/fileService.ts | 6 +++--- .../files/node/watcher/nsfw/watcherService.ts | 2 +- .../files/node/watcher/unix/watcherService.ts | 2 +- .../files/node/watcher/win32/watcherService.ts | 2 +- .../workbench/services/history/browser/history.ts | 2 +- .../services/telemetry/common/workspaceStats.ts | 4 ++-- .../textfile/common/textFileEditorModel.ts | 2 +- .../workspace/node/workspaceEditingService.ts | 6 +++--- src/vs/workbench/test/workbenchTestServices.ts | 6 +++--- 38 files changed, 69 insertions(+), 69 deletions(-) diff --git a/src/vs/base/common/labels.ts b/src/vs/base/common/labels.ts index 172700a0811..02a57bfbca9 100644 --- a/src/vs/base/common/labels.ts +++ b/src/vs/base/common/labels.ts @@ -19,7 +19,7 @@ export interface ILabelProvider { export interface IRootProvider { getRoot(resource: URI): URI; - getWorkspace2(): { + getWorkspace(): { roots: URI[]; }; } @@ -40,7 +40,7 @@ export function getPathLabel(resource: URI | string, rootProvider?: IRootProvide // return early if we can resolve a relative path label from the root const baseResource = rootProvider ? rootProvider.getRoot(resource) : null; if (baseResource) { - const hasMultipleRoots = rootProvider.getWorkspace2().roots.length > 1; + const hasMultipleRoots = rootProvider.getWorkspace().roots.length > 1; let pathLabel: string; if (isEqual(baseResource.fsPath, resource.fsPath, !platform.isLinux /* ignorecase */)) { diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index b2fbe6c070e..b44d504ae8f 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -536,11 +536,11 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService { this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', roots: [this.legacyWorkspace.resource], name: this.legacyWorkspace.resource.fsPath }; } - public getWorkspace(): ILegacyWorkspace { + public getLegacyWorkspace(): ILegacyWorkspace { return this.legacyWorkspace; } - public getWorkspace2(): IWorkspace { + public getWorkspace(): IWorkspace { return this.workspace; } diff --git a/src/vs/platform/storage/test/common/storageService.test.ts b/src/vs/platform/storage/test/common/storageService.test.ts index 5eb5b89f1b2..c70b62ec900 100644 --- a/src/vs/platform/storage/test/common/storageService.test.ts +++ b/src/vs/platform/storage/test/common/storageService.test.ts @@ -22,14 +22,14 @@ suite('Workbench StorageSevice', () => { hasWorkspace: () => { return true; }, - getWorkspace2: () => { + getWorkspace: () => { return TestWorkspace; } }); }); test('Swap Data with undefined default value', () => { - let s = new StorageService(new InMemoryLocalStorage(), null, contextService.getWorkspace2()); + let s = new StorageService(new InMemoryLocalStorage(), null, contextService.getWorkspace()); s.swap('Monaco.IDE.Core.Storage.Test.swap', 'foobar', 'barfoo'); assert.strictEqual('foobar', s.get('Monaco.IDE.Core.Storage.Test.swap')); @@ -40,7 +40,7 @@ suite('Workbench StorageSevice', () => { }); test('Remove Data', () => { - let s = new StorageService(new InMemoryLocalStorage(), null, contextService.getWorkspace2()); + let s = new StorageService(new InMemoryLocalStorage(), null, contextService.getWorkspace()); s.store('Monaco.IDE.Core.Storage.Test.remove', 'foobar'); assert.strictEqual('foobar', s.get('Monaco.IDE.Core.Storage.Test.remove')); @@ -49,7 +49,7 @@ suite('Workbench StorageSevice', () => { }); test('Get Data, Integer, Boolean', () => { - let s = new StorageService(new InMemoryLocalStorage(), null, contextService.getWorkspace2()); + let s = new StorageService(new InMemoryLocalStorage(), null, contextService.getWorkspace()); assert.strictEqual(s.get('Monaco.IDE.Core.Storage.Test.get', StorageScope.GLOBAL, 'foobar'), 'foobar'); assert.strictEqual(s.get('Monaco.IDE.Core.Storage.Test.get', StorageScope.GLOBAL, ''), ''); @@ -84,14 +84,14 @@ suite('Workbench StorageSevice', () => { test('StorageSevice cleans up when workspace changes', () => { let storageImpl = new InMemoryLocalStorage(); let time = new Date().getTime(); - let s = new StorageService(storageImpl, null, contextService.getWorkspace2(), time); + let s = new StorageService(storageImpl, null, contextService.getWorkspace(), time); s.store('key1', 'foobar'); s.store('key2', 'something'); s.store('wkey1', 'foo', StorageScope.WORKSPACE); s.store('wkey2', 'foo2', StorageScope.WORKSPACE); - s = new StorageService(storageImpl, null, contextService.getWorkspace2(), time); + s = new StorageService(storageImpl, null, contextService.getWorkspace(), time); assert.strictEqual(s.get('key1', StorageScope.GLOBAL), 'foobar'); assert.strictEqual(s.get('key1', StorageScope.WORKSPACE, null), null); @@ -100,7 +100,7 @@ suite('Workbench StorageSevice', () => { assert.strictEqual(s.get('wkey1', StorageScope.WORKSPACE), 'foo'); assert.strictEqual(s.get('wkey2', StorageScope.WORKSPACE), 'foo2'); - s = new StorageService(storageImpl, null, contextService.getWorkspace2(), time + 100); + s = new StorageService(storageImpl, null, contextService.getWorkspace(), time + 100); assert.strictEqual(s.get('key1', StorageScope.GLOBAL), 'foobar'); assert.strictEqual(s.get('key1', StorageScope.WORKSPACE, null), null); diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 0c5daf8472f..f84cf1cfe9c 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -25,13 +25,13 @@ export interface IWorkspaceContextService { * Provides access to the workspace object the platform is running with. This may be null if the workbench was opened * without workspace (empty); */ - getWorkspace(): ILegacyWorkspace; + getLegacyWorkspace(): ILegacyWorkspace; /** * Provides access to the workspace object the platform is running with. This may be null if the workbench was opened * without workspace (empty); */ - getWorkspace2(): IWorkspace; + getWorkspace(): IWorkspace; /** * An event which fires on workspace roots change. diff --git a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts index 6aa919fe9eb..3a4fef5dd89 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts @@ -43,13 +43,13 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape { // --- workspace --- private _onDidChangeWorkspace(): void { - this._proxy.$acceptWorkspaceData(this._contextService.getWorkspace2()); + this._proxy.$acceptWorkspaceData(this._contextService.getWorkspace()); } // --- search --- $startSearch(include: string, exclude: string, maxResults: number, requestId: number): Thenable { - const workspace = this._contextService.getWorkspace2(); + const workspace = this._contextService.getWorkspace(); if (!workspace) { return undefined; } diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index ea796c96534..b6639f3e00e 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -183,7 +183,7 @@ export class TitlebarPart extends Part implements ITitleService { */ private doGetWindowTitle(): string { const input = this.editorService.getActiveEditorInput(); - const workspace = this.contextService.getWorkspace2(); + const workspace = this.contextService.getWorkspace(); // Compute root resource // Single Root Workspace: always the single root workspace in this case diff --git a/src/vs/workbench/common/resources.ts b/src/vs/workbench/common/resources.ts index 6acefead117..8aa7b0ff5a2 100644 --- a/src/vs/workbench/common/resources.ts +++ b/src/vs/workbench/common/resources.ts @@ -107,7 +107,7 @@ export class ResourceGlobMatcher { // Add excludes per workspaces that got added if (this.contextService.hasWorkspace()) { - this.contextService.getWorkspace2().roots.forEach(root => { + this.contextService.getWorkspace().roots.forEach(root => { const rootExcludes = this.globFn(root); if (!this.mapRootToExpressionConfig.has(root.toString()) || !objects.equals(this.mapRootToExpressionConfig.get(root.toString()), rootExcludes)) { changed = true; diff --git a/src/vs/workbench/electron-browser/extensionHost.ts b/src/vs/workbench/electron-browser/extensionHost.ts index 0caea478678..ed393c61a2d 100644 --- a/src/vs/workbench/electron-browser/extensionHost.ts +++ b/src/vs/workbench/electron-browser/extensionHost.ts @@ -288,7 +288,7 @@ export class ExtensionHostProcessWorker { enableProposedApiForAll: !this.environmentService.isBuilt || (!!this.environmentService.extensionDevelopmentPath && product.nameLong.indexOf('Insiders') >= 0), enableProposedApiFor: this.environmentService.args['enable-proposed-api'] || [] }, - workspace: this.contextService.getWorkspace2(), + workspace: this.contextService.getWorkspace(), extensions: extensionDescriptions, configuration: this.configurationService.getConfigurationData(), telemetryInfo diff --git a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts index 08edc9c7ff2..113db82a6ec 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugConfigurationManager.ts @@ -276,7 +276,7 @@ export class ConfigurationManager implements IConfigurationManager { return null; } - const config = this.configurationService.getConfiguration('launch', { resource: this.contextService.getWorkspace().resource }); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) + const config = this.configurationService.getConfiguration('launch', { resource: this.contextService.getLegacyWorkspace().resource }); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) if (!config || !config.compounds) { return null; } @@ -285,7 +285,7 @@ export class ConfigurationManager implements IConfigurationManager { } public getConfigurationNames(): string[] { - const config = this.contextService.hasWorkspace() ? this.configurationService.getConfiguration('launch', { resource: this.contextService.getWorkspace().resource }) : null; // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) + const config = this.contextService.hasWorkspace() ? this.configurationService.getConfiguration('launch', { resource: this.contextService.getLegacyWorkspace().resource }) : null; // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) if (!config || !config.configurations) { return []; } else { @@ -306,7 +306,7 @@ export class ConfigurationManager implements IConfigurationManager { return null; } - const config = this.configurationService.getConfiguration('launch', { resource: this.contextService.getWorkspace().resource }); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) + const config = this.configurationService.getConfiguration('launch', { resource: this.contextService.getLegacyWorkspace().resource }); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) if (!config || !config.configurations) { return null; } @@ -342,7 +342,7 @@ export class ConfigurationManager implements IConfigurationManager { } public get configFileUri(): uri { - return uri.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '/.vscode/launch.json')); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) + return uri.file(paths.join(this.contextService.getLegacyWorkspace().resource.fsPath, '/.vscode/launch.json')); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) } public openConfigFile(sideBySide: boolean, type?: string): TPromise { diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index 3918249f39b..88d59cd9fbc 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -408,7 +408,7 @@ export class DebugService implements debug.IDebugService { const process = this.viewModel.focusedProcess; if (process && session && process.getId() === session.getId() && strings.equalsIgnoreCase(process.configuration.type, 'extensionhost') && this.sessionStates.get(session.getId()) === debug.State.Running && process && this.contextService.hasWorkspace() && process.configuration.noDebug) { - this.windowsService.closeExtensionHostWindow(this.contextService.getWorkspace2().roots.map(r => r.fsPath)); + this.windowsService.closeExtensionHostWindow(this.contextService.getWorkspace().roots.map(r => r.fsPath)); } if (session && session.getId() === event.body.sessionId) { this.onSessionEnd(session); @@ -827,7 +827,7 @@ export class DebugService implements debug.IDebugService { watchExpressionsCount: this.model.getWatchExpressions().length, extensionName: `${adapter.extensionDescription.publisher}.${adapter.extensionDescription.name}`, isBuiltin: adapter.extensionDescription.isBuiltin, - launchJsonExists: this.contextService.hasWorkspace() && !!this.configurationService.getConfiguration('launch', { resource: this.contextService.getWorkspace().resource }) // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) + launchJsonExists: this.contextService.hasWorkspace() && !!this.configurationService.getConfiguration('launch', { resource: this.contextService.getLegacyWorkspace().resource }) // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29245) }); }).then(() => process, (error: any) => { if (error instanceof Error && error.message === 'Canceled') { diff --git a/src/vs/workbench/parts/emmet/electron-browser/emmetActions.ts b/src/vs/workbench/parts/emmet/electron-browser/emmetActions.ts index fb3323ae6c4..a4082ed27ef 100644 --- a/src/vs/workbench/parts/emmet/electron-browser/emmetActions.ts +++ b/src/vs/workbench/parts/emmet/electron-browser/emmetActions.ts @@ -292,7 +292,7 @@ export abstract class EmmetEditorAction extends EditorAction { const modeService = accessor.get(IModeService); const messageService = accessor.get(IMessageService); const contextService = accessor.get(IWorkspaceContextService); - const workspaceRoot = contextService.hasWorkspace() ? contextService.getWorkspace().resource.fsPath : ''; // TODO@Ramya (https://github.com/Microsoft/vscode/issues/29244) + const workspaceRoot = contextService.hasWorkspace() ? contextService.getLegacyWorkspace().resource.fsPath : ''; // TODO@Ramya (https://github.com/Microsoft/vscode/issues/29244) const telemetryService = accessor.get(ITelemetryService); const commandService = accessor.get(ICommandService); diff --git a/src/vs/workbench/parts/extensions/browser/extensionsActions.ts b/src/vs/workbench/parts/extensions/browser/extensionsActions.ts index 0020df64bd1..1b9cc797d1f 100644 --- a/src/vs/workbench/parts/extensions/browser/extensionsActions.ts +++ b/src/vs/workbench/parts/extensions/browser/extensionsActions.ts @@ -1224,7 +1224,7 @@ export class ConfigureWorkspaceRecommendedExtensionsAction extends Action { } private getOrCreateExtensionsFile(): TPromise<{ created: boolean, extensionsFileResource: URI }> { - const extensionsFileResource = URI.file(paths.join(this.contextService.getWorkspace().resource.fsPath, '.vscode', 'extensions.json')); // TODO@Sandeep (https://github.com/Microsoft/vscode/issues/29242) + const extensionsFileResource = URI.file(paths.join(this.contextService.getLegacyWorkspace().resource.fsPath, '.vscode', 'extensions.json')); // TODO@Sandeep (https://github.com/Microsoft/vscode/issues/29242) return this.fileService.resolveContent(extensionsFileResource).then(content => { return { created: false, extensionsFileResource }; diff --git a/src/vs/workbench/parts/files/browser/explorerViewlet.ts b/src/vs/workbench/parts/files/browser/explorerViewlet.ts index d7d132a5856..a20a0f0d3a3 100644 --- a/src/vs/workbench/parts/files/browser/explorerViewlet.ts +++ b/src/vs/workbench/parts/files/browser/explorerViewlet.ts @@ -110,7 +110,7 @@ export class ExplorerViewlet extends ComposedViewsViewlet { private createExplorerViewDescriptor(): IViewDescriptor { return { id: ExplorerView.ID, - name: this.contextService.getWorkspace2().name, + name: this.contextService.getWorkspace().name, location: ViewLocation.Explorer, ctor: ExplorerView, order: 1 diff --git a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts index 121aaf6c8e9..f2dbf17b792 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.contribution.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.contribution.ts @@ -95,7 +95,7 @@ class FilesViewerActionContributor extends ActionBarContributor { let action: Action = this.instantiationService.createInstance(AddRootFolderAction, AddRootFolderAction.ID, AddRootFolderAction.LABEL); action.order = 52; actions.push(action); - if (this.contextService.getWorkspace2().roots.length > 1) { + if (this.contextService.getWorkspace().roots.length > 1) { action = this.instantiationService.createInstance(RemoveRootFolderAction, stat.resource, RemoveRootFolderAction.ID, RemoveRootFolderAction.LABEL); action.order = 53; actions.push(action); diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 299505e21a8..c179c6865ee 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -132,7 +132,7 @@ export class ExplorerView extends CollapsibleView { const titleDiv = $('div.title').appendTo(container); const titleSpan = $('span').appendTo(titleDiv); const setHeader = () => { - const workspace = this.contextService.getWorkspace2(); + const workspace = this.contextService.getWorkspace(); const title = workspace.roots.map(root => labels.getPathLabel(root.fsPath, void 0, this.environmentService)).join(); titleSpan.text(this.name).title(title); }; @@ -143,7 +143,7 @@ export class ExplorerView extends CollapsibleView { } public get name(): string { - const workspace = this.contextService.getWorkspace2(); + const workspace = this.contextService.getWorkspace(); return workspace.roots.length === 1 ? workspace.name : nls.localize('folders', "Folders"); } diff --git a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts index eb189012f91..29611199838 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerViewer.ts @@ -574,7 +574,7 @@ export class FileFilter implements IFilter { public updateConfiguration(): boolean { let needsRefresh = false; - this.contextService.getWorkspace2().roots.forEach(root => { + this.contextService.getWorkspace().roots.forEach(root => { const configuration = this.configurationService.getConfiguration(undefined, { resource: root }); const excludesConfig = (configuration && configuration.files && configuration.files.exclude) || Object.create(null); needsRefresh = needsRefresh || !objects.equals(this.hiddenExpressionPerRoot.get(root.toString()), excludesConfig); @@ -641,7 +641,7 @@ export class FileDragAndDrop implements IDragAndDrop { } public getDragURI(tree: ITree, stat: FileStat): string { - if (this.contextService.getWorkspace2().roots.some(r => r.toString() === stat.resource.toString())) { + if (this.contextService.getWorkspace().roots.some(r => r.toString() === stat.resource.toString())) { return null; // Can not move root folder } if (stat.isDirectory) { @@ -744,7 +744,7 @@ export class FileDragAndDrop implements IDragAndDrop { return fromDesktop || isCopy ? DRAG_OVER_ACCEPT_BUBBLE_DOWN_COPY(true) : DRAG_OVER_ACCEPT_BUBBLE_DOWN(true); } - const workspace = this.contextService.getWorkspace2(); + const workspace = this.contextService.getWorkspace(); if (workspace && workspace.roots.every(r => r.toString() !== target.resource.toString())) { return fromDesktop || isCopy ? DRAG_OVER_ACCEPT_BUBBLE_UP_COPY : DRAG_OVER_ACCEPT_BUBBLE_UP; } diff --git a/src/vs/workbench/parts/files/common/explorerModel.ts b/src/vs/workbench/parts/files/common/explorerModel.ts index b8b2cc531da..c92e951555a 100644 --- a/src/vs/workbench/parts/files/common/explorerModel.ts +++ b/src/vs/workbench/parts/files/common/explorerModel.ts @@ -25,7 +25,7 @@ export class Model { private _roots: FileStat[]; constructor( @IWorkspaceContextService private contextService: IWorkspaceContextService) { - const setRoots = () => this._roots = this.contextService.getWorkspace2().roots.map(uri => new FileStat(uri, undefined)); + const setRoots = () => this._roots = this.contextService.getWorkspace().roots.map(uri => new FileStat(uri, undefined)); this.contextService.onDidChangeWorkspaceRoots(() => setRoots()); setRoots(); } diff --git a/src/vs/workbench/parts/output/common/outputLinkProvider.ts b/src/vs/workbench/parts/output/common/outputLinkProvider.ts index b6a149eb2b4..abdd048bdad 100644 --- a/src/vs/workbench/parts/output/common/outputLinkProvider.ts +++ b/src/vs/workbench/parts/output/common/outputLinkProvider.ts @@ -55,7 +55,7 @@ export class OutputLinkProvider { } // Update link provider worker if workspace roots changed - const newWorkspacesCount = this.contextService.getWorkspace2().roots.length; + const newWorkspacesCount = this.contextService.getWorkspace().roots.length; if (this.workspacesCount !== newWorkspacesCount) { this.workspacesCount = newWorkspacesCount; @@ -80,7 +80,7 @@ export class OutputLinkProvider { if (!this.worker) { const createData: ICreateData = { - workspaceFolders: this.contextService.getWorkspace2().roots.map(root => root.toString()) + workspaceFolders: this.contextService.getWorkspace().roots.map(root => root.toString()) }; this.worker = createWebWorker(this.modelService, { diff --git a/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts b/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts index ee255342e96..9941724b56c 100644 --- a/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts +++ b/src/vs/workbench/parts/relauncher/electron-browser/relauncher.contribution.ts @@ -40,7 +40,7 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution { @IMessageService private messageService: IMessageService, @IWorkspaceContextService private contextService: IWorkspaceContextService ) { - this.rootCount = this.contextService.hasWorkspace() ? this.contextService.getWorkspace2().roots.length : 0; + this.rootCount = this.contextService.hasWorkspace() ? this.contextService.getWorkspace().roots.length : 0; this.onConfigurationChange(configurationService.getConfiguration(), false); this.registerListeners(); @@ -90,7 +90,7 @@ export class SettingsChangeRelauncher implements IWorkbenchContribution { } private onDidChangeWorkspaceRoots(): void { - const newRootCount = this.contextService.hasWorkspace() ? this.contextService.getWorkspace2().roots.length : 0; + const newRootCount = this.contextService.hasWorkspace() ? this.contextService.getWorkspace().roots.length : 0; let reload = false; if (this.rootCount === 0 && newRootCount > 0) { diff --git a/src/vs/workbench/parts/search/browser/openFileHandler.ts b/src/vs/workbench/parts/search/browser/openFileHandler.ts index 50532409b65..f872cd46777 100644 --- a/src/vs/workbench/parts/search/browser/openFileHandler.ts +++ b/src/vs/workbench/parts/search/browser/openFileHandler.ts @@ -162,7 +162,7 @@ export class OpenFileHandler extends QuickOpenHandler { iconClass = 'file'; // only use a generic file icon if we are forced to use an icon and have no icon theme set otherwise } - const folderResources = this.contextService.hasWorkspace() ? this.contextService.getWorkspace2().roots : []; + const folderResources = this.contextService.hasWorkspace() ? this.contextService.getWorkspace().roots : []; return this.searchService.search(this.queryBuilder.file(folderResources, query)).then((complete) => { const results: QuickOpenEntry[] = []; for (let i = 0; i < complete.results.length; i++) { @@ -196,7 +196,7 @@ export class OpenFileHandler extends QuickOpenHandler { sortByScore: true }; - const folderResources = this.contextService.hasWorkspace() ? this.contextService.getWorkspace2().roots : []; + const folderResources = this.contextService.hasWorkspace() ? this.contextService.getWorkspace().roots : []; const query = this.queryBuilder.file(folderResources, options); this.searchService.extendQuery(query); diff --git a/src/vs/workbench/parts/search/browser/searchViewlet.ts b/src/vs/workbench/parts/search/browser/searchViewlet.ts index c3bd5272e28..64568249dec 100644 --- a/src/vs/workbench/parts/search/browser/searchViewlet.ts +++ b/src/vs/workbench/parts/search/browser/searchViewlet.ts @@ -150,7 +150,7 @@ export class SearchViewlet extends Viewlet { } private onConfigurationUpdated(): void { - const resource = this.contextService.hasWorkspace() ? this.contextService.getWorkspace2().roots[0] : undefined; + const resource = this.contextService.hasWorkspace() ? this.contextService.getWorkspace().roots[0] : undefined; const config = this.configurationService.getConfiguration(undefined, { resource }); this.updateGlobalPatternExclusions(config); } @@ -894,7 +894,7 @@ export class SearchViewlet extends Viewlet { public searchInFolder(resource: URI): void { let folderPath = null; - const workspace = this.contextService.getWorkspace2(); + const workspace = this.contextService.getWorkspace(); if (workspace) { if (workspace.roots.length === 1) { // Fallback to old way for single root workspace @@ -976,7 +976,7 @@ export class SearchViewlet extends Viewlet { searchPaths }; - const folderResources = this.contextService.hasWorkspace() ? this.contextService.getWorkspace2().roots : []; + const folderResources = this.contextService.hasWorkspace() ? this.contextService.getWorkspace().roots : []; this.onQueryTriggered(this.queryBuilder.text(content, folderResources, options), excludePatternText, includePatternText); if (!preserveFocus) { diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index bdd54d407f8..397f0f890de 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -1404,7 +1404,7 @@ class TaskService extends EventEmitter implements ITaskService { } private getConfiguration(): { config: TaskConfig.ExternalTaskRunnerConfiguration; hasParseErrors: boolean } { - let result = this.contextService.hasWorkspace() ? this.configurationService.getConfiguration('tasks', { resource: this.contextService.getWorkspace().resource }) : undefined; + let result = this.contextService.hasWorkspace() ? this.configurationService.getConfiguration('tasks', { resource: this.contextService.getLegacyWorkspace().resource }) : undefined; if (!result) { return { config: undefined, hasParseErrors: false }; } diff --git a/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts b/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts index 16f4b13ba8c..dcf646daff4 100644 --- a/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts +++ b/src/vs/workbench/parts/tasks/node/processRunnerDetector.ts @@ -156,7 +156,7 @@ export class ProcessRunnerDetector { this.taskConfiguration = config; this._stderr = []; this._stdout = []; - this._cwd = this.contextService.hasWorkspace() ? Paths.normalize(this.contextService.getWorkspace().resource.fsPath, true) : ''; + this._cwd = this.contextService.hasWorkspace() ? Paths.normalize(this.contextService.getLegacyWorkspace().resource.fsPath, true) : ''; } public get stderr(): string[] { diff --git a/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts b/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts index 41425a27cec..00fd45babd9 100644 --- a/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts +++ b/src/vs/workbench/parts/terminal/electron-browser/terminalLinkHandler.ts @@ -224,7 +224,7 @@ export class TerminalLinkHandler { // Abort if no workspace is open return null; } - link = path.join(this._contextService.getWorkspace().resource.fsPath, link); // TODO@Daniel (https://github.com/Microsoft/vscode/issues/29006) + link = path.join(this._contextService.getLegacyWorkspace().resource.fsPath, link); // TODO@Daniel (https://github.com/Microsoft/vscode/issues/29006) } } // Resolve workspace path . | .. | -> /. | /.. | / @@ -233,7 +233,7 @@ export class TerminalLinkHandler { // Abort if no workspace is open return null; } - link = path.join(this._contextService.getWorkspace().resource.fsPath, link); // TODO@Daniel (https://github.com/Microsoft/vscode/issues/29006) + link = path.join(this._contextService.getLegacyWorkspace().resource.fsPath, link); // TODO@Daniel (https://github.com/Microsoft/vscode/issues/29006) } return link; } diff --git a/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts b/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts index f4f799d839f..eb12b56e3ec 100644 --- a/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts +++ b/src/vs/workbench/parts/welcome/page/electron-browser/welcomePage.ts @@ -222,7 +222,7 @@ class WelcomePage { recentlyOpened.then(({ folders }) => { if (this.contextService.hasWorkspace()) { - const currents = this.contextService.getWorkspace2().roots; + const currents = this.contextService.getWorkspace().roots; folders = folders.filter(folder => !currents.some(current => this.pathEquals(folder, current.fsPath))); } if (!folders.length) { diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/node/configuration.ts index c828892f64c..1aa619f288c 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/node/configuration.ts @@ -227,11 +227,11 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp } } - public getWorkspace(): ILegacyWorkspace { + public getLegacyWorkspace(): ILegacyWorkspace { return this.legacyWorkspace; } - public getWorkspace2(): IWorkspace { + public getWorkspace(): IWorkspace { return this.workspace; } diff --git a/src/vs/workbench/services/configuration/node/configurationEditingService.ts b/src/vs/workbench/services/configuration/node/configurationEditingService.ts index 2fd3997b26a..ba58a32aee0 100644 --- a/src/vs/workbench/services/configuration/node/configurationEditingService.ts +++ b/src/vs/workbench/services/configuration/node/configurationEditingService.ts @@ -287,7 +287,7 @@ export class ConfigurationEditingService implements IConfigurationEditingService } private getConfigurationFileResource(resource: URI): URI { - const workspace = this.contextService.getWorkspace2(); + const workspace = this.contextService.getWorkspace(); if (workspace) { if (resource) { const root = this.contextService.getRoot(resource); diff --git a/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts b/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts index 985e55d81be..6cc318a718e 100644 --- a/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts +++ b/src/vs/workbench/services/configurationResolver/node/configurationResolverService.ts @@ -30,7 +30,7 @@ export class ConfigurationResolverService implements IConfigurationResolverServi @ICommandService private commandService: ICommandService, @IWorkspaceContextService private contextService: IWorkspaceContextService ) { - this._workspaceRoot = paths.normalize(contextService.hasWorkspace() ? contextService.getWorkspace().resource.fsPath : '', true); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29246) + this._workspaceRoot = paths.normalize(contextService.hasWorkspace() ? contextService.getLegacyWorkspace().resource.fsPath : '', true); // TODO@Isidor (https://github.com/Microsoft/vscode/issues/29246) this._execPath = environmentService.execPath; Object.keys(envVariables).forEach(key => { this[`env:${key}`] = envVariables[key]; diff --git a/src/vs/workbench/services/files/electron-browser/fileService.ts b/src/vs/workbench/services/files/electron-browser/fileService.ts index 8f3af22b457..991e116aebc 100644 --- a/src/vs/workbench/services/files/electron-browser/fileService.ts +++ b/src/vs/workbench/services/files/electron-browser/fileService.ts @@ -145,7 +145,7 @@ export class FileService implements IFileService { const encodingOverride: IEncodingOverride[] = []; encodingOverride.push({ resource: uri.file(this.environmentService.appSettingsHome), encoding: encoding.UTF8 }); if (this.contextService.hasWorkspace()) { - this.contextService.getWorkspace2().roots.forEach(root => { + this.contextService.getWorkspace().roots.forEach(root => { encodingOverride.push({ resource: uri.file(paths.join(root.fsPath, '.vscode')), encoding: encoding.UTF8 }); }); } diff --git a/src/vs/workbench/services/files/node/fileService.ts b/src/vs/workbench/services/files/node/fileService.ts index bf7021c4d72..db42fdd616a 100644 --- a/src/vs/workbench/services/files/node/fileService.ts +++ b/src/vs/workbench/services/files/node/fileService.ts @@ -100,7 +100,7 @@ export class FileService implements IFileService { this.toDispose = []; this.options = options || Object.create(null); this.tmpPath = this.options.tmpDir || os.tmpdir(); - this.currentWorkspaceRootsCount = contextService.hasWorkspace() ? contextService.getWorkspace2().roots.length : 0; + this.currentWorkspaceRootsCount = contextService.hasWorkspace() ? contextService.getWorkspace().roots.length : 0; this._onFileChanges = new Emitter(); this.toDispose.push(this._onFileChanges); @@ -128,7 +128,7 @@ export class FileService implements IFileService { } private onDidChangeWorkspaceRoots(): void { - const newRootCount = this.contextService.hasWorkspace() ? this.contextService.getWorkspace2().roots.length : 0; + const newRootCount = this.contextService.hasWorkspace() ? this.contextService.getWorkspace().roots.length : 0; let restartWorkspaceWatcher = false; if (this.currentWorkspaceRootsCount <= 1 && newRootCount > 1) { @@ -166,7 +166,7 @@ export class FileService implements IFileService { } // new watcher: use it if setting tells us so or we run in multi-root environment - if (this.options.useExperimentalFileWatcher || this.contextService.getWorkspace2().roots.length > 1) { + if (this.options.useExperimentalFileWatcher || this.contextService.getWorkspace().roots.length > 1) { this.activeWorkspaceChangeWatcher = toDisposable(this.setupNsfwWorkspaceWatching().startWatching()); } diff --git a/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts b/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts index e1c368f9306..be60fdf3bae 100644 --- a/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts +++ b/src/vs/workbench/services/files/node/watcher/nsfw/watcherService.ts @@ -93,7 +93,7 @@ export class FileWatcher { return; } - const roots = this.contextService.getWorkspace2().roots; + const roots = this.contextService.getWorkspace().roots; this.service.setRoots(roots.map(root => { // Fetch the root's watcherExclude setting and return it const configuration = this.configurationService.getConfiguration(undefined, { diff --git a/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts b/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts index 02ce171a003..fa895f465ea 100644 --- a/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts +++ b/src/vs/workbench/services/files/node/watcher/unix/watcherService.ts @@ -52,7 +52,7 @@ export class FileWatcher { const service = new WatcherChannelClient(channel); // Start watching - const basePath: string = normalize(this.contextService.getWorkspace2().roots[0].fsPath); + const basePath: string = normalize(this.contextService.getWorkspace().roots[0].fsPath); service.watch({ basePath: basePath, ignored: this.ignored, verboseLogging: this.verboseLogging }).then(null, err => { if (!this.isDisposed && !(err instanceof Error && err.name === 'Canceled' && err.message === 'Canceled')) { return TPromise.wrapError(err); // the service lib uses the promise cancel error to indicate the process died, we do not want to bubble this up diff --git a/src/vs/workbench/services/files/node/watcher/win32/watcherService.ts b/src/vs/workbench/services/files/node/watcher/win32/watcherService.ts index 80e71eb3b4b..518a08f22a3 100644 --- a/src/vs/workbench/services/files/node/watcher/win32/watcherService.ts +++ b/src/vs/workbench/services/files/node/watcher/win32/watcherService.ts @@ -26,7 +26,7 @@ export class FileWatcher { } public startWatching(): () => void { - let basePath: string = normalize(this.contextService.getWorkspace2().roots[0].fsPath); + let basePath: string = normalize(this.contextService.getWorkspace().roots[0].fsPath); if (basePath && basePath.indexOf('\\\\') === 0 && endsWith(basePath, sep)) { // for some weird reason, node adds a trailing slash to UNC paths diff --git a/src/vs/workbench/services/history/browser/history.ts b/src/vs/workbench/services/history/browser/history.ts index bb0106de828..1607663e439 100644 --- a/src/vs/workbench/services/history/browser/history.ts +++ b/src/vs/workbench/services/history/browser/history.ts @@ -703,6 +703,6 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic } // fallback to first workspace - return this.contextService.getWorkspace2().roots[0]; + return this.contextService.getWorkspace().roots[0]; } } diff --git a/src/vs/workbench/services/telemetry/common/workspaceStats.ts b/src/vs/workbench/services/telemetry/common/workspaceStats.ts index 243f066a251..5aaf624833f 100644 --- a/src/vs/workbench/services/telemetry/common/workspaceStats.ts +++ b/src/vs/workbench/services/telemetry/common/workspaceStats.ts @@ -152,7 +152,7 @@ export class WorkspaceStats { tags['workbench.filesToCreate'] = filesToCreate && filesToCreate.length || undefined; tags['workbench.filesToDiff'] = filesToDiff && filesToDiff.length || undefined; - const workspace = this.contextService.getWorkspace2(); + const workspace = this.contextService.getWorkspace(); tags['workspace.roots'] = workspace ? workspace.roots.length : 0; tags['workspace.empty'] = !workspace; @@ -332,7 +332,7 @@ export class WorkspaceStats { } public reportCloudStats(): void { - const workspace = this.contextService.getWorkspace2(); + const workspace = this.contextService.getWorkspace(); const uris = workspace && workspace.roots; if (uris && uris.length && this.fileService) { this.reportRemoteDomains(uris); diff --git a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts index d572951231d..484e41af3e5 100644 --- a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts +++ b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts @@ -726,7 +726,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil // Check for workspace settings file if (this.contextService.hasWorkspace()) { - return this.contextService.getWorkspace2().roots.some(root => { + return this.contextService.getWorkspace().roots.some(root => { return paths.isEqualOrParent(this.resource.fsPath, path.join(root.fsPath, '.vscode')); }); } diff --git a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts b/src/vs/workbench/services/workspace/node/workspaceEditingService.ts index 485a1ab96f4..1e63ca75ccf 100644 --- a/src/vs/workbench/services/workspace/node/workspaceEditingService.ts +++ b/src/vs/workbench/services/workspace/node/workspaceEditingService.ts @@ -48,7 +48,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { return TPromise.as(void 0); // we need a workspace to begin with } - const roots = this.contextService.getWorkspace2().roots; + const roots = this.contextService.getWorkspace().roots; return this.doSetRoots([...roots, ...rootsToAdd]); } @@ -58,7 +58,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { return TPromise.as(void 0); // we need a workspace to begin with } - const roots = this.contextService.getWorkspace2().roots; + const roots = this.contextService.getWorkspace().roots; const rootsToRemoveRaw = rootsToRemove.map(root => root.toString()); return this.doSetRoots(roots.filter(root => rootsToRemoveRaw.indexOf(root.toString()) === -1)); @@ -66,7 +66,7 @@ export class WorkspaceEditingService implements IWorkspaceEditingService { private doSetRoots(newRoots: URI[]): TPromise { const workspaceUserConfig = this.configurationService.lookup(workspaceConfigKey).user as IWorkspaceConfiguration || Object.create(null); - const master = this.contextService.getWorkspace2().roots[0]; + const master = this.contextService.getWorkspace().roots[0]; const masterKey = master.toString(true /* skip encoding */); const currentWorkspaceRoots = this.validateRoots(master, workspaceUserConfig[masterKey] && workspaceUserConfig[masterKey].folders); diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 3b104736d52..b88a6f173ea 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -89,11 +89,11 @@ export class TestContextService implements IWorkspaceContextService { return !!this.workspace; } - public getWorkspace(): ILegacyWorkspace { + public getLegacyWorkspace(): ILegacyWorkspace { return this.workspace ? { resource: this.workspace.roots[0] } : void 0; } - public getWorkspace2(): IWorkspace { + public getWorkspace(): IWorkspace { return this.workspace; } @@ -397,7 +397,7 @@ export class TestStorageService extends EventEmitter implements IStorageService super(); let context = new TestContextService(); - this.storage = new StorageService(new InMemoryLocalStorage(), null, context.getWorkspace2()); + this.storage = new StorageService(new InMemoryLocalStorage(), null, context.getWorkspace()); } store(key: string, value: any, scope: StorageScope = StorageScope.GLOBAL): void {