From e23c3d03ef9a9893e4f298d66b036acc785f0b2a Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Fri, 14 Jul 2017 10:42:39 +0200 Subject: [PATCH] remove some unused code (part of #29460) --- .../standalone/browser/simpleServices.ts | 4 --- src/vs/platform/workspace/common/workspace.ts | 29 +++------------ src/vs/workbench/electron-browser/main.ts | 35 +++++++++---------- .../configuration/node/configuration.ts | 4 --- .../workbench/test/workbenchTestServices.ts | 12 ------- 5 files changed, 21 insertions(+), 63 deletions(-) diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index dcae68b3d18..a6ab32da9b2 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -560,10 +560,6 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService { return resource && resource.scheme === SimpleWorkspaceContextService.SCHEME; } - public toWorkspaceRelativePath(resource: URI, toOSPath?: boolean): string { - return resource.fsPath; - } - public toResource(workspaceRelativePath: string): URI { return URI.file(workspaceRelativePath); } diff --git a/src/vs/platform/workspace/common/workspace.ts b/src/vs/platform/workspace/common/workspace.ts index 598f9e64a0a..608b859f16b 100644 --- a/src/vs/platform/workspace/common/workspace.ts +++ b/src/vs/platform/workspace/common/workspace.ts @@ -8,7 +8,6 @@ import URI from 'vs/base/common/uri'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import * as paths from 'vs/base/common/paths'; import { TrieMap } from 'vs/base/common/map'; -import { isLinux } from 'vs/base/common/platform'; import Event from 'vs/base/common/event'; export const IWorkspaceContextService = createDecorator('contextService'); @@ -59,13 +58,6 @@ export interface IWorkspaceContextService { */ isInsideWorkspace(resource: URI): boolean; - /** - * Given a resource inside the workspace, returns its relative path from the workspace root - * without leading or trailing slashes. Returns null if the file is not inside an opened - * workspace. - */ - toWorkspaceRelativePath: (resource: URI, toOSPath?: boolean) => string; - /** * Given a workspace relative path, returns the resource with the absolute path. */ @@ -79,6 +71,11 @@ export interface ILegacyWorkspace { * of the workspace on disk. */ resource: URI; + + /** + * creation time of the workspace folder if known + */ + ctime?: number; } export interface IWorkspace { @@ -123,22 +120,6 @@ export class LegacyWorkspace implements ILegacyWorkspace { return this._ctime; } - public toWorkspaceRelativePath(resource: URI, toOSPath?: boolean): string { - if (this.contains(resource)) { - return paths.normalize(paths.relative(this._resource.fsPath, resource.fsPath), toOSPath); - } - - return null; - } - - private contains(resource: URI): boolean { - if (resource) { - return paths.isEqualOrParent(resource.fsPath, this._resource.fsPath, !isLinux /* ignorecase */); - } - - return false; - } - public toResource(workspaceRelativePath: string, root?: URI): URI { if (typeof workspaceRelativePath === 'string') { return URI.file(paths.join(root ? root.fsPath : this._resource.fsPath, workspaceRelativePath)); diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 9118720b026..b2af47dd283 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -18,8 +18,8 @@ import paths = require('vs/base/common/paths'); import uri from 'vs/base/common/uri'; import strings = require('vs/base/common/strings'); import { IResourceInput } from 'vs/platform/editor/common/editor'; -import { LegacyWorkspace, Workspace } from 'vs/platform/workspace/common/workspace'; -import { WorkspaceService, EmptyWorkspaceServiceImpl, WorkspaceServiceImpl } from 'vs/workbench/services/configuration/node/configuration'; +import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; +import { EmptyWorkspaceServiceImpl, WorkspaceServiceImpl, WorkspaceService } from 'vs/workbench/services/configuration/node/configuration'; import { realpath } from 'vs/base/node/pfs'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import path = require('path'); @@ -100,10 +100,8 @@ function openWorkbench(configuration: IWindowConfiguration, options: IOptions): // Since the configuration service is one of the core services that is used in so many places, we initialize it // right before startup of the workbench shell to have its data ready for consumers return createAndInitializeWorkspaceService(configuration, environmentService).then(workspaceService => { - const workspace = workspaceService.getWorkspace(); - const legacyWorkspace = workspaceService.getLegacyWorkspace(); - const timerService = new TimerService((window).MonacoEnvironment.timers as IInitData, !!workspace); - const storageService = createStorageService(legacyWorkspace, workspace, configuration, environmentService); + const timerService = new TimerService((window).MonacoEnvironment.timers as IInitData, !workspaceService.hasWorkspace()); + const storageService = createStorageService(configuration, workspaceService, environmentService); timerService.beforeDOMContentLoaded = Date.now(); @@ -166,24 +164,23 @@ function validateWorkspacePath(configuration: IWindowConfiguration): TPromise