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


TypeScript languageFeatureRegistry.ordered函數代碼示例

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


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

示例1: getDeclarationsAtPosition

export function getDeclarationsAtPosition(model: IModel, position: IPosition): TPromise<IReference[]> {

	const resource = model.getAssociatedResource();
	const provider = DeclarationRegistry.ordered(model);

	// get results
	const promises = provider.map((provider, idx) => {
		return provider.findDeclaration(resource, position).then(result => {
			return result;
		}, err => {
			onUnexpectedError(err);
		});
	});

	return TPromise.join(promises).then(allReferences => {
		let result: IReference[] = [];
		for (let references of allReferences) {
			if (Array.isArray(references)) {
				result.push(...references);
			} else if (references) {
				result.push(references);
			}
		}
		return result;
	});
}
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:26,代碼來源:goToDeclaration.ts

示例2: formatRange

export function formatRange(model: IModel, range: IRange, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
	const [support] = FormatRegistry.ordered(model)
		.filter(s => typeof s.formatRange === 'function');

	if (!support) {
		return TPromise.as(undefined);
	}
	return support.formatRange(model.getAssociatedResource(), range, options);
}
開發者ID:1424667164,項目名稱:vscode,代碼行數:9,代碼來源:format.ts

示例3: getParameterHints

export function getParameterHints(model:IModel, position:IPosition, triggerCharacter: string): TPromise<IParameterHints> {

	let support = ParameterHintsRegistry.ordered(model)[0];
	if (!support) {
		return TPromise.as(undefined);
	}

	return support.getParameterHints(model.getAssociatedResource(), position, triggerCharacter);
}
開發者ID:sangohan,項目名稱:KodeStudio,代碼行數:9,代碼來源:parameterHints.ts

示例4: formatAfterKeystroke

export function formatAfterKeystroke(model: IModel, position: IPosition, ch: string, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
	const [support] = FormatOnTypeRegistry.ordered(model);
	if (!support) {
		return TPromise.as(undefined);
	}
	if (support.autoFormatTriggerCharacters.indexOf(ch) < 0) {
		return TPromise.as(undefined);
	}
	return support.formatAfterKeystroke(model.getAssociatedResource(), position, ch, options);
}
開發者ID:1424667164,項目名稱:vscode,代碼行數:10,代碼來源:format.ts

示例5: formatDocument

export function formatDocument(model: IModel, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
	const [support] = FormatRegistry.ordered(model);
	if (!support) {
		return TPromise.as(undefined);
	}
	if (typeof support.formatDocument !== 'function') {
		if (typeof support.formatRange === 'function') {
			return formatRange(model, model.getFullModelRange(), options);
		} else {
			return TPromise.as(undefined);
		}
	}

	return support.formatDocument(model.getAssociatedResource(), options);
}
開發者ID:1424667164,項目名稱:vscode,代碼行數:15,代碼來源:format.ts

示例6: asWinJsPromise

function getDefinitions<T>(
	model: ITextModel,
	position: Position,
	registry: LanguageFeatureRegistry<T>,
	provide: (provider: T, model: ITextModel, position: Position, token: CancellationToken) => Location | Location[] | Thenable<Location | Location[]>
): TPromise<Location[]> {
	const provider = registry.ordered(model);

	// get results
	const promises = provider.map((provider, idx) => {
		return asWinJsPromise((token) => {
			return provide(provider, model, position, token);
		}).then(undefined, err => {
			onUnexpectedExternalError(err);
			return null;
		});
	});
	return outputResults(promises);
}
開發者ID:servicesgpr,項目名稱:vscode,代碼行數:19,代碼來源:goToDeclaration.ts

示例7: coalesce

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

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

示例8: asWinJsPromise

function getDefinitions<T>(
	model: ITextModel,
	position: Position,
	registry: LanguageFeatureRegistry<T>,
	provide: (provider: T, model: ITextModel, position: Position, token: CancellationToken) => Location | Location[] | Thenable<Location | Location[]>
): TPromise<DefinitionLink[]> {
	const provider = registry.ordered(model);

	// get results
	const promises = provider.map((provider): TPromise<DefinitionLink | DefinitionLink[]> => {
		return asWinJsPromise((token) => {
			return provide(provider, model, position, token);
		}).then(undefined, err => {
			onUnexpectedExternalError(err);
			return null;
		});
	});
	return TPromise.join(promises)
		.then(flatten)
		.then(references => references.filter(x => !!x));
}
開發者ID:liunian,項目名稱:vscode,代碼行數:21,代碼來源:goToDefinition.ts

示例9: getExtraInfoAtPosition

export function getExtraInfoAtPosition(model: IModel, position: IPosition): TPromise<IComputeExtraInfoResult[]> {

	const resource = model.getAssociatedResource();
	const supports = ExtraInfoRegistry.ordered(model);
	const values: IComputeExtraInfoResult[] = [];

	const promises = supports.map((support, idx) => {
		return support.computeInfo(resource, position).then(result => {
			if (result) {
				let hasRange = (typeof result.range !== 'undefined');
				let hasValue = (typeof result.value !== 'undefined');
				let hasHtmlContent = (typeof result.htmlContent !== 'undefined' && result.htmlContent && result.htmlContent.length > 0);
				if (hasRange && (hasValue || hasHtmlContent)) {
					values[idx]  = result;
				}
			}
		}, err => {
			onUnexpectedError(err);
		});
	});

	return TPromise.join(promises).then(() => coalesce(values));
}
開發者ID:1424667164,項目名稱:vscode,代碼行數:23,代碼來源:hover.ts


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