當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript languageFeatureRegistry.LanguageFeatureRegistry類代碼示例

本文整理匯總了TypeScript中vs/editor/common/modes/languageFeatureRegistry.LanguageFeatureRegistry的典型用法代碼示例。如果您正苦於以下問題:TypeScript LanguageFeatureRegistry類的具體用法?TypeScript LanguageFeatureRegistry怎麽用?TypeScript LanguageFeatureRegistry使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LanguageFeatureRegistry類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1:

function getDefinitions<T>(
	model: ITextModel,
	position: Position,
	registry: LanguageFeatureRegistry<T>,
	provide: (provider: T, model: ITextModel, position: Position) => ProviderResult<DefinitionLink | DefinitionLink[]>
): Promise<DefinitionLink[]> {
	const provider = registry.ordered(model);

	// get results
	const promises = provider.map((provider): Promise<DefinitionLink | DefinitionLink[] | null | undefined> => {
		return Promise.resolve(provide(provider, model, position)).then(undefined, err => {
			onUnexpectedExternalError(err);
			return null;
		});
	});
	return Promise.all(promises)
		.then(flatten)
		.then(coalesce);
}
開發者ID:kumarharsh,項目名稱:vscode,代碼行數:19,代碼來源:goToDefinition.ts

示例2: getCodeInsetData

export function getCodeInsetData(model: ITextModel, token: CancellationToken): Promise<ICodeInsetData[]> {

	const symbols: ICodeInsetData[] = [];
	const providers = CodeInsetProviderRegistry.ordered(model);

	const promises = providers.map(provider =>
		Promise.resolve(provider.provideCodeInsets(model, token)).then(result => {
			if (Array.isArray(result)) {
				for (let symbol of result) {
					symbols.push({ symbol, provider });
				}
			}
		}).catch(onUnexpectedExternalError));

	return Promise.all(promises).then(() => {

		return mergeSort(symbols, (a, b) => {
			// sort by lineNumber, provider-rank, and column
			if (a.symbol.range.startLineNumber < b.symbol.range.startLineNumber) {
				return -1;
			} else if (a.symbol.range.startLineNumber > b.symbol.range.startLineNumber) {
				return 1;
			} else if (providers.indexOf(a.provider) < providers.indexOf(b.provider)) {
				return -1;
			} else if (providers.indexOf(a.provider) > providers.indexOf(b.provider)) {
				return 1;
			} else if (a.symbol.range.startColumn < b.symbol.range.startColumn) {
				return -1;
			} else if (a.symbol.range.startColumn > b.symbol.range.startColumn) {
				return 1;
			} else {
				return 0;
			}
		});
	});
}
開發者ID:eamodio,項目名稱:vscode,代碼行數:36,代碼來源:codeInset.ts


注:本文中的vs/editor/common/modes/languageFeatureRegistry.LanguageFeatureRegistry類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。