提交 e23c3d03 编写于 作者: B Benjamin Pasero

remove some unused code (part of #29460)

上级 84628ed1
......@@ -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);
}
......
......@@ -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<IWorkspaceContextService>('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));
......
......@@ -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 = <Workspace>workspaceService.getWorkspace();
const legacyWorkspace = <LegacyWorkspace>workspaceService.getLegacyWorkspace();
const timerService = new TimerService((<any>window).MonacoEnvironment.timers as IInitData, !!workspace);
const storageService = createStorageService(legacyWorkspace, workspace, configuration, environmentService);
const timerService = new TimerService((<any>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<vo
});
}
function createStorageService(legacyWorkspace: LegacyWorkspace, workspace: Workspace, configuration: IWindowConfiguration, environmentService: IEnvironmentService): IStorageService {
function createStorageService(configuration: IWindowConfiguration, workspaceService: IWorkspaceContextService, environmentService: IEnvironmentService): IStorageService {
const workspace = workspaceService.getWorkspace();
let workspaceId: string;
let secondaryWorkspaceId: number;
if (workspace) {
// in multi root workspace mode we use the provided ID as key for workspace storage
if (workspace.configuration) {
workspaceId = uri.from({ path: workspace.id, scheme: 'root' }).toString();
}
// in multi root workspace mode we use the provided ID as key for workspace storage
if (workspaceService.hasMultiFolderWorkspace()) {
workspaceId = uri.from({ path: workspace.id, scheme: 'root' }).toString();
}
// in single folder mode we use the path of the opened folder as key for workspace storage
// the ctime is used as secondary workspace id to clean up stale UI state if necessary
else {
workspaceId = legacyWorkspace.resource.toString();
secondaryWorkspaceId = legacyWorkspace.ctime;
}
// in single folder mode we use the path of the opened folder as key for workspace storage
// the ctime is used as secondary workspace id to clean up stale UI state if necessary
else if (workspaceService.hasFolderWorkspace()) {
const legacyWorkspace = workspaceService.getLegacyWorkspace();
workspaceId = legacyWorkspace.resource.toString();
secondaryWorkspaceId = legacyWorkspace.ctime;
}
// finaly, if we do not have a workspace open, we need to find another identifier for the window to store
......
......@@ -212,10 +212,6 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
return !!this.getRoot(resource);
}
public toWorkspaceRelativePath(resource: URI, toOSPath?: boolean): string {
return this.workspace ? this.legacyWorkspace.toWorkspaceRelativePath(resource, toOSPath) : null;
}
public toResource(workspaceRelativePath: string): URI {
return this.workspace ? this.legacyWorkspace.toResource(workspaceRelativePath) : null;
}
......
......@@ -131,23 +131,11 @@ export class TestContextService implements IWorkspaceContextService {
return false;
}
public toWorkspaceRelativePath(resource: URI, toOSPath?: boolean): string {
return makePosixAbsolute(paths.normalize(resource.fsPath.substr('c:'.length), toOSPath));
}
public toResource(workspaceRelativePath: string): URI {
return URI.file(paths.join('C:\\', workspaceRelativePath));
}
}
function isPosixAbsolute(path: string): boolean {
return path && path[0] === '/';
}
function makePosixAbsolute(path: string): string {
return isPosixAbsolute(paths.normalize(path)) ? path : paths.sep + path;
}
export class TestTextFileService extends TextFileService {
public cleanupBackupsBeforeShutdownCalled: boolean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册