本文整理汇总了TypeScript中vs/platform/registry/common/platform.Registry.as方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Registry.as方法的具体用法?TypeScript Registry.as怎么用?TypeScript Registry.as使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/platform/registry/common/platform.Registry
的用法示例。
在下文中一共展示了Registry.as方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('lookup with null', async () => {
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
'id': '_testNull',
'type': 'object',
'properties': {
'lookup.service.testNullSetting': {
'type': 'null',
}
}
});
const r = await testFile('config', 'config.json');
const service = new ConfigurationService(r.testFile);
let res = service.inspect('lookup.service.testNullSetting');
assert.strictEqual(res.default, null);
assert.strictEqual(res.value, null);
assert.strictEqual(res.user, undefined);
fs.writeFileSync(r.testFile, '{ "lookup.service.testNullSetting": null }');
await service.reloadConfiguration();
res = service.inspect('lookup.service.testNullSetting');
assert.strictEqual(res.default, null);
assert.strictEqual(res.value, null);
assert.strictEqual(res.user, null);
service.dispose();
return r.cleanUp();
});
示例2: test
test('lookup with null', () => {
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
'id': '_testNull',
'type': 'object',
'properties': {
'lookup.service.testNullSetting': {
'type': 'null',
}
}
});
return testFile('config', 'config.json').then(r => {
const service = new ConfigurationService(new SettingsTestEnvironmentService(parseArgs(process.argv), process.execPath, r.testFile));
let res = service.inspect('lookup.service.testNullSetting');
assert.strictEqual(res.default, null);
assert.strictEqual(res.value, null);
assert.strictEqual(res.user, void 0);
fs.writeFileSync(r.testFile, '{ "lookup.service.testNullSetting": null }');
return service.reloadConfiguration().then(() => {
res = service.inspect('lookup.service.testNullSetting');
assert.strictEqual(res.default, null);
assert.strictEqual(res.value, null);
assert.strictEqual(res.user, null);
service.dispose();
return r.cleanUp();
});
});
});
示例3: _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));
}
示例4: registerShellConfiguration
export function registerShellConfiguration(getDefaultShell?: (p: Platform) => string): void {
const configurationRegistry = Registry.as<IConfigurationRegistry>(Extensions.Configuration);
configurationRegistry.registerConfiguration({
id: 'terminal',
order: 100,
title: nls.localize('terminalIntegratedConfigurationTitle', "Integrated Terminal"),
type: 'object',
properties: {
'terminal.integrated.shell.linux': {
markdownDescription:
getDefaultShell
? nls.localize('terminal.integrated.shell.linux', "The path of the shell that the terminal uses on Linux (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getDefaultShell(Platform.Linux))
: nls.localize('terminal.integrated.shell.linux.noDefault', "The path of the shell that the terminal uses on Linux. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
type: ['string', 'null'],
default: null
},
'terminal.integrated.shell.osx': {
markdownDescription:
getDefaultShell
? nls.localize('terminal.integrated.shell.osx', "The path of the shell that the terminal uses on macOS (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getDefaultShell(Platform.Mac))
: nls.localize('terminal.integrated.shell.osx.noDefault', "The path of the shell that the terminal uses on macOS. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
type: ['string', 'null'],
default: null
},
'terminal.integrated.shell.windows': {
markdownDescription:
getDefaultShell
? nls.localize('terminal.integrated.shell.windows', "The path of the shell that the terminal uses on Windows (default: {0}). [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration).", getDefaultShell(Platform.Windows))
: nls.localize('terminal.integrated.shell.windows.noDefault', "The path of the shell that the terminal uses on Windows. [Read more about configuring the shell](https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration)."),
type: ['string', 'null'],
default: null
}
}
});
}
示例5: test
test('all colors documented', async function () {
const reqContext = await request({ url: 'https://raw.githubusercontent.com/Microsoft/vscode-docs/vnext/docs/getstarted/theme-color-reference.md' }, CancellationToken.None);
const content = await asText(reqContext);
const expression = /\-\s*\`([\w\.]+)\`: (.*)/g;
let m: RegExpExecArray;
let colorsInDoc: { [id: string]: ColorInfo } = Object.create(null);
while (m = expression.exec(content)) {
colorsInDoc[m[1]] = { description: m[2], offset: m.index, length: m.length };
}
let missing = Object.create(null);
let descriptionDiffs: { [id: string]: DescriptionDiff } = Object.create(null);
let themingRegistry = Registry.as<IColorRegistry>(Extensions.ColorContribution);
for (let color of themingRegistry.getColors()) {
if (!colorsInDoc[color.id]) {
if (!color.deprecationMessage) {
missing[color.id] = getDescription(color);
}
} else {
let docDescription = colorsInDoc[color.id].description;
let specDescription = getDescription(color);
if (docDescription !== specDescription) {
descriptionDiffs[color.id] = { docDescription, specDescription };
}
delete colorsInDoc[color.id];
}
}
let colorsInExtensions = await getColorsFromExtension();
for (let colorId in colorsInExtensions) {
if (!colorsInDoc[colorId]) {
missing[colorId] = colorsInExtensions[colorId];
} else {
delete colorsInDoc[colorId];
}
}
for (let colorId of experimental) {
if (missing[colorId]) {
delete missing[colorId];
}
if (colorsInDoc[colorId]) {
assert.fail(`Color ${colorId} found in doc but marked experimental. Please remove from experimental list.`);
}
}
let undocumentedKeys = Object.keys(missing).map(k => `${k}: ${missing[k]}`);
assert.deepEqual(undocumentedKeys, [], 'Undocumented colors ids');
let superfluousKeys = Object.keys(colorsInDoc);
assert.deepEqual(superfluousKeys, [], 'Colors ids in doc that do not exist');
});
示例6: test
test('Viewlet extension point and registration', function () {
assert(Types.isFunction(Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).registerViewlet));
assert(Types.isFunction(Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet));
assert(Types.isFunction(Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets));
let oldCount = Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length;
let d = new ViewletDescriptor(TestViewlet, 'reg-test-id', 'name');
Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).registerViewlet(d);
assert(d === Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlet('reg-test-id'));
assert.equal(oldCount + 1, Platform.Registry.as<ViewletRegistry>(Extensions.Viewlets).getViewlets().length);
});
示例7: test
test('model defaults', async () => {
interface ITestSetting {
configuration: {
service: {
testSetting: string;
}
};
}
const configurationRegistry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration);
configurationRegistry.registerConfiguration({
'id': '_test',
'type': 'object',
'properties': {
'configuration.service.testSetting': {
'type': 'string',
'default': 'isSet'
}
}
});
let serviceWithoutFile = new ConfigurationService('__testFile');
await serviceWithoutFile.initialize();
let setting = serviceWithoutFile.getValue<ITestSetting>();
assert.ok(setting);
assert.equal(setting.configuration.service.testSetting, 'isSet');
return testFile('config', 'config.json').then(async res => {
fs.writeFileSync(res.testFile, '{ "testworkbench.editor.tabs": true }');
const service = new ConfigurationService(res.testFile);
let setting = service.getValue<ITestSetting>();
assert.ok(setting);
assert.equal(setting.configuration.service.testSetting, 'isSet');
fs.writeFileSync(res.testFile, '{ "configuration.service.testSetting": "isChanged" }');
await service.reloadConfiguration();
let setting_1 = service.getValue<ITestSetting>();
assert.ok(setting_1);
assert.equal(setting_1.configuration.service.testSetting, 'isChanged');
service.dispose();
serviceWithoutFile.dispose();
return res.cleanUp();
});
});
示例8: 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().getValue('a'));
});
示例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 DefaultConfigurationModel().getContentsFor('[a]'));
});