提交 a03b3b50 编写于 作者: I isidor

remove .name from IWorkspace

上级 6090860b
......@@ -58,7 +58,7 @@ function createServices(args: ParsedArgs, bufferLogService: BufferLogService): I
const environmentService = new EnvironmentService(args, process.execPath);
const consoleLogService = new ConsoleLogMainService(getLogLevel(environmentService));
const logService = new MultiplexLogService([consoleLogService, bufferLogService]);
const uriLabelService = new UriLabelService(environmentService);
const uriLabelService = new UriLabelService(environmentService, undefined);
process.once('exit', () => logService.dispose());
......
......@@ -508,7 +508,7 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
constructor() {
const resource = URI.from({ scheme: SimpleWorkspaceContextService.SCHEME, authority: 'model', path: '/' });
this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', folders: [new WorkspaceFolder({ uri: resource, name: '', index: 0 })], name: resource.fsPath };
this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', folders: [new WorkspaceFolder({ uri: resource, name: '', index: 0 })] };
}
public getWorkspace(): IWorkspace {
......@@ -609,8 +609,8 @@ export class SimpleUriLabelService implements IUriLabelService {
return resource.path;
}
public getWorkspaceLabel(workspace: IWorkspaceIdentifier | URI, options?: { verbose: boolean; }): string {
throw new Error('Not implemented');
public getWorkspaceLabel(workspace: IWorkspaceIdentifier | URI | IWorkspace, options?: { verbose: boolean; }): string {
return '';
}
public registerFormater(schema: string, formater: UriLabelRules): IDisposable {
......
......@@ -7,13 +7,13 @@ import URI from 'vs/base/common/uri';
import { IDisposable } from 'vs/base/common/lifecycle';
import { Event, Emitter } from 'vs/base/common/event';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceContextService, IWorkspace } from 'vs/platform/workspace/common/workspace';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { isEqual, basenameOrAuthority } from 'vs/base/common/resources';
import { isLinux, isWindows } from 'vs/base/common/platform';
import { tildify, getPathLabel } from 'vs/base/common/labels';
import { ltrim } from 'vs/base/common/strings';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces';
import { IWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, WORKSPACE_EXTENSION, toWorkspaceIdentifier, isWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { localize } from 'vs/nls';
import { isParent } from 'vs/platform/files/common/files';
import { basename, dirname, join } from 'vs/base/common/paths';
......@@ -21,7 +21,7 @@ import { basename, dirname, join } from 'vs/base/common/paths';
export interface IUriLabelService {
_serviceBrand: any;
getLabel(resource: URI, relative?: boolean, forceNoTildify?: boolean): string;
getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier), options?: { verbose: boolean }): string;
getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | IWorkspace), options?: { verbose: boolean }): string;
registerFormater(schema: string, formater: UriLabelRules): IDisposable;
onDidRegisterFormater: Event<{ scheme: string, formater: UriLabelRules }>;
}
......@@ -46,20 +46,16 @@ export class UriLabelService implements IUriLabelService {
private readonly formaters = new Map<string, UriLabelRules>();
private readonly _onDidRegisterFormater = new Emitter<{ scheme: string, formater: UriLabelRules }>();
private contextService: IWorkspaceContextService;
constructor(
@IEnvironmentService private environmentService: IEnvironmentService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
) { }
get onDidRegisterFormater(): Event<{ scheme: string, formater: UriLabelRules }> {
return this._onDidRegisterFormater.event;
}
acquireContextService(contextService: IWorkspaceContextService): void {
this.contextService = contextService;
}
getLabel(resource: URI, relative?: boolean, forceNoTildify?: boolean): string {
if (!resource) {
return undefined;
......@@ -93,7 +89,14 @@ export class UriLabelService implements IUriLabelService {
return this.formatUri(resource, formater, forceNoTildify);
}
getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier), options?: { verbose: boolean }): string {
getWorkspaceLabel(workspace: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | IWorkspace), options?: { verbose: boolean }): string {
if (!isWorkspaceIdentifier(workspace) && !isSingleFolderWorkspaceIdentifier(workspace)) {
workspace = toWorkspaceIdentifier(workspace);
if (!workspace) {
return '';
}
}
// Workspace: Single Folder
if (isSingleFolderWorkspaceIdentifier(workspace)) {
// Folder on disk
......@@ -106,6 +109,7 @@ export class UriLabelService implements IUriLabelService {
}
// Workspace: Saved
console.log(workspace.configPath);
const filename = basename(workspace.configPath);
const workspaceName = filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1);
if (options && options.verbose) {
......
......@@ -17,8 +17,7 @@ suite('URI Label', () => {
let uriLabelService: UriLabelService;
setup(() => {
uriLabelService = new UriLabelService(TestEnvironmentService);
uriLabelService.acquireContextService(new TestContextService());
uriLabelService = new UriLabelService(TestEnvironmentService, new TestContextService());
});
test('file scheme', function () {
......
......@@ -81,7 +81,6 @@ export namespace IWorkspace {
export function isIWorkspace(thing: any): thing is IWorkspace {
return thing && typeof thing === 'object'
&& typeof (thing as IWorkspace).id === 'string'
&& typeof (thing as IWorkspace).name === 'string'
&& Array.isArray((thing as IWorkspace).folders);
}
}
......@@ -93,11 +92,6 @@ export interface IWorkspace {
*/
readonly id: string;
/**
* the name of the workspace.
*/
readonly name: string;
/**
* Folders in the workspace.
*/
......@@ -151,7 +145,6 @@ export class Workspace implements IWorkspace {
constructor(
private _id: string,
private _name: string = '',
folders: WorkspaceFolder[] = [],
private _configuration: URI = null,
private _ctime?: number
......@@ -161,7 +154,6 @@ export class Workspace implements IWorkspace {
update(workspace: Workspace) {
this._id = workspace.id;
this._name = workspace.name;
this._configuration = workspace.configuration;
this._ctime = workspace.ctime;
this.folders = workspace.folders;
......@@ -184,14 +176,6 @@ export class Workspace implements IWorkspace {
return this._ctime;
}
get name(): string {
return this._name;
}
set name(name: string) {
this._name = name;
}
get configuration(): URI {
return this._configuration;
}
......@@ -216,7 +200,7 @@ export class Workspace implements IWorkspace {
}
toJSON(): IWorkspace {
return { id: this.id, folders: this.folders, name: this.name, configuration: this.configuration };
return { id: this.id, folders: this.folders, configuration: this.configuration };
}
}
......
......@@ -13,7 +13,6 @@ export const TestWorkspace = testWorkspace(wsUri);
export function testWorkspace(resource: URI): Workspace {
return new Workspace(
resource.toString(),
resource.fsPath,
toWorkspaceFolders([{ path: resource.fsPath }])
);
}
\ No newline at end of file
}
......@@ -14,7 +14,7 @@ suite('Workspace', () => {
test('getFolder returns the folder with given uri', () => {
const expected = new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 2 });
let testObject = new Workspace('', '', [new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 0 }), expected, new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 2 })]);
let testObject = new Workspace('', [new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 0 }), expected, new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 2 })]);
const actual = testObject.getFolder(expected.uri);
......@@ -23,7 +23,7 @@ suite('Workspace', () => {
test('getFolder returns the folder if the uri is sub', () => {
const expected = new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 0 });
let testObject = new Workspace('', '', [expected, new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 1 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 2 })]);
let testObject = new Workspace('', [expected, new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 1 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 2 })]);
const actual = testObject.getFolder(URI.file('/src/test/a'));
......@@ -32,7 +32,7 @@ suite('Workspace', () => {
test('getFolder returns the closest folder if the uri is sub', () => {
const expected = new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 2 });
let testObject = new Workspace('', '', [new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 0 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 1 }), expected]);
let testObject = new Workspace('', [new WorkspaceFolder({ uri: URI.file('/src/main'), name: '', index: 0 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 1 }), expected]);
const actual = testObject.getFolder(URI.file('/src/test/a'));
......@@ -40,7 +40,7 @@ suite('Workspace', () => {
});
test('getFolder returns null if the uri is not sub', () => {
let testObject = new Workspace('', '', [new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 0 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 1 })]);
let testObject = new Workspace('', [new WorkspaceFolder({ uri: URI.file('/src/test'), name: '', index: 0 }), new WorkspaceFolder({ uri: URI.file('/src/code'), name: '', index: 1 })]);
const actual = testObject.getFolder(URI.file('/src/main/a'));
......
......@@ -23,6 +23,7 @@ import { CommandsRegistry } from 'vs/platform/commands/common/commands';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { areSameExtensions } from 'vs/platform/extensionManagement/common/extensionManagementUtil';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
@extHostNamedCustomer(MainContext.MainThreadWorkspace)
export class MainThreadWorkspace implements MainThreadWorkspaceShape {
......@@ -40,6 +41,7 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
@IWorkspaceEditingService private readonly _workspaceEditingService: IWorkspaceEditingService,
@IStatusbarService private readonly _statusbarService: IStatusbarService,
@IInstantiationService private readonly _instantiationService: IInstantiationService,
@IUriLabelService private readonly _uriLabelService: IUriLabelService
) {
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostWorkspace);
this._contextService.onDidChangeWorkspaceFolders(this._onDidChangeWorkspace, this, this._toDispose);
......@@ -99,7 +101,13 @@ export class MainThreadWorkspace implements MainThreadWorkspaceShape {
}
private _onDidChangeWorkspace(): void {
this._proxy.$acceptWorkspaceData(this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : this._contextService.getWorkspace());
const workspace = this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : this._contextService.getWorkspace();
this._proxy.$acceptWorkspaceData(workspace ? {
configuration: workspace.configuration,
folders: workspace.folders,
id: workspace.id,
name: this._uriLabelService.getWorkspaceLabel(workspace)
} : null);
}
// --- search ---
......@@ -230,4 +238,4 @@ CommandsRegistry.registerCommand('_workbench.enterWorkspace', async function (ac
}
return workspaceEditingService.enterWorkspace(workspace.fsPath);
});
\ No newline at end of file
});
......@@ -485,7 +485,7 @@ export function createApiFactory(
return extHostWorkspace.getWorkspaceFolders();
},
get name() {
return extHostWorkspace.workspace ? extHostWorkspace.workspace.name : undefined;
return extHostWorkspace.name;
},
set name(value) {
throw errors.readonly();
......
......@@ -107,8 +107,8 @@ class ExtHostWorkspaceImpl extends Workspace {
private readonly _workspaceFolders: vscode.WorkspaceFolder[] = [];
private readonly _structure = TernarySearchTree.forPaths<vscode.WorkspaceFolder>();
private constructor(id: string, name: string, folders: vscode.WorkspaceFolder[]) {
super(id, name, folders.map(f => new WorkspaceFolder(f)));
private constructor(id: string, private _name: string, folders: vscode.WorkspaceFolder[]) {
super(id, folders.map(f => new WorkspaceFolder(f)));
// setup the workspace folder data structure
folders.forEach(folder => {
......@@ -117,6 +117,10 @@ class ExtHostWorkspaceImpl extends Workspace {
});
}
get name(): string {
return this._name;
}
get workspaceFolders(): vscode.WorkspaceFolder[] {
return this._workspaceFolders.slice(0);
}
......@@ -166,6 +170,10 @@ export class ExtHostWorkspace implements ExtHostWorkspaceShape {
return this._actualWorkspace;
}
get name(): string {
return this._actualWorkspace ? this._actualWorkspace.name : undefined;
}
private get _actualWorkspace(): ExtHostWorkspaceImpl {
return this._unconfirmedWorkspace || this._confirmedWorkspace;
}
......
......@@ -243,7 +243,7 @@ export class TitlebarPart extends Part implements ITitleService {
const activeEditorShort = editor ? editor.getTitle(Verbosity.SHORT) : '';
const activeEditorMedium = editor ? editor.getTitle(Verbosity.MEDIUM) : activeEditorShort;
const activeEditorLong = editor ? editor.getTitle(Verbosity.LONG) : activeEditorMedium;
const rootName = workspace.name;
const rootName = root ? this.uriLabelService.getWorkspaceLabel(root) : '';
const rootPath = root ? this.uriLabelService.getLabel(root) : '';
const folderName = folder ? folder.name : '';
const folderPath = folder ? this.uriLabelService.getLabel(folder.uri) : '';
......
......@@ -48,7 +48,6 @@ import { RelayURLService } from 'vs/platform/url/common/urlService';
import { MenubarChannelClient } from 'vs/platform/menubar/node/menubarIpc';
import { IMenubarService } from 'vs/platform/menubar/common/menubar';
import { Schemas } from 'vs/base/common/network';
import { IUriLabelService, UriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
gracefulFs.gracefulify(fs); // enable gracefulFs
......@@ -99,15 +98,13 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
const mainServices = createMainProcessServices(mainProcessClient, configuration);
const environmentService = new EnvironmentService(configuration, configuration.execPath);
const uriLabelService = new UriLabelService(environmentService);
const logService = createLogService(mainProcessClient, configuration, environmentService);
logService.trace('openWorkbench configuration', JSON.stringify(configuration));
// 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, uriLabelService).then(workspaceService => {
return createAndInitializeWorkspaceService(configuration, environmentService).then(workspaceService => {
const storageService = createStorageService(workspaceService, environmentService);
uriLabelService.acquireContextService(workspaceService);
return domContentLoaded().then(() => {
......@@ -118,8 +115,7 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
configurationService: workspaceService,
environmentService,
logService,
storageService,
uriLabelService
storageService
}, mainServices, mainProcessClient, configuration);
shell.open();
......@@ -135,10 +131,10 @@ function openWorkbench(configuration: IWindowConfiguration): TPromise<void> {
});
}
function createAndInitializeWorkspaceService(configuration: IWindowConfiguration, environmentService: EnvironmentService, uriLabelService: IUriLabelService): TPromise<WorkspaceService> {
function createAndInitializeWorkspaceService(configuration: IWindowConfiguration, environmentService: EnvironmentService): TPromise<WorkspaceService> {
return validateFolderUri(configuration.folderUri, configuration.verbose).then(validatedFolderUri => {
const workspaceService = new WorkspaceService(environmentService, uriLabelService);
const workspaceService = new WorkspaceService(environmentService);
return workspaceService.initialize(configuration.workspace || validatedFolderUri || configuration).then(() => workspaceService, error => workspaceService);
});
......
......@@ -109,7 +109,6 @@ export interface ICoreServices {
environmentService: IEnvironmentService;
logService: ILogService;
storageService: IStorageService;
uriLabelService: IUriLabelService;
}
/**
......@@ -148,7 +147,6 @@ export class WorkbenchShell extends Disposable {
this.contextService = coreServices.contextService;
this.configurationService = coreServices.configurationService;
this.environmentService = coreServices.environmentService;
this.uriLabelService = coreServices.uriLabelService;
this.logService = coreServices.logService;
this.storageService = coreServices.storageService;
......
......@@ -116,6 +116,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { TelemetryService } from 'vs/platform/telemetry/common/telemetryService';
import { WorkbenchThemeService } from 'vs/workbench/services/themes/electron-browser/workbenchThemeService';
import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService';
import { UriLabelService, IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
interface WorkbenchParams {
configuration: IWindowConfiguration;
......@@ -335,6 +336,10 @@ export class Workbench extends Disposable implements IPartService {
// Clipboard
serviceCollection.set(IClipboardService, new ClipboardService());
// Uri Display
const uriLabelService = new UriLabelService(this.environmentService, this.contextService);
serviceCollection.set(IUriLabelService, uriLabelService);
// Status bar
this.statusbarPart = this.instantiationService.createInstance(StatusbarPart, Identifiers.STATUSBAR_PART);
this._register(toDisposable(() => this.statusbarPart.shutdown()));
......
......@@ -103,7 +103,7 @@ export class EmptyView extends ViewletPanel {
if (this.button) {
this.button.label = nls.localize('addFolder', "Add Folder");
}
this.titleDiv.text(this.contextService.getWorkspace().name);
this.titleDiv.text(EmptyView.NAME);
} else {
this.messageDiv.text(nls.localize('noFolderHelp', "You have not yet opened a folder."));
if (this.button) {
......
......@@ -43,6 +43,7 @@ import { Schemas } from 'vs/base/common/network';
import { INotificationService } from 'vs/platform/notification/common/notification';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
export interface IExplorerViewOptions extends IViewletViewOptions {
viewletState: FileViewletState;
......@@ -94,7 +95,8 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
@IKeybindingService keybindingService: IKeybindingService,
@IContextKeyService contextKeyService: IContextKeyService,
@IConfigurationService configurationService: IConfigurationService,
@IDecorationsService decorationService: IDecorationsService
@IDecorationsService decorationService: IDecorationsService,
@IUriLabelService private uriLabelService: IUriLabelService
) {
super({ ...(options as IViewletPanelOptions), ariaHeaderLabel: nls.localize('explorerSection', "Files Explorer Section") }, keybindingService, contextMenuService, configurationService);
......@@ -147,7 +149,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView
}
public get name(): string {
return this.contextService.getWorkspace().name;
return this.uriLabelService.getWorkspaceLabel(this.contextService.getWorkspace());
}
public get title(): string {
......
......@@ -16,6 +16,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import URI from 'vs/base/common/uri';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IQuickPickItem, IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
export class OpenLogsFolderAction extends Action {
......@@ -42,14 +43,16 @@ export class ShowLogsAction extends Action {
constructor(id: string, label: string,
@IQuickInputService private quickInputService: IQuickInputService,
@IOutputService private outputService: IOutputService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IUriLabelService private uriLabelService: IUriLabelService
) {
super(id, label);
}
run(): TPromise<void> {
const workspaceName = this.uriLabelService.getWorkspaceLabel(this.contextService.getWorkspace());
const entries: IQuickPickItem[] = [
{ id: Constants.rendererLogChannelId, label: this.contextService.getWorkspace().name ? nls.localize('rendererProcess', "Window ({0})", this.contextService.getWorkspace().name) : nls.localize('emptyWindow', "Window") },
{ id: Constants.rendererLogChannelId, label: workspaceName ? nls.localize('rendererProcess', "Window ({0})", workspaceName) : nls.localize('emptyWindow', "Window") },
{ id: Constants.extHostLogChannelId, label: nls.localize('extensionHost', "Extension Host") },
{ id: Constants.sharedLogChannelId, label: nls.localize('sharedProcess', "Shared") },
{ id: Constants.mainLogChannelId, label: nls.localize('mainProcess', "Main") }
......@@ -75,14 +78,16 @@ export class OpenLogFileAction extends Action {
@IEnvironmentService private environmentService: IEnvironmentService,
@ICommandService private commandService: ICommandService,
@IWindowService private windowService: IWindowService,
@IWorkspaceContextService private contextService: IWorkspaceContextService
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IUriLabelService private uriLabelService: IUriLabelService
) {
super(id, label);
}
run(): TPromise<void> {
const workspaceName = this.uriLabelService.getWorkspaceLabel(this.contextService.getWorkspace());
const entries: IQuickPickItem[] = [
{ id: URI.file(paths.join(this.environmentService.logsPath, `renderer${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: this.contextService.getWorkspace().name ? nls.localize('rendererProcess', "Window ({0})", this.contextService.getWorkspace().name) : nls.localize('emptyWindow', "Window") },
{ id: URI.file(paths.join(this.environmentService.logsPath, `renderer${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: workspaceName ? nls.localize('rendererProcess', "Window ({0})", workspaceName) : nls.localize('emptyWindow', "Window") },
{ id: URI.file(paths.join(this.environmentService.logsPath, `exthost${this.windowService.getCurrentWindowId()}.log`)).fsPath, label: nls.localize('extensionHost', "Extension Host") },
{ id: URI.file(paths.join(this.environmentService.logsPath, `sharedprocess.log`)).fsPath, label: nls.localize('sharedProcess', "Shared") },
{ id: URI.file(paths.join(this.environmentService.logsPath, `main.log`)).fsPath, label: nls.localize('mainProcess', "Main") },
......@@ -142,4 +147,4 @@ export class SetLogLevelAction extends Action {
}
return void 0;
}
}
\ No newline at end of file
}
......@@ -41,7 +41,7 @@ suite('QueryBuilder', () => {
instantiationService.stub(IConfigurationService, mockConfigService);
mockContextService = new TestContextService();
mockWorkspace = new Workspace('workspace', 'workspace', toWorkspaceFolders([{ path: ROOT_1_URI.fsPath }]));
mockWorkspace = new Workspace('workspace', toWorkspaceFolders([{ path: ROOT_1_URI.fsPath }]));
mockContextService.setWorkspace(mockWorkspace);
instantiationService.stub(IWorkspaceContextService, mockContextService);
......
......@@ -39,7 +39,7 @@ const untitledBackupPath = path.join(workspaceBackupPath, 'untitled', crypto.cre
class TestBackupFileService extends BackupFileService {
constructor(workspace: Uri, backupHome: string, workspacesJsonPath: string) {
const fileService = new FileService(new TestContextService(new Workspace(workspace.fsPath, workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
const fileService = new FileService(new TestContextService(new Workspace(workspace.fsPath, toWorkspaceFolders([{ path: workspace.fsPath }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
super(workspaceBackupPath, fileService);
}
......
......@@ -41,7 +41,6 @@ import { UserConfiguration } from 'vs/platform/configuration/node/configuration'
import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
import { localize } from 'vs/nls';
import { isEqual } from 'vs/base/common/resources';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
export class WorkspaceService extends Disposable implements IWorkspaceConfigurationService, IWorkspaceContextService {
......@@ -72,7 +71,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
private configurationEditingService: ConfigurationEditingService;
private jsonEditingService: JSONEditingService;
constructor(private environmentService: IEnvironmentService, private uriLabelService: IUriLabelService, private workspaceSettingsRootFolder: string = FOLDER_CONFIG_FOLDER_NAME) {
constructor(private environmentService: IEnvironmentService, private workspaceSettingsRootFolder: string = FOLDER_CONFIG_FOLDER_NAME) {
super();
this.defaultConfiguration = new DefaultConfigurationModel();
......@@ -341,8 +340,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
.then(() => {
const workspaceFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), URI.file(dirname(workspaceConfigPath.fsPath)));
const workspaceId = workspaceIdentifier.id;
const workspaceName = this.uriLabelService.getWorkspaceLabel({ id: workspaceId, configPath: workspaceConfigPath.fsPath });
return new Workspace(workspaceId, workspaceName, workspaceFolders, workspaceConfigPath);
return new Workspace(workspaceId, workspaceFolders, workspaceConfigPath);
});
}
......@@ -364,11 +362,11 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
}
const id = createHash('md5').update(folder.fsPath).update(ctime ? String(ctime) : '').digest('hex');
return new Workspace(id, this.uriLabelService.getWorkspaceLabel(folder), toWorkspaceFolders([{ path: folder.fsPath }]), null, ctime);
return new Workspace(id, toWorkspaceFolders([{ path: folder.fsPath }]), null, ctime);
});
} else {
const id = createHash('md5').update(folder.toString()).digest('hex');
return TPromise.as(new Workspace(id, this.uriLabelService.getWorkspaceLabel(folder), toWorkspaceFolders([{ uri: folder.toString() }]), null));
return TPromise.as(new Workspace(id, toWorkspaceFolders([{ uri: folder.toString() }]), null));
}
}
......
......@@ -115,7 +115,7 @@ suite('WorkspaceConfigurationChangeEvent', () => {
configurationChangeEvent.change(['window.restoreWindows'], URI.file('folder2'));
configurationChangeEvent.telemetryData(ConfigurationTarget.WORKSPACE, {});
let testObject = new WorkspaceConfigurationChangeEvent(configurationChangeEvent, new Workspace('id', 'name',
let testObject = new WorkspaceConfigurationChangeEvent(configurationChangeEvent, new Workspace('id',
[new WorkspaceFolder({ index: 0, name: '1', uri: URI.file('folder1') }),
new WorkspaceFolder({ index: 1, name: '2', uri: URI.file('folder2') }),
new WorkspaceFolder({ index: 2, name: '3', uri: URI.file('folder3') })]));
......
......@@ -39,7 +39,6 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
import { ICommandService } from 'vs/platform/commands/common/commands';
import { CommandService } from 'vs/workbench/services/commands/common/commandService';
import URI from 'vs/base/common/uri';
import { UriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
class SettingsTestEnvironmentService extends EnvironmentService {
......@@ -103,7 +102,7 @@ suite('ConfigurationEditingService', () => {
instantiationService = <TestInstantiationService>workbenchInstantiationService();
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
instantiationService.stub(IEnvironmentService, environmentService);
const workspaceService = new WorkspaceService(environmentService, new UriLabelService(environmentService));
const workspaceService = new WorkspaceService(environmentService);
instantiationService.stub(IWorkspaceContextService, workspaceService);
return workspaceService.initialize(noWorkspace ? {} as IWindowConfiguration : URI.file(workspaceDir)).then(() => {
instantiationService.stub(IConfigurationService, workspaceService);
......
......@@ -35,7 +35,6 @@ import { IJSONEditingService } from 'vs/workbench/services/configuration/common/
import { JSONEditingService } from 'vs/workbench/services/configuration/node/jsonEditingService';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IWindowConfiguration } from 'vs/platform/windows/common/windows';
import { UriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
class SettingsTestEnvironmentService extends EnvironmentService {
......@@ -87,8 +86,7 @@ suite('WorkspaceContextService - Folder', () => {
workspaceResource = folderDir;
const globalSettingsFile = path.join(parentDir, 'settings.json');
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
const uriLabelService = new UriLabelService(environmentService);
workspaceContextService = new WorkspaceService(environmentService, uriLabelService);
workspaceContextService = new WorkspaceService(environmentService);
return (<WorkspaceService>workspaceContextService).initialize(URI.file(folderDir));
});
});
......@@ -145,8 +143,7 @@ suite('WorkspaceContextService - Workspace', () => {
parentResource = parentDir;
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json'));
const uriLabelService = new UriLabelService(environmentService);
const workspaceService = new WorkspaceService(environmentService, uriLabelService);
const workspaceService = new WorkspaceService(environmentService);
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
instantiationService.stub(IWorkspaceContextService, workspaceService);
......@@ -409,8 +406,7 @@ suite('WorkspaceService - Initialization', () => {
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
const uriLabelService = new UriLabelService(environmentService);
const workspaceService = new WorkspaceService(environmentService, uriLabelService);
const workspaceService = new WorkspaceService(environmentService);
instantiationService.stub(IWorkspaceContextService, workspaceService);
instantiationService.stub(IConfigurationService, workspaceService);
instantiationService.stub(IEnvironmentService, environmentService);
......@@ -665,8 +661,7 @@ suite('WorkspaceConfigurationService - Folder', () => {
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
const environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, globalSettingsFile);
const uriLabelService = new UriLabelService(environmentService);
const workspaceService = new WorkspaceService(environmentService, uriLabelService);
const workspaceService = new WorkspaceService(environmentService);
instantiationService.stub(IWorkspaceContextService, workspaceService);
instantiationService.stub(IConfigurationService, workspaceService);
instantiationService.stub(IEnvironmentService, environmentService);
......@@ -941,8 +936,7 @@ suite('WorkspaceConfigurationService-Multiroot', () => {
parentResource = parentDir;
environmentService = new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, path.join(parentDir, 'settings.json'));
const uriLabelService = new UriLabelService(environmentService);
const workspaceService = new WorkspaceService(environmentService, uriLabelService);
const workspaceService = new WorkspaceService(environmentService);
const instantiationService = <TestInstantiationService>workbenchInstantiationService();
instantiationService.stub(IWorkspaceContextService, workspaceService);
......
......@@ -23,7 +23,7 @@ import { IMessagePassingProtocol } from 'vs/base/parts/ipc/node/ipc';
import { generateRandomPipeName, Protocol } from 'vs/base/parts/ipc/node/ipc.net';
import { createServer, Server, Socket } from 'net';
import { Event, Emitter, debounceEvent, mapEvent, anyEvent, fromNodeEventEmitter } from 'vs/base/common/event';
import { IInitData, IWorkspaceData, IConfigurationInitData } from 'vs/workbench/api/node/extHost.protocol';
import { IInitData, IConfigurationInitData } from 'vs/workbench/api/node/extHost.protocol';
import { IExtensionDescription } from 'vs/workbench/services/extensions/common/extensions';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { ICrashReporterService } from 'vs/workbench/services/crashReporter/electron-browser/crashReporterService';
......@@ -38,6 +38,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
import { getPathFromAmdModule } from 'vs/base/common/amd';
import { timeout } from 'vs/base/common/async';
import { isMessageOfType, MessageType, createMessageOfType } from 'vs/workbench/common/extensionHostProtocol';
import { IUriLabelService } from 'vs/platform/uriLabel/common/uriLabel';
export interface IExtensionHostStarter {
readonly onCrashed: Event<[number, string]>;
......@@ -81,7 +82,8 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
@IWorkspaceConfigurationService private readonly _configurationService: IWorkspaceConfigurationService,
@ITelemetryService private readonly _telemetryService: ITelemetryService,
@ICrashReporterService private readonly _crashReporterService: ICrashReporterService,
@ILogService private readonly _logService: ILogService
@ILogService private readonly _logService: ILogService,
@IUriLabelService private readonly _uriLabelService: IUriLabelService
) {
// handle extension host lifecycle a bit special when we know we are developing an extension that runs inside
this._isExtensionDevHost = this._environmentService.isExtensionDevelopment;
......@@ -371,6 +373,7 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
private _createExtHostInitData(): TPromise<IInitData> {
return TPromise.join([this._telemetryService.getTelemetryInfo(), this._extensions]).then(([telemetryInfo, extensionDescriptions]) => {
const configurationData: IConfigurationInitData = { ...this._configurationService.getConfigurationData(), configurationScopes: {} };
const workspace = this._contextService.getWorkspace();
const r: IInitData = {
parentPid: process.pid,
environment: {
......@@ -380,7 +383,12 @@ export class ExtensionHostProcessWorker implements IExtensionHostStarter {
extensionDevelopmentPath: this._environmentService.extensionDevelopmentPath,
extensionTestsPath: this._environmentService.extensionTestsPath
},
workspace: this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : <IWorkspaceData>this._contextService.getWorkspace(),
workspace: this._contextService.getWorkbenchState() === WorkbenchState.EMPTY ? null : {
configuration: workspace.configuration,
folders: workspace.folders,
id: workspace.id,
name: this._uriLabelService.getWorkspaceLabel(workspace)
},
extensions: extensionDescriptions,
// Send configurations scopes only in development mode.
configuration: !this._environmentService.isBuilt || this._environmentService.isExtensionDevelopment ? { ...configurationData, configurationScopes: getScopes() } : configurationData,
......
......@@ -37,7 +37,7 @@ suite('FileService', () => {
const sourceDir = getPathFromAmdModule(require, './fixtures/service');
return pfs.copy(sourceDir, testDir).then(() => {
service = new FileService(new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
service = new FileService(new TestContextService(new Workspace(testDir, toWorkspaceFolders([{ path: testDir }]))), TestEnvironmentService, new TestTextResourceConfigurationService(), new TestConfigurationService(), new TestLifecycleService(), new TestStorageService(), new TestNotificationService(), { disableWatcher: true });
});
});
......@@ -853,7 +853,7 @@ suite('FileService', () => {
const textResourceConfigurationService = new TestTextResourceConfigurationService(configurationService);
const _service = new FileService(
new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))),
new TestContextService(new Workspace(_testDir, toWorkspaceFolders([{ path: _testDir }]))),
TestEnvironmentService,
textResourceConfigurationService,
configurationService,
......@@ -898,7 +898,7 @@ suite('FileService', () => {
const textResourceConfigurationService = new TestTextResourceConfigurationService(configurationService);
const _service = new FileService(
new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))),
new TestContextService(new Workspace(_testDir, toWorkspaceFolders([{ path: _testDir }]))),
TestEnvironmentService,
textResourceConfigurationService,
configurationService,
......@@ -932,7 +932,7 @@ suite('FileService', () => {
const resource = uri.file(path.join(testDir, 'index.html'));
const _service = new FileService(
new TestContextService(new Workspace(_testDir, _testDir, toWorkspaceFolders([{ path: _testDir }]))),
new TestContextService(new Workspace(_testDir, toWorkspaceFolders([{ path: _testDir }]))),
TestEnvironmentService,
new TestTextResourceConfigurationService(),
new TestConfigurationService(),
......
......@@ -86,7 +86,7 @@ suite('KeybindingsEditing', () => {
instantiationService.stub(ILogService, new TestLogService());
instantiationService.stub(IModelService, instantiationService.createInstance(ModelServiceImpl));
instantiationService.stub(IFileService, new FileService(
new TestContextService(new Workspace(testDir, testDir, toWorkspaceFolders([{ path: testDir }]))),
new TestContextService(new Workspace(testDir, toWorkspaceFolders([{ path: testDir }]))),
TestEnvironmentService,
new TestTextResourceConfigurationService(),
new TestConfigurationService(),
......
......@@ -16,7 +16,7 @@ import { FileKind } from 'vs/platform/files/common/files';
suite('Breadcrumb Model', function () {
const workspaceService = new TestContextService(new Workspace('ffff', 'Test', [new WorkspaceFolder({ uri: URI.parse('foo:/bar/baz/ws'), name: 'ws', index: 0 })]));
const workspaceService = new TestContextService(new Workspace('ffff', [new WorkspaceFolder({ uri: URI.parse('foo:/bar/baz/ws'), name: 'ws', index: 0 })]));
const configService = new class extends TestConfigurationService {
getValue(...args: any[]) {
if (args[0] === 'breadcrumbs.filePath') {
......
......@@ -21,7 +21,7 @@ import { Range } from 'vs/editor/common/core/range';
import { Position } from 'vs/editor/common/core/position';
import { IModelService } from 'vs/editor/common/services/modelService';
import { EditOperation } from 'vs/editor/common/core/editOperation';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService } from 'vs/workbench/test/workbenchTestServices';
import { TestFileService, TestEditorService, TestEditorGroupsService, TestEnvironmentService, TestContextService } from 'vs/workbench/test/workbenchTestServices';
import { TPromise } from 'vs/base/common/winjs.base';
import { ResourceTextEdit } from 'vs/editor/common/modes';
import { BulkEditService } from 'vs/workbench/services/bulkEdit/electron-browser/bulkEditService';
......@@ -84,7 +84,7 @@ suite('MainThreadEditors', () => {
}
};
const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new UriLabelService(TestEnvironmentService));
const bulkEditService = new BulkEditService(new NullLogService(), modelService, new TestEditorService(), textModelService, new TestFileService(), textFileService, new UriLabelService(TestEnvironmentService, new TestContextService()));
const rpcProtocol = new TestRPCProtocol();
rpcProtocol.set(ExtHostContext.ExtHostDocuments, new class extends mock<ExtHostDocumentsShape>() {
......
......@@ -271,7 +271,7 @@ export function workbenchInstantiationService(): IInstantiationService {
instantiationService.stub(IHashService, new TestHashService());
instantiationService.stub(ILogService, new TestLogService());
instantiationService.stub(IEditorGroupsService, new TestEditorGroupsService([new TestEditorGroup(0)]));
instantiationService.stub(IUriLabelService, new UriLabelService(TestEnvironmentService));
instantiationService.stub(IUriLabelService, new UriLabelService(TestEnvironmentService, workspaceContextService));
const editorService = new TestEditorService();
instantiationService.stub(IEditorService, editorService);
instantiationService.stub(ICodeEditorService, new TestCodeEditorService());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册