提交 9754a210 编写于 作者: B Benjamin Pasero

Revert "extract more functionality into IWorkspace"

This reverts commit 25b4b172.
上级 7a927e30
...@@ -22,7 +22,7 @@ import { IMessageService } from 'vs/platform/message/common/message'; ...@@ -22,7 +22,7 @@ import { IMessageService } from 'vs/platform/message/common/message';
import { IProgressService } from 'vs/platform/progress/common/progress'; import { IProgressService } from 'vs/platform/progress/common/progress';
import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage'; import { IStorageService, NullStorageService } from 'vs/platform/storage/common/storage';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService, WorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceContextService, WorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService'; import { ICodeEditorService } from 'vs/editor/common/services/codeEditorService';
import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService'; import { IEditorWorkerService } from 'vs/editor/common/services/editorWorkerService';
import { EditorWorkerServiceImpl } from 'vs/editor/common/services/editorWorkerServiceImpl'; import { EditorWorkerServiceImpl } from 'vs/editor/common/services/editorWorkerServiceImpl';
...@@ -115,9 +115,9 @@ export module StaticServices { ...@@ -115,9 +115,9 @@ export module StaticServices {
export const instantiationService = define<IInstantiationService>(IInstantiationService, () => new InstantiationService(_serviceCollection, true)); export const instantiationService = define<IInstantiationService>(IInstantiationService, () => new InstantiationService(_serviceCollection, true));
export const contextService = define(IWorkspaceContextService, () => new WorkspaceContextService(new Workspace( export const contextService = define(IWorkspaceContextService, () => new WorkspaceContextService({
URI.from({ scheme: 'inmemory', authority: 'model', path: '/' }) resource: URI.from({ scheme: 'inmemory', authority: 'model', path: '/' })
))); }));
export const telemetryService = define(ITelemetryService, () => new StandaloneTelemetryService()); export const telemetryService = define(ITelemetryService, () => new StandaloneTelemetryService());
......
...@@ -65,26 +65,27 @@ export interface IWorkspace { ...@@ -65,26 +65,27 @@ export interface IWorkspace {
name?: string; name?: string;
} }
export class Workspace implements IWorkspace { export class WorkspaceContextService implements IWorkspaceContextService {
constructor(private _resource: URI, private _uid?: number, private _name?: string) { public _serviceBrand: any;
}
public get resource(): URI { private workspace: IWorkspace;
return this._resource;
constructor(workspace: IWorkspace) {
this.workspace = workspace;
} }
public get uid(): number { public getWorkspace(): IWorkspace {
return this._uid; return this.workspace;
} }
public get name(): string { public hasWorkspace(): boolean {
return this._name; return !!this.workspace;
} }
public isInsideWorkspace(resource: URI): boolean { public isInsideWorkspace(resource: URI): boolean {
if (resource) { if (resource && this.workspace) {
return isEqualOrParent(resource.fsPath, this._resource.fsPath, !isLinux /* ignorecase */); return isEqualOrParent(resource.fsPath, this.workspace.resource.fsPath, !isLinux /* ignorecase */);
} }
return false; return false;
...@@ -92,48 +93,17 @@ export class Workspace implements IWorkspace { ...@@ -92,48 +93,17 @@ export class Workspace implements IWorkspace {
public toWorkspaceRelativePath(resource: URI, toOSPath?: boolean): string { public toWorkspaceRelativePath(resource: URI, toOSPath?: boolean): string {
if (this.isInsideWorkspace(resource)) { if (this.isInsideWorkspace(resource)) {
return paths.normalize(paths.relative(this._resource.fsPath, resource.fsPath), toOSPath); return paths.normalize(paths.relative(this.workspace.resource.fsPath, resource.fsPath), toOSPath);
} }
return null; return null;
} }
public toResource(workspaceRelativePath: string): URI { public toResource(workspaceRelativePath: string): URI {
if (typeof workspaceRelativePath === 'string') { if (typeof workspaceRelativePath === 'string' && this.workspace) {
return URI.file(paths.join(this._resource.fsPath, workspaceRelativePath)); return URI.file(paths.join(this.workspace.resource.fsPath, workspaceRelativePath));
} }
return null; return null;
} }
}
export class WorkspaceContextService implements IWorkspaceContextService {
public _serviceBrand: any;
private workspace: Workspace;
constructor(workspace?: Workspace) {
this.workspace = workspace;
}
public getWorkspace(): IWorkspace {
return this.workspace;
}
public hasWorkspace(): boolean {
return !!this.workspace;
}
public isInsideWorkspace(resource: URI): boolean {
return this.workspace ? this.workspace.isInsideWorkspace(resource) : false;
}
public toWorkspaceRelativePath(resource: URI, toOSPath?: boolean): string {
return this.workspace ? this.workspace.toWorkspaceRelativePath(resource, toOSPath) : null;
}
public toResource(workspaceRelativePath: string): URI {
return this.workspace ? this.workspace.toResource(workspaceRelativePath) : null;
}
} }
\ No newline at end of file
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { Workspace } from 'vs/platform/workspace/common/workspace'; import { IWorkspace } from 'vs/platform/workspace/common/workspace';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
export const TestWorkspace = new Workspace( export const TestWorkspace: IWorkspace = {
URI.file('C:\\testWorkspace'), resource: URI.file('C:\\testWorkspace'),
Date.now(), name: 'Test Workspace',
'Test Workspace' uid: Date.now()
); };
...@@ -18,7 +18,7 @@ import paths = require('vs/base/common/paths'); ...@@ -18,7 +18,7 @@ import paths = require('vs/base/common/paths');
import uri from 'vs/base/common/uri'; import uri from 'vs/base/common/uri';
import strings = require('vs/base/common/strings'); import strings = require('vs/base/common/strings');
import { IResourceInput } from 'vs/platform/editor/common/editor'; import { IResourceInput } from 'vs/platform/editor/common/editor';
import { WorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace'; import { IWorkspace, WorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { WorkspaceConfigurationService } from 'vs/workbench/services/configuration/node/configurationService'; import { WorkspaceConfigurationService } from 'vs/workbench/services/configuration/node/configurationService';
import { ParsedArgs } from 'vs/platform/environment/common/environment'; import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { realpath, stat } from 'vs/base/node/pfs'; import { realpath, stat } from 'vs/base/node/pfs';
...@@ -116,7 +116,7 @@ function toInputs(paths: IPath[], isUntitledFile?: boolean): IResourceInput[] { ...@@ -116,7 +116,7 @@ function toInputs(paths: IPath[], isUntitledFile?: boolean): IResourceInput[] {
}); });
} }
function getWorkspace(workspacePath: string): TPromise<Workspace> { function getWorkspace(workspacePath: string): TPromise<IWorkspace> {
if (!workspacePath) { if (!workspacePath) {
return TPromise.as(null); return TPromise.as(null);
} }
...@@ -135,23 +135,23 @@ function getWorkspace(workspacePath: string): TPromise<Workspace> { ...@@ -135,23 +135,23 @@ function getWorkspace(workspacePath: string): TPromise<Workspace> {
const folderName = path.basename(realWorkspacePath) || realWorkspacePath; const folderName = path.basename(realWorkspacePath) || realWorkspacePath;
return stat(realWorkspacePath).then(folderStat => { return stat(realWorkspacePath).then(folderStat => {
return new Workspace( return <IWorkspace>{
workspaceResource, 'resource': workspaceResource,
platform.isLinux ? folderStat.ino : folderStat.birthtime.getTime(), 'name': folderName,
folderName // On Linux, birthtime is ctime, so we cannot use it! We use the ino instead! 'uid': platform.isLinux ? folderStat.ino : folderStat.birthtime.getTime() // On Linux, birthtime is ctime, so we cannot use it! We use the ino instead!
); };
}); });
}, error => { }, (error) => {
errors.onUnexpectedError(error); errors.onUnexpectedError(error);
return null; // treat invalid paths as empty workspace return null; // treat invalid paths as empty workspace
}); });
} }
function openWorkbench(environment: IWindowConfiguration, workspace: Workspace, options: IOptions): TPromise<void> { function openWorkbench(environment: IWindowConfiguration, workspace: IWorkspace, options: IOptions): TPromise<void> {
const environmentService = new EnvironmentService(environment, environment.execPath); const environmentService = new EnvironmentService(environment, environment.execPath);
const contextService = new WorkspaceContextService(workspace); const contextService = new WorkspaceContextService(workspace);
const configurationService = new WorkspaceConfigurationService(environmentService, workspace); const configurationService = new WorkspaceConfigurationService(contextService, environmentService);
const timerService = new TimerService((<any>window).MonacoEnvironment.timers as IInitData, !contextService.hasWorkspace()); const timerService = new TimerService((<any>window).MonacoEnvironment.timers as IInitData, !contextService.hasWorkspace());
// Since the configuration service is one of the core services that is used in so many places, we initialize it // Since the configuration service is one of the core services that is used in so many places, we initialize it
......
...@@ -15,7 +15,7 @@ import { ExtHostThreadService } from 'vs/workbench/services/thread/common/extHos ...@@ -15,7 +15,7 @@ import { ExtHostThreadService } from 'vs/workbench/services/thread/common/extHos
import { QueryType, ISearchQuery } from 'vs/platform/search/common/search'; import { QueryType, ISearchQuery } from 'vs/platform/search/common/search';
import { DiskSearch } from 'vs/workbench/services/search/node/searchService'; import { DiskSearch } from 'vs/workbench/services/search/node/searchService';
import { RemoteTelemetryService } from 'vs/workbench/api/node/extHostTelemetry'; import { RemoteTelemetryService } from 'vs/workbench/api/node/extHostTelemetry';
import { IWorkspaceContextService, WorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceContextService, WorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IInitData, IEnvironment, MainContext } from 'vs/workbench/api/node/extHost.protocol'; import { IInitData, IEnvironment, MainContext } from 'vs/workbench/api/node/extHost.protocol';
import * as errors from 'vs/base/common/errors'; import * as errors from 'vs/base/common/errors';
...@@ -43,14 +43,7 @@ export class ExtensionHostMain { ...@@ -43,14 +43,7 @@ export class ExtensionHostMain {
constructor(remoteCom: IRemoteCom, initData: IInitData) { constructor(remoteCom: IRemoteCom, initData: IInitData) {
// services // services
this._environment = initData.environment; this._environment = initData.environment;
this._contextService = new WorkspaceContextService(initData.contextService.workspace);
const workspaceRaw = initData.contextService.workspace;
let workspace: Workspace;
if (workspaceRaw) {
workspace = new Workspace(workspaceRaw.resource, workspaceRaw.uid, workspaceRaw.name);
}
this._contextService = new WorkspaceContextService(workspace);
const threadService = new ExtHostThreadService(remoteCom); const threadService = new ExtHostThreadService(remoteCom);
const telemetryService = new RemoteTelemetryService('pluginHostTelemetry', threadService); const telemetryService = new RemoteTelemetryService('pluginHostTelemetry', threadService);
this._extensionService = new ExtHostExtensionService(initData, threadService, telemetryService, this._contextService); this._extensionService = new ExtHostExtensionService(initData, threadService, telemetryService, this._contextService);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import * as assert from 'assert'; import * as assert from 'assert';
import { Platform } from 'vs/base/common/platform'; import { Platform } from 'vs/base/common/platform';
import { TerminalLinkHandler, LineColumnInfo } from 'vs/workbench/parts/terminal/electron-browser/terminalLinkHandler'; import { TerminalLinkHandler, LineColumnInfo } from 'vs/workbench/parts/terminal/electron-browser/terminalLinkHandler';
import { WorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace'; import { IWorkspace, WorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
import * as strings from 'vs/base/common/strings'; import * as strings from 'vs/base/common/strings';
import * as path from 'path'; import * as path from 'path';
...@@ -44,9 +44,10 @@ interface LinkFormatInfo { ...@@ -44,9 +44,10 @@ interface LinkFormatInfo {
column?: string; column?: string;
} }
class TestWorkspace extends Workspace { class TestWorkspace implements IWorkspace {
constructor(private basePath: string) { resource: URI;
super(new TestURI(basePath)); constructor(basePath: string) {
this.resource = new TestURI(basePath);
} }
} }
......
...@@ -12,6 +12,7 @@ import extfs = require('vs/base/node/extfs'); ...@@ -12,6 +12,7 @@ import extfs = require('vs/base/node/extfs');
import objects = require('vs/base/common/objects'); import objects = require('vs/base/common/objects');
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
import collections = require('vs/base/common/collections'); import collections = require('vs/base/common/collections');
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle'; import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { readFile } from 'vs/base/node/pfs'; import { readFile } from 'vs/base/node/pfs';
...@@ -23,7 +24,7 @@ import { ConfigurationService as BaseConfigurationService } from 'vs/platform/co ...@@ -23,7 +24,7 @@ import { ConfigurationService as BaseConfigurationService } from 'vs/platform/co
import { IWorkspaceConfigurationValues, IWorkspaceConfigurationService, IWorkspaceConfigurationValue, WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME, WORKSPACE_STANDALONE_CONFIGURATIONS, WORKSPACE_CONFIG_DEFAULT_PATH } from 'vs/workbench/services/configuration/common/configuration'; import { IWorkspaceConfigurationValues, IWorkspaceConfigurationService, IWorkspaceConfigurationValue, WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME, WORKSPACE_STANDALONE_CONFIGURATIONS, WORKSPACE_CONFIG_DEFAULT_PATH } from 'vs/workbench/services/configuration/common/configuration';
import { FileChangeType, FileChangesEvent, isEqual } from 'vs/platform/files/common/files'; import { FileChangeType, FileChangesEvent, isEqual } from 'vs/platform/files/common/files';
import Event, { Emitter } from 'vs/base/common/event'; import Event, { Emitter } from 'vs/base/common/event';
import { Workspace } from "vs/platform/workspace/common/workspace";
interface IStat { interface IStat {
resource: uri; resource: uri;
...@@ -61,8 +62,8 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp ...@@ -61,8 +62,8 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
private reloadConfigurationScheduler: RunOnceScheduler; private reloadConfigurationScheduler: RunOnceScheduler;
constructor( constructor(
private environmentService: IEnvironmentService, @IWorkspaceContextService private contextService: IWorkspaceContextService,
private workspace?: Workspace, @IEnvironmentService environmentService: IEnvironmentService,
private workspaceSettingsRootFolder: string = WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME private workspaceSettingsRootFolder: string = WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME
) { ) {
super(); super();
...@@ -215,13 +216,13 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp ...@@ -215,13 +216,13 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
private loadWorkspaceConfigFiles<T>(): TPromise<{ [relativeWorkspacePath: string]: IConfigModel<T> }> { private loadWorkspaceConfigFiles<T>(): TPromise<{ [relativeWorkspacePath: string]: IConfigModel<T> }> {
// Return early if we don't have a workspace // Return early if we don't have a workspace
if (!this.workspace) { if (!this.contextService.hasWorkspace()) {
return TPromise.as(Object.create(null)); return TPromise.as(Object.create(null));
} }
// once: when invoked for the first time we fetch json files that contribute settings // once: when invoked for the first time we fetch json files that contribute settings
if (!this.bulkFetchFromWorkspacePromise) { if (!this.bulkFetchFromWorkspacePromise) {
this.bulkFetchFromWorkspacePromise = resolveStat(this.workspace.toResource(this.workspaceSettingsRootFolder)).then(stat => { this.bulkFetchFromWorkspacePromise = resolveStat(this.contextService.toResource(this.workspaceSettingsRootFolder)).then(stat => {
if (!stat.isDirectory) { if (!stat.isDirectory) {
return TPromise.as([]); return TPromise.as([]);
} }
...@@ -232,11 +233,11 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp ...@@ -232,11 +233,11 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
return false; // only JSON files return false; // only JSON files
} }
return this.isWorkspaceConfigurationFile(this.workspace.toWorkspaceRelativePath(stat.resource)); // only workspace config files return this.isWorkspaceConfigurationFile(this.contextService.toWorkspaceRelativePath(stat.resource)); // only workspace config files
}).map(stat => stat.resource)); }).map(stat => stat.resource));
}, err => [] /* never fail this call */) }, err => [] /* never fail this call */)
.then((contents: IContent[]) => { .then((contents: IContent[]) => {
contents.forEach(content => this.workspaceFilePathToConfiguration[this.workspace.toWorkspaceRelativePath(content.resource)] = TPromise.as(this.createConfigModel(content))); contents.forEach(content => this.workspaceFilePathToConfiguration[this.contextService.toWorkspaceRelativePath(content.resource)] = TPromise.as(this.createConfigModel(content)));
}, errors.onUnexpectedError); }, errors.onUnexpectedError);
} }
...@@ -258,7 +259,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp ...@@ -258,7 +259,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
continue; // only JSON files or the actual settings folder continue; // only JSON files or the actual settings folder
} }
const workspacePath = this.workspace.toWorkspaceRelativePath(resource); const workspacePath = this.contextService.toWorkspaceRelativePath(resource);
if (!workspacePath) { if (!workspacePath) {
continue; // event is not inside workspace continue; // event is not inside workspace
} }
...@@ -294,7 +295,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp ...@@ -294,7 +295,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
} }
private createConfigModel<T>(content: IContent): IConfigModel<T> { private createConfigModel<T>(content: IContent): IConfigModel<T> {
const path = this.workspace.toWorkspaceRelativePath(content.resource); const path = this.contextService.toWorkspaceRelativePath(content.resource);
if (path === WORKSPACE_CONFIG_DEFAULT_PATH) { if (path === WORKSPACE_CONFIG_DEFAULT_PATH) {
return new WorkspaceSettingsConfigModel<T>(content.value, content.resource.toString()); return new WorkspaceSettingsConfigModel<T>(content.value, content.resource.toString());
} else { } else {
......
...@@ -15,7 +15,7 @@ import { TPromise } from 'vs/base/common/winjs.base'; ...@@ -15,7 +15,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { Registry } from 'vs/platform/platform'; import { Registry } from 'vs/platform/platform';
import { ParsedArgs, IEnvironmentService } from 'vs/platform/environment/common/environment'; import { ParsedArgs, IEnvironmentService } from 'vs/platform/environment/common/environment';
import { parseArgs } from 'vs/platform/environment/node/argv'; import { parseArgs } from 'vs/platform/environment/node/argv';
import { WorkspaceContextService, IWorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace'; import { WorkspaceContextService, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import extfs = require('vs/base/node/extfs'); import extfs = require('vs/base/node/extfs');
import { TestTextFileService, TestEditorGroupService, TestLifecycleService, TestBackupFileService } from 'vs/workbench/test/workbenchTestServices'; import { TestTextFileService, TestEditorGroupService, TestLifecycleService, TestBackupFileService } from 'vs/workbench/test/workbenchTestServices';
...@@ -113,11 +113,9 @@ suite('ConfigurationEditingService', () => { ...@@ -113,11 +113,9 @@ suite('ConfigurationEditingService', () => {
clearServices(); clearServices();
instantiationService = new TestInstantiationService(); instantiationService = new TestInstantiationService();
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); instantiationService.stub(IEnvironmentService, new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile));
instantiationService.stub(IEnvironmentService, environmentService); instantiationService.stub(IWorkspaceContextService, new WorkspaceContextService(noWorkspace ? null : { resource: URI.file(workspaceDir) }));
const workspace = noWorkspace ? null : new Workspace(URI.file(workspaceDir)); const configurationService = instantiationService.createInstance(WorkspaceConfigurationService);
instantiationService.stub(IWorkspaceContextService, new WorkspaceContextService(workspace));
const configurationService = new WorkspaceConfigurationService(environmentService, workspace);
instantiationService.stub(IConfigurationService, configurationService); instantiationService.stub(IConfigurationService, configurationService);
instantiationService.stub(ILifecycleService, new TestLifecycleService()); instantiationService.stub(ILifecycleService, new TestLifecycleService());
instantiationService.stub(IEditorGroupService, new TestEditorGroupService()); instantiationService.stub(IEditorGroupService, new TestEditorGroupService());
......
...@@ -13,7 +13,7 @@ import * as sinon from 'sinon'; ...@@ -13,7 +13,7 @@ import * as sinon from 'sinon';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import { Registry } from 'vs/platform/platform'; import { Registry } from 'vs/platform/platform';
import { ParsedArgs } from 'vs/platform/environment/common/environment'; import { ParsedArgs } from 'vs/platform/environment/common/environment';
import { Workspace } from 'vs/platform/workspace/common/workspace'; import { WorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { EnvironmentService } from 'vs/platform/environment/node/environmentService'; import { EnvironmentService } from 'vs/platform/environment/node/environmentService';
import { parseArgs } from 'vs/platform/environment/node/argv'; import { parseArgs } from 'vs/platform/environment/node/argv';
import extfs = require('vs/base/node/extfs'); import extfs = require('vs/base/node/extfs');
...@@ -47,9 +47,9 @@ suite('WorkspaceConfigurationService - Node', () => { ...@@ -47,9 +47,9 @@ suite('WorkspaceConfigurationService - Node', () => {
} }
function createService(workspaceDir: string, globalSettingsFile: string): TPromise<WorkspaceConfigurationService> { function createService(workspaceDir: string, globalSettingsFile: string): TPromise<WorkspaceConfigurationService> {
const workspace = new Workspace(URI.file(workspaceDir)); const workspaceContextService = new WorkspaceContextService({ resource: URI.file(workspaceDir) });
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
const service = new WorkspaceConfigurationService(environmentService, workspace); const service = new WorkspaceConfigurationService(workspaceContextService, environmentService);
return service.initialize().then(() => service); return service.initialize().then(() => service);
} }
...@@ -204,9 +204,9 @@ suite('WorkspaceConfigurationService - Node', () => { ...@@ -204,9 +204,9 @@ suite('WorkspaceConfigurationService - Node', () => {
test('workspace change triggers event', (done: () => void) => { test('workspace change triggers event', (done: () => void) => {
createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => { createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => {
const workspace = new Workspace(URI.file(workspaceDir)); const workspaceContextService = new WorkspaceContextService({ resource: URI.file(workspaceDir) });
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
const service = new WorkspaceConfigurationService(environmentService, workspace); const service = new WorkspaceConfigurationService(workspaceContextService, environmentService);
return service.initialize().then(() => { return service.initialize().then(() => {
service.onDidUpdateConfiguration(event => { service.onDidUpdateConfiguration(event => {
...@@ -230,9 +230,9 @@ suite('WorkspaceConfigurationService - Node', () => { ...@@ -230,9 +230,9 @@ suite('WorkspaceConfigurationService - Node', () => {
test('workspace reload should triggers event if content changed', (done: () => void) => { test('workspace reload should triggers event if content changed', (done: () => void) => {
createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => { createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => {
const workspace = new Workspace(URI.file(workspaceDir)); const workspaceContextService = new WorkspaceContextService({ resource: URI.file(workspaceDir) });
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
const service = new WorkspaceConfigurationService(environmentService, workspace); const service = new WorkspaceConfigurationService(workspaceContextService, environmentService);
return service.initialize().then(() => { return service.initialize().then(() => {
const settingsFile = path.join(workspaceDir, '.vscode', 'settings.json'); const settingsFile = path.join(workspaceDir, '.vscode', 'settings.json');
...@@ -255,9 +255,9 @@ suite('WorkspaceConfigurationService - Node', () => { ...@@ -255,9 +255,9 @@ suite('WorkspaceConfigurationService - Node', () => {
test('workspace reload should not trigger event if nothing changed', (done: () => void) => { test('workspace reload should not trigger event if nothing changed', (done: () => void) => {
createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => { createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => {
const workspace = new Workspace(URI.file(workspaceDir)); const workspaceContextService = new WorkspaceContextService({ resource: URI.file(workspaceDir) });
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
const service = new WorkspaceConfigurationService(environmentService, workspace); const service = new WorkspaceConfigurationService(workspaceContextService, environmentService);
return service.initialize().then(() => { return service.initialize().then(() => {
const settingsFile = path.join(workspaceDir, '.vscode', 'settings.json'); const settingsFile = path.join(workspaceDir, '.vscode', 'settings.json');
...@@ -280,9 +280,9 @@ suite('WorkspaceConfigurationService - Node', () => { ...@@ -280,9 +280,9 @@ suite('WorkspaceConfigurationService - Node', () => {
test('workspace reload should not trigger event if there is no model', (done: () => void) => { test('workspace reload should not trigger event if there is no model', (done: () => void) => {
createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => { createWorkspace((workspaceDir, globalSettingsFile, cleanUp) => {
const workspace = new Workspace(URI.file(workspaceDir)); const workspaceContextService = new WorkspaceContextService({ resource: URI.file(workspaceDir) });
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile); const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
const service = new WorkspaceConfigurationService(environmentService, workspace); const service = new WorkspaceConfigurationService(workspaceContextService, environmentService);
return service.initialize().then(() => { return service.initialize().then(() => {
const target = sinon.stub(); const target = sinon.stub();
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import 'vs/workbench/parts/search/browser/search.contribution'; // load contributions import 'vs/workbench/parts/search/browser/search.contribution'; // load contributions
import * as assert from 'assert'; import * as assert from 'assert';
import { WorkspaceContextService, IWorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace'; import { WorkspaceContextService, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ISearchService } from 'vs/platform/search/common/search'; import { ISearchService } from 'vs/platform/search/common/search';
...@@ -73,7 +73,7 @@ suite('QuickOpen performance (integration)', () => { ...@@ -73,7 +73,7 @@ suite('QuickOpen performance (integration)', () => {
[ITelemetryService, telemetryService], [ITelemetryService, telemetryService],
[IConfigurationService, new SimpleConfigurationService()], [IConfigurationService, new SimpleConfigurationService()],
[IModelService, new ModelServiceImpl(null, configurationService)], [IModelService, new ModelServiceImpl(null, configurationService)],
[IWorkspaceContextService, new WorkspaceContextService(new Workspace(URI.file(testWorkspacePath)))], [IWorkspaceContextService, new WorkspaceContextService({ resource: URI.file(testWorkspacePath) })],
[IWorkbenchEditorService, new TestEditorService()], [IWorkbenchEditorService, new TestEditorService()],
[IEditorGroupService, new TestEditorGroupService()], [IEditorGroupService, new TestEditorGroupService()],
[IEnvironmentService, TestEnvironmentService], [IEnvironmentService, TestEnvironmentService],
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import 'vs/workbench/parts/search/browser/search.contribution'; // load contributions import 'vs/workbench/parts/search/browser/search.contribution'; // load contributions
import * as assert from 'assert'; import * as assert from 'assert';
import * as fs from 'fs'; import * as fs from 'fs';
import { WorkspaceContextService, IWorkspaceContextService, Workspace } from 'vs/platform/workspace/common/workspace'; import { WorkspaceContextService, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { createSyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService'; import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { ISearchService, IQueryOptions } from 'vs/platform/search/common/search'; import { ISearchService, IQueryOptions } from 'vs/platform/search/common/search';
...@@ -62,7 +62,7 @@ suite('TextSearch performance (integration)', () => { ...@@ -62,7 +62,7 @@ suite('TextSearch performance (integration)', () => {
[ITelemetryService, telemetryService], [ITelemetryService, telemetryService],
[IConfigurationService, new SimpleConfigurationService()], [IConfigurationService, new SimpleConfigurationService()],
[IModelService, new ModelServiceImpl(null, configurationService)], [IModelService, new ModelServiceImpl(null, configurationService)],
[IWorkspaceContextService, new WorkspaceContextService(new Workspace(URI.file(testWorkspacePath)))], [IWorkspaceContextService, new WorkspaceContextService({ resource: URI.file(testWorkspacePath) })],
[IWorkbenchEditorService, new TestEditorService()], [IWorkbenchEditorService, new TestEditorService()],
[IEditorGroupService, new TestEditorGroupService()], [IEditorGroupService, new TestEditorGroupService()],
[IEnvironmentService, TestEnvironmentService], [IEnvironmentService, TestEnvironmentService],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册