本文整理汇总了TypeScript中vs/editor/common/modes.DocumentRangeFormattingEditProviderRegistry.ordered方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DocumentRangeFormattingEditProviderRegistry.ordered方法的具体用法?TypeScript DocumentRangeFormattingEditProviderRegistry.ordered怎么用?TypeScript DocumentRangeFormattingEditProviderRegistry.ordered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/modes.DocumentRangeFormattingEditProviderRegistry
的用法示例。
在下文中一共展示了DocumentRangeFormattingEditProviderRegistry.ordered方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getRealAndSyntheticDocumentFormattersOrdered
export function getRealAndSyntheticDocumentFormattersOrdered(model: ITextModel): DocumentFormattingEditProvider[] {
const result: DocumentFormattingEditProvider[] = [];
const seen = new Set<string>();
// (1) add all document formatter
const docFormatter = DocumentFormattingEditProviderRegistry.ordered(model);
for (const formatter of docFormatter) {
result.push(formatter);
if (formatter.extensionId) {
seen.add(ExtensionIdentifier.toKey(formatter.extensionId));
}
}
// (2) add all range formatter as document formatter (unless the same extension already did that)
const rangeFormatter = DocumentRangeFormattingEditProviderRegistry.ordered(model);
for (const formatter of rangeFormatter) {
if (formatter.extensionId) {
if (seen.has(ExtensionIdentifier.toKey(formatter.extensionId))) {
continue;
}
seen.add(ExtensionIdentifier.toKey(formatter.extensionId));
}
result.push({
displayName: formatter.displayName,
extensionId: formatter.extensionId,
provideDocumentFormattingEdits(model, options, token) {
return formatter.provideDocumentRangeFormattingEdits(model, model.getFullModelRange(), options, token);
}
});
}
return result;
}
示例2: formatDocumentRangeWithFirstProvider
export async function formatDocumentRangeWithFirstProvider(
accessor: ServicesAccessor,
editorOrModel: ITextModel | IActiveCodeEditor,
range: Range,
token: CancellationToken
): Promise<boolean> {
const instaService = accessor.get(IInstantiationService);
const statusBarService = accessor.get(IStatusbarService);
const labelService = accessor.get(ILabelService);
const model = isCodeEditor(editorOrModel) ? editorOrModel.getModel() : editorOrModel;
const [best, ...rest] = DocumentRangeFormattingEditProviderRegistry.ordered(model);
if (!best) {
return false;
}
const ret = await instaService.invokeFunction(formatDocumentRangeWithProvider, best, editorOrModel, range, token);
if (rest.length > 0) {
statusBarService.setStatusMessage(
nls.localize('random.pick', "$(tasklist) Formatted '{0}' with '{1}'", labelService.getUriLabel(model.uri, { relative: true }), best.displayName),
5 * 1000
);
}
return ret;
}
示例3: getDocumentRangeFormattingEdits
export function getDocumentRangeFormattingEdits(model: IReadOnlyModel, range: IEditorRange, options: IFormattingOptions): TPromise<ISingleEditOperation[]> {
const [support] = DocumentRangeFormattingEditProviderRegistry.ordered(model);
if (!support) {
return TPromise.as(undefined);
}
return asWinJsPromise((token) => {
return support.provideDocumentRangeFormattingEdits(model, range, options, token);
});
}
示例4: getDocumentRangeFormattingEditsUntilResult
export async function getDocumentRangeFormattingEditsUntilResult(
workerService: IEditorWorkerService,
model: ITextModel,
range: Range,
options: FormattingOptions,
token: CancellationToken
): Promise<TextEdit[] | undefined> {
const providers = DocumentRangeFormattingEditProviderRegistry.ordered(model);
for (const provider of providers) {
let rawEdits = await Promise.resolve(provider.provideDocumentRangeFormattingEdits(model, range, options, token)).catch(onUnexpectedExternalError);
if (isNonEmptyArray(rawEdits)) {
return await workerService.computeMoreMinimalEdits(model.uri, rawEdits);
}
}
return undefined;
}
示例5: getDocumentRangeFormattingEdits
export function getDocumentRangeFormattingEdits(model: IReadOnlyModel, range: Range, options: FormattingOptions): TPromise<ISingleEditOperation[]> {
const providers = DocumentRangeFormattingEditProviderRegistry.ordered(model);
if (providers.length === 0) {
return TPromise.as(undefined);
}
let result: ISingleEditOperation[];
return sequence(providers.map(provider => {
if (isFalsyOrEmpty(result)) {
return () => {
return asWinJsPromise(token => provider.provideDocumentRangeFormattingEdits(model, range, options, token)).then(value => {
result = value;
}, onUnexpectedExternalError);
};
}
})).then(() => result);
}