本文整理汇总了TypeScript中vs/editor/common/modes.HoverProviderRegistry.ordered方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HoverProviderRegistry.ordered方法的具体用法?TypeScript HoverProviderRegistry.ordered怎么用?TypeScript HoverProviderRegistry.ordered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vs/editor/common/modes.HoverProviderRegistry
的用法示例。
在下文中一共展示了HoverProviderRegistry.ordered方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getHover
export function getHover(model: ITextModel, position: Position, token: CancellationToken): Promise<Hover[]> {
const supports = HoverProviderRegistry.ordered(model);
const promises = supports.map(support => {
return Promise.resolve(support.provideHover(model, position, token)).then(hover => {
return hover && isValid(hover) ? hover : undefined;
}, err => {
onUnexpectedExternalError(err);
return undefined;
});
});
return Promise.all(promises).then(coalesce);
}
示例2: provideHover
export function provideHover(model: IReadOnlyModel, position: IEditorPosition, cancellationToken = CancellationToken.None): Thenable<Hover[]> {
const supports = HoverProviderRegistry.ordered(model);
const values: Hover[] = [];
const promises = supports.map((support, idx) => {
return toThenable(support.provideHover(model, position, cancellationToken)).then(result => {
if (result) {
let hasRange = (typeof result.range !== 'undefined');
let hasHtmlContent = (typeof result.htmlContent !== 'undefined' && result.htmlContent && result.htmlContent.length > 0);
if (hasRange && hasHtmlContent) {
values[idx] = result;
}
}
}, err => {
onUnexpectedError(err);
});
});
return TPromise.join(promises).then(() => coalesce(values));
}
示例3: getHover
export function getHover(model: ITextModel, position: Position): TPromise<Hover[]> {
const supports = HoverProviderRegistry.ordered(model);
const values: Hover[] = [];
const promises = supports.map((support, idx) => {
return asWinJsPromise((token) => {
return support.provideHover(model, position, token);
}).then((result) => {
if (result) {
let hasRange = (typeof result.range !== 'undefined');
let hasHtmlContent = typeof result.contents !== 'undefined' && result.contents && result.contents.length > 0;
if (hasRange && hasHtmlContent) {
values[idx] = result;
}
}
}, err => {
onUnexpectedExternalError(err);
});
});
return TPromise.join(promises).then(() => coalesce(values));
}