SQL Operations Studio Public Preview 1 (0.23) release source code

This commit is contained in:
Karl Burtram
2017-11-09 14:30:27 -08:00
parent b88ecb8d93
commit 3cdac41339
8829 changed files with 759707 additions and 286 deletions

View File

@@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* 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 { Range } from 'vs/editor/common/core/range';
import { IModel } from 'vs/editor/common/editorCommon';
import { CommonEditorRegistry } from 'vs/editor/common/editorCommonExtensions';
import { SymbolInformation, DocumentSymbolProviderRegistry, IOutline } from 'vs/editor/common/modes';
import { IModelService } from 'vs/editor/common/services/modelService';
import { asWinJsPromise } from 'vs/base/common/async';
export function getDocumentSymbols(model: IModel): TPromise<IOutline> {
let entries: SymbolInformation[] = [];
let promises = DocumentSymbolProviderRegistry.all(model).map(support => {
return asWinJsPromise((token) => {
return support.provideDocumentSymbols(model, token);
}).then(result => {
if (Array.isArray(result)) {
entries.push(...result);
}
}, err => {
onUnexpectedExternalError(err);
});
});
return TPromise.join(promises).then(() => {
let flatEntries: SymbolInformation[] = [];
flatten(flatEntries, entries, '');
flatEntries.sort(compareEntriesUsingStart);
return {
entries: flatEntries,
};
});
}
function compareEntriesUsingStart(a: SymbolInformation, b: SymbolInformation): number {
return Range.compareRangesUsingStarts(Range.lift(a.location.range), Range.lift(b.location.range));
}
function flatten(bucket: SymbolInformation[], entries: SymbolInformation[], overrideContainerLabel: string): void {
for (let entry of entries) {
bucket.push({
kind: entry.kind,
location: entry.location,
name: entry.name,
containerName: entry.containerName || overrideContainerLabel
});
}
}
CommonEditorRegistry.registerLanguageCommand('_executeDocumentSymbolProvider', function (accessor, args) {
const { resource } = args;
if (!(resource instanceof URI)) {
throw illegalArgument('resource');
}
const model = accessor.get(IModelService).getModel(resource);
if (!model) {
throw illegalArgument('resource');
}
return getDocumentSymbols(model);
});