本文整理汇总了TypeScript中vs/platform/platform.Registry类的典型用法代码示例。如果您正苦于以下问题:TypeScript Registry类的具体用法?TypeScript Registry怎么用?TypeScript Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Registry类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
public run(accessor: ServicesAccessor, editor: ICommonCodeEditor): TPromise<void> {
const quickOpenService = accessor.get(IQuickOpenService);
if (!editor.getModel()) {
return;
}
const {lineNumber, column} = editor.getPosition();
const modeId = editor.getModel().getModeIdAtPosition(lineNumber, column);
const picks: ISnippetPick[] = [];
Registry.as<ISnippetsRegistry>(Extensions.Snippets).visitSnippets(modeId, snippet => {
picks.push({
label: snippet.prefix,
detail: snippet.description,
snippet
});
return true;
});
return quickOpenService.pick(picks).then(pick => {
if (pick) {
SnippetController.get(editor).insertSnippet(pick.snippet.codeSnippet, 0, 0);
}
});
}
示例2: _registerLanguages
_registerLanguages(desc: ILanguageExtensionPoint[]): void {
if (desc.length === 0) {
return;
}
for (let i = 0; i < desc.length; i++) {
this._registerLanguage(desc[i]);
}
// Rebuild fast path maps
this._mimeTypesMap = {};
this._nameMap = {};
this._lowercaseNameMap = {};
Object.keys(this._languages).forEach((langId) => {
let language = this._languages[langId];
if (language.name) {
this._nameMap[language.name] = language.identifier;
}
language.aliases.forEach((alias) => {
this._lowercaseNameMap[alias.toLowerCase()] = language.identifier;
});
language.mimetypes.forEach((mimetype) => {
this._mimeTypesMap[mimetype] = language.identifier;
});
});
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerOverrideIdentifiers(ModesRegistry.getLanguages().map(language => language.id));
}
示例3: getDefaultValues
export function getDefaultValues(): any {
const valueTreeRoot: any = Object.create(null);
const properties = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties();
for (let key in properties) {
let value = properties[key].default;
addToValueTree(valueTreeRoot, key, value);
}
return valueTreeRoot;
}
示例4: getDefaultValues
export function getDefaultValues(): any {
const valueTreeRoot: any = Object.create(null);
const properties = Registry.as<IConfigurationRegistry>(Extensions.Configuration).getConfigurationProperties();
for (let key in properties) {
let value = properties[key].default;
addToValueTree(valueTreeRoot, key, value, message => console.error(`Conflict in default settings: ${message}`));
}
return valueTreeRoot;
}
示例5: test
test("Viewlet extension point and registration", function() {
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).registerViewlet));
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlet));
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlets));
let oldCount = Platform.Registry.as(Extensions.Viewlets).getViewlets().length;
let d = new ViewletDescriptor("moduleId", "ctorName", "reg-test-id", "name");
Platform.Registry.as(Extensions.Viewlets).registerViewlet(d);
assert(d === Platform.Registry.as(Extensions.Viewlets).getViewlet("reg-test-id"));
assert.equal(oldCount + 1, Platform.Registry.as(Extensions.Viewlets).getViewlets().length);
});
示例6: test
test('Viewlet extension point and registration', function () {
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).registerViewlet));
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlet));
assert(Types.isFunction(Platform.Registry.as(Extensions.Viewlets).getViewlets));
let oldCount = Platform.Registry.as(Extensions.Viewlets).getViewlets().length;
let d = new ViewletDescriptor('moduleId', 'ctorName', 'reg-test-id', 'name');
Platform.Registry.as(Extensions.Viewlets).registerViewlet(d);
assert(d === Platform.Registry.as(Extensions.Viewlets).getViewlet('reg-test-id'));
assert.equal(oldCount + 1, Platform.Registry.as(Extensions.Viewlets).getViewlets().length);
});
示例7: registerContributions
export function registerContributions(): void {
// configuration
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
'id': 'problems',
'order': 101,
'title': Messages.PROBLEMS_PANEL_CONFIGURATION_TITLE,
'type': 'object',
'properties': {
'problems.autoReveal': {
'description': Messages.PROBLEMS_PANEL_CONFIGURATION_AUTO_REVEAL,
'type': 'boolean',
'default': true
}
}
});
// markers panel
Registry.as<PanelRegistry>(PanelExtensions.Panels).registerPanel(new PanelDescriptor(
'vs/workbench/parts/markers/browser/markersPanel',
'MarkersPanel',
Constants.MARKERS_PANEL_ID,
Messages.MARKERS_PANEL_TITLE_PROBLEMS,
'markersPanel',
10,
ToggleMarkersPanelAction.ID
));
// actions
const registry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleMarkersPanelAction, ToggleMarkersPanelAction.ID, ToggleMarkersPanelAction.LABEL, {
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KEY_M
}), 'View: Show Problems', Messages.MARKERS_PANEL_VIEW_CATEGORY);
// Retaining old action to show errors and warnings, so that custom bindings to this action for existing users works.
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleErrorsAndWarningsAction, ToggleErrorsAndWarningsAction.ID, ToggleErrorsAndWarningsAction.LABEL), 'Show Errors and Warnings');
}
示例8: test
test("Workbench Action Registration", function() {
let Registry = Platform.Registry.as(Extensions.WorkbenchActions);
let d = new SyncActionDescriptor(MyClass, "id", "name");
let oldActions = Registry.getWorkbenchActions().slice(0);
let oldCount = Registry.getWorkbenchActions().length;
Registry.registerWorkbenchAction(d);
Registry.registerWorkbenchAction(d);
assert.equal(Registry.getWorkbenchActions().length, 1 + oldCount);
assert.strictEqual(d, Registry.getWorkbenchAction("id"));
Registry.setWorkbenchActions(oldActions);
});
示例9: test
test('Test registering the language property', () => {
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
'id': '[a]',
'order': 1,
'title': 'a',
'type': 'object',
'properties': {
'[a]': {
'description': 'a',
'type': 'boolean',
'default': false,
}
}
});
assert.equal(undefined, new model.DefaultConfigModel().getContentsFor('[a]'));
});
示例10: test
test('Test registering the same property again', () => {
Registry.as<IConfigurationRegistry>(Extensions.Configuration).registerConfiguration({
'id': 'a',
'order': 1,
'title': 'a',
'type': 'object',
'properties': {
'a': {
'description': 'a',
'type': 'boolean',
'default': false,
}
}
});
assert.equal(true, new DefaultConfigurationModel().getContentsFor('a'));
});