提交 c0161e66 编写于 作者: J Johannes Rieken

debt - less addSingleton usage

上级 13cf79ac
......@@ -80,7 +80,7 @@ export interface IExtensionsService {
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
export interface IExtensionTipsService {
serviceId: ServiceIdentifier<any>;
serviceId: ServiceIdentifier<IExtensionTipsService>;
getRecommendations(): TPromise<IExtension[]>;
}
......
......@@ -19,7 +19,8 @@ interface ExtensionRecommendations {
export class ExtensionTipsService implements IExtensionTipsService {
serviceId: any;
serviceId = IExtensionTipsService;
private _recommendations: { [id: string]: boolean; };
private _disposables: IDisposable[] = [];
private _availableRecommendations: ExtensionRecommendations;
......
......@@ -8,13 +8,15 @@ import { Registry } from 'vs/platform/platform';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IStatusbarRegistry, Extensions as StatusbarExtensions, StatusbarItemDescriptor, StatusbarAlignment } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { ExtensionsStatusbarItem } from 'vs/workbench/parts/extensions/electron-browser/extensionsWidgets';
import { IGalleryService, ExtensionsLabel, ExtensionsChannelId } from 'vs/workbench/parts/extensions/common/extensions';
import { IGalleryService, IExtensionTipsService, ExtensionsLabel, ExtensionsChannelId } from 'vs/workbench/parts/extensions/common/extensions';
import { GalleryService } from 'vs/workbench/parts/extensions/common/vsoGalleryService';
import { ExtensionTipsService } from 'vs/workbench/parts/extensions/electron-browser/extensionTipsService';
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ExtensionsWorkbenchExtension } from 'vs/workbench/parts/extensions/electron-browser/extensionsWorkbenchExtension';
import { IOutputChannelRegistry, Extensions as OutputExtensions } from 'vs/workbench/parts/output/common/output';
registerSingleton(IGalleryService, GalleryService);
registerSingleton(IExtensionTipsService, ExtensionTipsService);
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(ExtensionsWorkbenchExtension);
......
......@@ -17,7 +17,6 @@ import { ReloadWindowAction } from 'vs/workbench/electron-browser/actions';
import wbaregistry = require('vs/workbench/common/actionRegistry');
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { ListExtensionsAction, InstallExtensionAction, ListOutdatedExtensionsAction, ListSuggestedExtensionsAction } from './extensionsActions';
import { ExtensionTipsService } from './extensionTipsService';
import { IQuickOpenRegistry, Extensions, QuickOpenHandlerDescriptor } from 'vs/workbench/browser/quickopen';
import {ipcRenderer as ipc} from 'electron';
......@@ -32,6 +31,7 @@ export class ExtensionsWorkbenchExtension implements IWorkbenchContribution {
@IExtensionsService private extensionsService: IExtensionsService,
@IMessageService private messageService: IMessageService,
@IWorkspaceContextService contextService: IWorkspaceContextService,
@IExtensionTipsService extenstionTips: IExtensionTipsService, // this is to eagerly start the service
@IGalleryService galleryService: IGalleryService
) {
this.registerListeners();
......@@ -42,9 +42,6 @@ export class ExtensionsWorkbenchExtension implements IWorkbenchContribution {
this.install(options.extensionsToInstall).done(null, errors.onUnexpectedError);
}
// add service
instantiationService.addSingleton(IExtensionTipsService, this.instantiationService.createInstance(ExtensionTipsService));
const actionRegistry = (<wbaregistry.IWorkbenchActionRegistry> platform.Registry.as(wbaregistry.Extensions.WorkbenchActions));
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(ListExtensionsAction, ListExtensionsAction.ID, ListExtensionsAction.LABEL), ExtensionsLabel);
......
......@@ -268,8 +268,7 @@ suite('Workbench UI Services', () => {
services.set(IFileService, <any> TestFileService);
let inst = new InstantiationService(services);
let textFileService = <ITextFileService>inst.createInstance(<any>TextFileService);
inst.addSingleton(ITextFileService, textFileService);
services.set(ITextFileService, <ITextFileService>inst.createInstance(<any>TextFileService));
services['instantiationService'] = inst;
let activeInput: EditorInput = inst.createInstance(FileEditorInput, toResource('/something.js'), 'text/javascript', void 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册