本文整理匯總了TypeScript中vs/editor/common/modes.DocumentFormattingEditProviderRegistry.all方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DocumentFormattingEditProviderRegistry.all方法的具體用法?TypeScript DocumentFormattingEditProviderRegistry.all怎麽用?TypeScript DocumentFormattingEditProviderRegistry.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/modes.DocumentFormattingEditProviderRegistry
的用法示例。
在下文中一共展示了DocumentFormattingEditProviderRegistry.all方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: run
async run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): Promise<void> {
if (!editor.hasModel()) {
return;
}
const commandService = accessor.get(ICommandService);
const viewletService = accessor.get(IViewletService);
const notificationService = accessor.get(INotificationService);
const model = editor.getModel();
const formatterCount = DocumentFormattingEditProviderRegistry.all(model).length;
if (formatterCount > 1) {
return commandService.executeCommand('editor.action.formatDocument.multiple');
} else if (formatterCount === 1) {
return commandService.executeCommand('editor.action.formatDocument');
} else {
const langName = model.getLanguageIdentifier().language;
const message = nls.localize('no.rovider', "There is no formatter for '{0}'-files installed.", langName);
const choice = {
label: nls.localize('install.formatter', "Install Formatter..."),
run: () => showExtensionQuery(viewletService, `category:formatters ${langName}`)
};
notificationService.prompt(Severity.Info, message, [choice]);
}
}