提交 20a007cc 编写于 作者: J Johannes Rieken

remove worker particpants

上级 3f9f9b4d
......@@ -414,10 +414,6 @@ export function configureMode(modeId: string, options: any): void {
modeService.configureModeById(modeId, options);
}
export function registerWorkerParticipant(modeId:string, moduleName:string, ctorName:string): void {
ModesRegistry.registerWorkerParticipant(modeId, moduleName, ctorName);
}
export function createCustomMode(language:ILanguage): TPromise<IMode> {
startup.initStaticServicesIfNecessary();
let staticPlatformServices = ensureStaticPlatformServices(null);
......
......@@ -26,7 +26,6 @@ Monaco.Editor.create = standaloneCodeEditor.create;
Monaco.Editor.createModel = standaloneCodeEditor.createModel;
Monaco.Editor.createDiffEditor = standaloneCodeEditor.createDiffEditor;
Monaco.Editor.configureMode = standaloneCodeEditor.configureMode;
Monaco.Editor.registerWorkerParticipant = standaloneCodeEditor.registerWorkerParticipant;
Monaco.Editor.getOrCreateMode = standaloneCodeEditor.getOrCreateMode;
Monaco.Editor.createCustomMode = standaloneCodeEditor.createCustomMode;
Monaco.Editor.colorize = standaloneCodeEditor.colorize;
......
......@@ -9,20 +9,9 @@ import {IHTMLContentElement} from 'vs/base/common/htmlContent';
import {IDisposable} from 'vs/base/common/lifecycle';
import URI from 'vs/base/common/uri';
import {TPromise} from 'vs/base/common/winjs.base';
import {AsyncDescriptor0} from 'vs/platform/instantiation/common/descriptors';
import {IMarker} from 'vs/platform/markers/common/markers';
import * as editorCommon from 'vs/editor/common/editorCommon';
export interface IWorkerParticipantDescriptor {
modeId: string;
moduleId: string;
ctorName: string;
}
export interface IWorkerParticipant {
}
export interface ITokenizationResult {
type?:string;
dontMergeWithPrev?:boolean;
......@@ -159,7 +148,6 @@ export interface IStream {
export interface IModeDescriptor {
id:string;
workerParticipants:AsyncDescriptor0<IWorkerParticipant>[];
}
export interface ILineContext {
......
......@@ -7,7 +7,7 @@
import {EventEmitter} from 'vs/base/common/eventEmitter';
import {IDisposable} from 'vs/base/common/lifecycle';
import {TPromise} from 'vs/base/common/winjs.base';
import {AsyncDescriptor2, createAsyncDescriptor2} from 'vs/platform/instantiation/common/descriptors';
import {AsyncDescriptor1, createAsyncDescriptor1} from 'vs/platform/instantiation/common/descriptors';
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
import {IModeSupportChangedEvent} from 'vs/editor/common/editorCommon';
import * as modes from 'vs/editor/common/modes';
......@@ -22,7 +22,7 @@ export function createWordRegExp(allowInWords:string = ''): RegExp {
export class ModeWorkerManager<W> {
private _descriptor: modes.IModeDescriptor;
private _workerDescriptor: AsyncDescriptor2<string, modes.IWorkerParticipant[], W>;
private _workerDescriptor: AsyncDescriptor1<string, W>;
private _superWorkerModuleId: string;
private _instantiationService: IInstantiationService;
private _workerPiecePromise:TPromise<W>;
......@@ -35,7 +35,7 @@ export class ModeWorkerManager<W> {
instantiationService: IInstantiationService
) {
this._descriptor = descriptor;
this._workerDescriptor = createAsyncDescriptor2(workerModuleId, workerClassName);
this._workerDescriptor = createAsyncDescriptor1(workerModuleId, workerClassName);
this._superWorkerModuleId = superWorkerModuleId;
this._instantiationService = instantiationService;
this._workerPiecePromise = null;
......@@ -57,14 +57,8 @@ export class ModeWorkerManager<W> {
// Second, load the code of the worker (without instantiating it)
return ModeWorkerManager._loadModule(this._workerDescriptor.moduleName);
}).then(() => {
// Then, load & instantiate all the participants
var participants = this._descriptor.workerParticipants;
return TPromise.join<modes.IWorkerParticipant>(participants.map((participant) => {
return this._instantiationService.createInstance(participant);
}));
}).then((participants:modes.IWorkerParticipant[]) => {
// Finally, create the mode worker instance
return this._instantiationService.createInstance<string, modes.IWorkerParticipant[], W>(this._workerDescriptor, this._descriptor.id, participants);
return this._instantiationService.createInstance<string, W>(this._workerDescriptor, this._descriptor.id);
});
}
......
......@@ -7,7 +7,6 @@
import * as nls from 'vs/nls';
import Event, {Emitter} from 'vs/base/common/event';
import {Registry} from 'vs/platform/platform';
import {IWorkerParticipantDescriptor} from 'vs/editor/common/modes';
import {ILanguageExtensionPoint} from 'vs/editor/common/services/modeService';
export interface ILegacyLanguageDefinition {
......@@ -28,7 +27,6 @@ export var Extensions = {
export class EditorModesRegistry {
private _workerParticipants: IWorkerParticipantDescriptor[];
private _compatModes: ILegacyLanguageDefinition[];
private _languages: ILanguageExtensionPoint[];
......@@ -39,36 +37,10 @@ export class EditorModesRegistry {
public onDidAddLanguages: Event<ILanguageExtensionPoint[]> = this._onDidAddLanguages.event;
constructor() {
this._workerParticipants = [];
this._compatModes = [];
this._languages = [];
}
// --- worker participants
public registerWorkerParticipants(participants:IWorkerParticipantDescriptor[]): void {
this._workerParticipants = participants;
}
public registerWorkerParticipant(modeId:string, moduleId:string, ctorName?:string):void {
if (typeof modeId !== 'string') {
throw new Error('InvalidArgument: expected `modeId` to be a string');
}
if (typeof moduleId !== 'string') {
throw new Error('InvalidArgument: expected `moduleId` to be a string');
}
this._workerParticipants.push({
modeId: modeId,
moduleId: moduleId,
ctorName: ctorName
});
}
public getWorkerParticipantsForMode(modeId:string):IWorkerParticipantDescriptor[] {
return this._workerParticipants.filter(p => p.modeId === modeId);
}
public getWorkerParticipants(): IWorkerParticipantDescriptor[] {
return this._workerParticipants;
}
// --- compat modes
......
......@@ -13,7 +13,7 @@ import * as paths from 'vs/base/common/paths';
import {TPromise} from 'vs/base/common/winjs.base';
import mime = require('vs/base/common/mime');
import {IFilesConfiguration} from 'vs/platform/files/common/files';
import {createAsyncDescriptor0, createAsyncDescriptor1} from 'vs/platform/instantiation/common/descriptors';
import {createAsyncDescriptor1} from 'vs/platform/instantiation/common/descriptors';
import {IExtensionService} from 'vs/platform/extensions/common/extensions';
import {IExtensionPointUser, IExtensionMessageCollector, ExtensionsRegistry} from 'vs/platform/extensions/common/extensionsRegistry';
import {IThreadService, Remotable, ThreadAffinity} from 'vs/platform/thread/common/thread';
......@@ -393,10 +393,8 @@ export class ModeServiceImpl implements IModeService {
}
private _createModeDescriptor(modeId:string): modes.IModeDescriptor {
var workerParticipants = ModesRegistry.getWorkerParticipantsForMode(modeId);
return {
id: modeId,
workerParticipants: workerParticipants.map(p => createAsyncDescriptor0(p.moduleId, p.ctorName))
id: modeId
};
}
......@@ -589,8 +587,7 @@ export class MainThreadModeServiceImpl extends ModeServiceImpl {
let initData = {
compatModes: ModesRegistry.getCompatModes(),
languages: ModesRegistry.getLanguages(),
workerParticipants: ModesRegistry.getWorkerParticipants()
languages: ModesRegistry.getLanguages()
};
r._initialize(initData);
......@@ -628,7 +625,6 @@ export class MainThreadModeServiceImpl extends ModeServiceImpl {
export interface IWorkerInitData {
compatModes: ILegacyLanguageDefinition[];
languages: ILanguageExtensionPoint[];
workerParticipants: modes.IWorkerParticipantDescriptor[];
}
@Remotable.WorkerContext('ModeServiceWorkerHelper', ThreadAffinity.All)
......@@ -642,7 +638,6 @@ export class ModeServiceWorkerHelper {
public _initialize(initData:IWorkerInitData): void {
ModesRegistry.registerCompatModes(initData.compatModes);
ModesRegistry.registerLanguages(initData.languages);
ModesRegistry.registerWorkerParticipants(initData.workerParticipants);
}
public _acceptCompatModes(modes:ILegacyLanguageDefinition[]): void {
......
......@@ -39,7 +39,6 @@ export class CSSWorker {
constructor(
modeId: string,
participants: Modes.IWorkerParticipant[],
@IResourceService resourceService: IResourceService,
@IMarkerService markerService: IMarkerService
) {
......
......@@ -10,7 +10,6 @@ import cssWorker = require('vs/languages/css/common/cssWorker');
import URI from 'vs/base/common/uri';
import ResourceService = require('vs/editor/common/services/resourceServiceImpl');
import MarkerService = require('vs/platform/markers/common/markerService');
import EditorCommon = require('vs/editor/common/editorCommon');
import Modes = require('vs/editor/common/modes');
import WinJS = require('vs/base/common/winjs.base');
import cssErrors = require('vs/languages/css/common/parser/cssErrors');
......@@ -40,7 +39,7 @@ suite('Validation - CSS', () => {
resourceService: resourceService,
markerService: markerService
});
var worker = new cssWorker.CSSWorker('mock.mode.id', [], services.resourceService, services.markerService);
var worker = new cssWorker.CSSWorker('mock.mode.id', services.resourceService, services.markerService);
worker.doValidate([url]);
var markers = markerService.read({ resource: url });
......@@ -62,7 +61,7 @@ suite('Validation - CSS', () => {
markerService: markerService
});
var worker = new cssWorker.CSSWorker('mock.mode.id', [], services.resourceService, services.markerService);
var worker = new cssWorker.CSSWorker('mock.mode.id', services.resourceService, services.markerService);
worker.doValidate([url]);
var markers = markerService.read({ resource: url });
......
......@@ -43,7 +43,6 @@ export class HTMLWorker {
constructor(
modeId: string,
participants: Modes.IWorkerParticipant[],
@IResourceService resourceService: IResourceService,
@IMarkerService markerService: IMarkerService,
@IWorkspaceContextService contextService:IWorkspaceContextService
......
......@@ -41,7 +41,7 @@ suite('HTML - worker', () => {
markerService: markerService
});
var worker = new htmlWorker.HTMLWorker(mode.getId(), [], services.resourceService, services.markerService, services.contextService);
var worker = new htmlWorker.HTMLWorker(mode.getId(), services.resourceService, services.markerService, services.contextService);
return { worker: worker, model: model };
};
......
......@@ -22,7 +22,6 @@ import definitions = require('vs/languages/typescript/common/features/definition
import quickFix = require('vs/languages/typescript/common/features/quickFix');
import diagnostics = require('vs/languages/typescript/common/features/diagnostics');
import rename = require('vs/languages/typescript/common/features/rename');
import ShebangRewriter = require('vs/languages/typescript/common/js/shebangRewriter');
import {IMarker, IMarkerData, IMarkerService} from 'vs/platform/markers/common/markers';
import {IResourceService} from 'vs/editor/common/services/resourceService';
......@@ -30,20 +29,14 @@ export class JavaScriptWorker extends typeScriptWorker.TypeScriptWorker2 {
private _fancyRewriters: rewriter.ISyntaxRewriter[];
constructor(modeId: string, participants: Modes.IWorkerParticipant[], @IResourceService resourceService: IResourceService,
constructor(modeId: string, @IResourceService resourceService: IResourceService,
@IMarkerService markerService: IMarkerService) {
super(modeId, participants, resourceService, markerService);
super(modeId, resourceService, markerService);
// since we colorize the shebang we should also always handle it
this._projectService.defaultRewriter = [new ShebangRewriter()];
this._fancyRewriters = [new ShebangRewriter()];
participants.forEach((participant:any) => {
if (typeof participant['computeEdits'] === 'function') {
this._fancyRewriters.push(participant);
}
});
this._projectService.defaultRewriter = [];
this._fancyRewriters = [];
}
_doConfigure(options: any): winjs.TPromise<void> {
......
......@@ -82,7 +82,6 @@ export class JSONWorker implements Modes.IExtraInfoSupport {
constructor(
modeId: string,
participants: Modes.IWorkerParticipant[],
@IResourceService resourceService: IResourceService,
@IMarkerService markerService: IMarkerService,
@IRequestService requestService: IRequestService,
......
......@@ -41,7 +41,7 @@ suite('JSON - Worker', () => {
var _instantiationService = instantiationService.createInstantiationService({
resourceService: resourceModelMock
});
var worker = _instantiationService.createInstance(jsonworker.JSONWorker, mm.getMode().getId(), []);
var worker = _instantiationService.createInstance(jsonworker.JSONWorker, mm.getMode().getId());
return { worker: worker, model: mm };
};
......
......@@ -29,7 +29,7 @@ suite('LESS - Intellisense', () => {
resourceService: resourceService,
});
var worker = new lessWorker.LessWorker('mock.mode.id', [], services.resourceService, services.markerService);
var worker = new lessWorker.LessWorker('mock.mode.id', services.resourceService, services.markerService);
var position: EditorCommon.IPosition;
if (stringBefore === null) {
position = { column: 1, lineNumber: 1 };
......
......@@ -100,7 +100,6 @@ export class MarkdownWorker {
constructor(
modeId: string,
participants: Modes.IWorkerParticipant[],
@IResourceService resourceService: IResourceService,
@IMarkerService markerService: IMarkerService,
@IModeService modeService: IModeService
......
......@@ -26,7 +26,7 @@ suite('SASS - Worker', () => {
resourceService: resourceService,
});
var worker = new sassWorker.SassWorker('mock.mode.id', [], services.resourceService, services.markerService);
var worker = new sassWorker.SassWorker('mock.mode.id', services.resourceService, services.markerService);
return { worker: worker, model: model };
};
......
......@@ -47,7 +47,6 @@ export class TypeScriptWorker2 {
constructor(
modeId: string,
participants: Modes.IWorkerParticipant[],
@IResourceService resourceService: IResourceService,
@IMarkerService markerService: IMarkerService
) {
......
......@@ -11,7 +11,7 @@ import URI from 'vs/base/common/uri';
import strings = require('vs/base/common/strings');
import arrays = require('vs/base/common/arrays');
import paths = require('vs/base/common/paths');
import {ILink, IWorkerParticipant} from 'vs/editor/common/modes';
import {ILink} from 'vs/editor/common/modes';
import {Range} from 'vs/editor/common/core/range';
import {IWorkspaceContextService, IWorkspace} from 'vs/platform/workspace/common/workspace';
......@@ -27,7 +27,6 @@ export class OutputWorker {
constructor(
modeId: string,
participants: IWorkerParticipant[],
@IResourceService resourceService: IResourceService,
@IMarkerService markerService: IMarkerService,
@IWorkspaceContextService contextService:IWorkspaceContextService
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册