当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Registry.as方法代码示例

本文整理汇总了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();
	});
开发者ID:eamodio,项目名称:vscode,代码行数:31,代码来源:configurationService.test.ts

示例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();
			});
		});
	});
开发者ID:AllureFer,项目名称:vscode,代码行数:34,代码来源:configurationService.test.ts

示例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));
	}
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:28,代码来源:languagesRegistry.ts

示例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
			}
		}
	});
}
开发者ID:PKRoma,项目名称:vscode,代码行数:35,代码来源:terminalShellConfig.ts

示例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');

	});
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:53,代码来源:colorRegistry.releaseTest.ts

示例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);
	});
开发者ID:burhandodhy,项目名称:azuredatastudio,代码行数:12,代码来源:viewlet.test.ts

示例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();
		});
	});
开发者ID:PKRoma,项目名称:vscode,代码行数:49,代码来源:configurationService.test.ts

示例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'));
	});
开发者ID:VishalMadhvani,项目名称:vscode,代码行数:16,代码来源:configurationModels.test.ts

示例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]'));
	});
开发者ID:Chan-PH,项目名称:vscode,代码行数:16,代码来源:model.test.ts


注:本文中的vs/platform/registry/common/platform.Registry.as方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。