本文整理汇总了TypeScript中vs/platform/platform.Registry.add方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Registry.add方法的具体用法?TypeScript Registry.add怎么用?TypeScript Registry.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/platform/platform.Registry
的用法示例。
在下文中一共展示了Registry.add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: registerWorkbenchContribution
/**
* Registers a workbench contribution to the platform that will be loaded when the workbench starts and disposed when
* the workbench shuts down.
*/
registerWorkbenchContribution(contribution: IWorkbenchContributionSignature): void;
/**
* Returns all workbench contributions that are known to the platform.
*/
getWorkbenchContributions(): IWorkbenchContribution[];
setInstantiationService(service: IInstantiationService): void;
}
class WorkbenchContributionsRegistry extends BaseRegistry<IWorkbenchContribution> implements IWorkbenchContributionsRegistry {
public registerWorkbenchContribution(ctor: IWorkbenchContributionSignature): void {
super._register(ctor);
}
public getWorkbenchContributions(): IWorkbenchContribution[] {
return super._getInstances();
}
public setWorkbenchContributions(contributions: IWorkbenchContribution[]): void {
super._setInstances(contributions);
}
}
Registry.add(Extensions.Workbench, new WorkbenchContributionsRegistry());
示例2: registerChannel
/**
* Make an output channel known to the output world.
*/
registerChannel(id: string, name: string): void;
/**
* Returns the list of channels known to the output world.
*/
getChannels(): { id: string, label: string }[];
}
class OutputChannelRegistry implements IOutputChannelRegistry {
private channels: { id: string, label: string }[];
constructor() {
this.channels = [];
}
public registerChannel(id: string, label: string): void {
if (this.channels.every(channel => channel.id !== id)) {
this.channels.push({ id, label });
}
}
public getChannels(): { id: string, label: string }[] {
return this.channels;
}
}
Registry.add(Extensions.OutputChannels, new OutputChannelRegistry());
示例3: registerStatusbarItem
}
}
export interface IStatusbarRegistry {
registerStatusbarItem(descriptor: StatusbarItemDescriptor): void;
items: StatusbarItemDescriptor[];
}
class StatusbarRegistry implements IStatusbarRegistry {
private _items: StatusbarItemDescriptor[];
constructor() {
this._items = [];
}
public get items(): StatusbarItemDescriptor[] {
return this._items;
}
public registerStatusbarItem(descriptor: StatusbarItemDescriptor): void {
this._items.push(descriptor);
}
}
export const Extensions = {
Statusbar: 'workbench.contributions.statusbar'
};
Registry.add(Extensions.Statusbar, new StatusbarRegistry());
示例4: getPanels
return this.getComposite(id);
}
/**
* Returns an array of registered panels known to the platform.
*/
public getPanels(): PanelDescriptor[] {
return this.getComposits();
}
/**
* Sets the id of the panel that should open on startup by default.
*/
public setDefaultPanelId(id: string): void {
this.defaultPanelId = id;
}
/**
* Gets the id of the panel that should open on startup by default.
*/
public getDefaultPanelId(): string {
return this.defaultPanelId;
}
}
export const Extensions = {
Panels: 'workbench.contributions.panels'
};
Registry.add(Extensions.Panels, new PanelRegistry());
示例5: getModeId
LanguageExtensions.registerCompatMode(def);
}
public getModeId(commaSeparatedMimetypesOrCommaSeparatedIds: string): string {
var modeIds = LanguageExtensions.extractModeIds(commaSeparatedMimetypesOrCommaSeparatedIds);
if (modeIds.length > 0) {
return modeIds[0];
}
return null;
}
}
var mR = new EditorModesRegistry();
Registry.add(Extensions.EditorModes, mR);
export function registerMode(def:ILegacyLanguageDefinition): void {
mR.registerMode(def);
}
export function registerWorkerParticipant(modeId:string, moduleId:string, ctorName?:string): void {
mR.registerWorkerParticipant(modeId, createAsyncDescriptor0<Modes.IWorkerParticipant>(moduleId, ctorName));
}
// TODO@Martin: find a better home for this code:
// TODO@Martin: modify suggestSupport to return a boolean if snippets should be presented or not
// and turn this into a real registry
示例6: return
return (this.mapActionIdToMeta[id] && this.mapActionIdToMeta[id].alias) || null;
}
public getWorkbenchActions(): SyncActionDescriptor[] {
return collections.values(this.workbenchActions);
}
public setWorkbenchActions(actions: SyncActionDescriptor[]): void {
this.workbenchActions = Object.create(null);
this.mapActionIdToMeta = Object.create(null);
actions.forEach(action => this.registerWorkbenchAction(action, ''), this);
}
}
Registry.add(Extensions.WorkbenchActions, new WorkbenchActionRegistry());
function registerWorkbenchCommandFromAction(descriptor: SyncActionDescriptor): void {
let when = descriptor.keybindingContext;
let weight = (typeof descriptor.keybindingWeight === 'undefined' ? KeybindingsRegistry.WEIGHT.workbenchContrib() : descriptor.keybindingWeight);
let keybindings = descriptor.keybindings;
let desc: ICommandAndKeybindingRule = {
id: descriptor.id,
handler: createCommandHandler(descriptor),
weight: weight,
when: when,
primary: keybindings && keybindings.primary,
secondary: keybindings && keybindings.secondary,
win: keybindings && keybindings.win,
mac: keybindings && keybindings.mac,
示例7: activate
this._telemetryAppenderCtors.push(ctor);
}
public activate(instantiationService: IInstantiationService): void {
const service = instantiationService.getInstance(ITelemetryService);
for (let ctor of this._telemetryAppenderCtors) {
const instance = instantiationService.createInstance(ctor);
service.addTelemetryAppender(instance);
}
// can only be done once
this._telemetryAppenderCtors = undefined;
}
}
Registry.add(Extenstions.TelemetryAppenders, new TelemetryAppendersRegistry());
// --- util
export function anonymize(input: string): string {
if (!input) {
return input;
}
let r = '';
for (let i = 0; i < input.length; i++) {
let ch = input[i];
if (ch >= '0' && ch <= '9') {
r += '0';
continue;
}