本文整理匯總了TypeScript中vs/editor/common/modes.CodeLensProviderRegistry.ordered方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript CodeLensProviderRegistry.ordered方法的具體用法?TypeScript CodeLensProviderRegistry.ordered怎麽用?TypeScript CodeLensProviderRegistry.ordered使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/editor/common/modes.CodeLensProviderRegistry
的用法示例。
在下文中一共展示了CodeLensProviderRegistry.ordered方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getCodeLensData
export function getCodeLensData(model: IModel): TPromise<ICodeLensData[]> {
const symbols: ICodeLensData[] = [];
const provider = CodeLensProviderRegistry.ordered(model);
const promises = provider.map(provider => asWinJsPromise(token => provider.provideCodeLenses(model, token)).then(result => {
if (Array.isArray(result)) {
for (let symbol of result) {
symbols.push({ symbol, provider });
}
}
}, onUnexpectedExternalError));
return TPromise.join(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 (provider.indexOf(a.provider) < provider.indexOf(b.provider)) {
return -1;
} else if (provider.indexOf(a.provider) > provider.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;
}
});
});
}
示例2: getCodeLensData
export function getCodeLensData(model: IModel): TPromise<ICodeLensData[]> {
const symbols: ICodeLensData[] = [];
const provider = CodeLensProviderRegistry.ordered(model);
const promises = provider.map(provider => asWinJsPromise(token => provider.provideCodeLenses(model, token)).then(result => {
if (Array.isArray(result)) {
for (let symbol of result) {
symbols.push({ symbol, provider });
}
}
}, onUnexpectedError));
return TPromise.join(promises).then(() => {
return symbols.sort((a, b) => {
// sort by range and provider rank
let ret = Range.compareRangesUsingStarts(a.symbol.range, b.symbol.range);
if (ret === 0) {
ret = provider.indexOf(a.provider) - provider.indexOf(b.provider);
}
return ret;
});
});
}