mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -3,25 +3,22 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { illegalArgument, onUnexpectedExternalError } from 'vs/base/common/errors';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { ITextModel } from 'vs/editor/common/model';
|
||||
import { registerLanguageCommand } from 'vs/editor/browser/editorExtensions';
|
||||
import { DocumentSymbol, DocumentSymbolProviderRegistry } from 'vs/editor/common/modes';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { asWinJsPromise } from 'vs/base/common/async';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
|
||||
export function getDocumentSymbols(model: ITextModel): TPromise<DocumentSymbol[]> {
|
||||
export function getDocumentSymbols(model: ITextModel, flat: boolean, token: CancellationToken): Thenable<DocumentSymbol[]> {
|
||||
|
||||
let roots: DocumentSymbol[] = [];
|
||||
|
||||
let promises = DocumentSymbolProviderRegistry.all(model).map(support => {
|
||||
|
||||
return asWinJsPromise(token => support.provideDocumentSymbols(model, token)).then(result => {
|
||||
return Promise.resolve(support.provideDocumentSymbols(model, token)).then(result => {
|
||||
if (Array.isArray(result)) {
|
||||
roots.push(...result);
|
||||
}
|
||||
@@ -30,9 +27,16 @@ export function getDocumentSymbols(model: ITextModel): TPromise<DocumentSymbol[]
|
||||
});
|
||||
});
|
||||
|
||||
return TPromise.join(promises).then(() => {
|
||||
return Promise.all(promises).then(() => {
|
||||
let flatEntries: DocumentSymbol[] = [];
|
||||
flatten(flatEntries, roots, '');
|
||||
if (token.isCancellationRequested) {
|
||||
return flatEntries;
|
||||
}
|
||||
if (flat) {
|
||||
flatten(flatEntries, roots, '');
|
||||
} else {
|
||||
flatEntries = roots;
|
||||
}
|
||||
flatEntries.sort(compareEntriesUsingStart);
|
||||
return flatEntries;
|
||||
});
|
||||
@@ -69,5 +73,5 @@ registerLanguageCommand('_executeDocumentSymbolProvider', function (accessor, ar
|
||||
if (!model) {
|
||||
throw illegalArgument('resource');
|
||||
}
|
||||
return getDocumentSymbols(model);
|
||||
return getDocumentSymbols(model, false, CancellationToken.None);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user