Revert "Revert "Remove typings and replace missing methods with vscodes (#8217)"" (#8242)

* Revert "Revert "Remove typings and replace missing methods with vscodes (#8217)" (#8240)"

This reverts commit e801a04bcf.

* fix runtime error

* add tests for chartview
This commit is contained in:
Anthony Dresser
2019-11-06 15:00:34 -08:00
committed by GitHub
parent df6b6ded33
commit 564f78b6f6
185 changed files with 670 additions and 43395 deletions

View File

@@ -26,6 +26,7 @@ import { VSBuffer } from 'vs/base/common/buffer';
import { IProductService } from 'vs/platform/product/common/productService';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
import { optional } from 'vs/platform/instantiation/common/instantiation';
import { find } from 'vs/base/common/arrays';
interface IRawGalleryExtensionFile {
assetType: string;
@@ -550,16 +551,16 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
if (query.criteria) {
const ids = query.criteria.filter(x => x.filterType === FilterType.ExtensionId).map(v => v.value ? v.value.toLocaleLowerCase() : undefined);
if (ids && ids.length > 0) {
filteredExtensions = filteredExtensions.filter(e => e.extensionId && ids.includes(e.extensionId.toLocaleLowerCase()));
filteredExtensions = filteredExtensions.filter(e => e.extensionId && find(ids, x => x === e.extensionId.toLocaleLowerCase()));
}
const names = query.criteria.filter(x => x.filterType === FilterType.ExtensionName).map(v => v.value ? v.value.toLocaleLowerCase() : undefined);
if (names && names.length > 0) {
filteredExtensions = filteredExtensions.filter(e => e.extensionName && e.publisher.publisherName && names.includes(`${e.publisher.publisherName.toLocaleLowerCase()}.${e.extensionName.toLocaleLowerCase()}`));
filteredExtensions = filteredExtensions.filter(e => e.extensionName && e.publisher.publisherName && find(names, x => x === `${e.publisher.publisherName.toLocaleLowerCase()}.${e.extensionName.toLocaleLowerCase()}`));
}
const categoryFilters = query.criteria.filter(x => x.filterType === FilterType.Category).map(v => v.value ? v.value.toLowerCase() : undefined);
if (categoryFilters && categoryFilters.length > 0) {
// Implement the @category: "language packs" filtering
if (categoryFilters.includes('language packs')) {
if (find(categoryFilters, x => x === 'language packs')) {
filteredExtensions = filteredExtensions.filter(e => {
// we only have 1 version for our extensions in the gallery file, so this should always be the case
if (e.versions.length === 1) {
@@ -611,12 +612,12 @@ export class ExtensionGalleryService implements IExtensionGalleryService {
}
let text = searchText.toLocaleLowerCase();
return !!extension
&& !!(extension.extensionName && extension.extensionName.toLocaleLowerCase().includes(text) ||
extension.publisher && extension.publisher.publisherName && extension.publisher.publisherName.toLocaleLowerCase().includes(text) ||
extension.publisher && extension.publisher.displayName && extension.publisher.displayName.toLocaleLowerCase().includes(text) ||
extension.displayName && extension.displayName.toLocaleLowerCase().includes(text) ||
extension.shortDescription && extension.shortDescription.toLocaleLowerCase().includes(text) ||
extension.extensionId && extension.extensionId.toLocaleLowerCase().includes(text));
&& !!(extension.extensionName && extension.extensionName.toLocaleLowerCase().indexOf(text) > -1 ||
extension.publisher && extension.publisher.publisherName && extension.publisher.publisherName.toLocaleLowerCase().indexOf(text) > -1 ||
extension.publisher && extension.publisher.displayName && extension.publisher.displayName.toLocaleLowerCase().indexOf(text) > -1 ||
extension.displayName && extension.displayName.toLocaleLowerCase().indexOf(text) > -1 ||
extension.shortDescription && extension.shortDescription.toLocaleLowerCase().indexOf(text) > -1 ||
extension.extensionId && extension.extensionId.toLocaleLowerCase().indexOf(text) > -1);
}
public static compareByField(a: any, b: any, fieldName: string): number {

View File

@@ -67,6 +67,7 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IURITransformerService } from 'vs/workbench/api/common/extHostUriTransformerService';
import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
import { IExtHostInitDataService } from 'vs/workbench/api/common/extHostInitDataService';
import { find } from 'vs/base/common/arrays';
export interface IExtensionApiFactory {
(extension: IExtensionDescription, registry: ExtensionDescriptionRegistry, configProvider: ExtHostConfigProvider): typeof vscode;
@@ -127,7 +128,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
// Check that no named customers are missing
// {{SQL CARBON EDIT}} filter out the services we don't expose
const filtered: ProxyIdentifier<any>[] = [ExtHostContext.ExtHostDebugService, ExtHostContext.ExtHostTask];
const expected: ProxyIdentifier<any>[] = values(ExtHostContext).filter(v => !filtered.includes(v));
const expected: ProxyIdentifier<any>[] = values(ExtHostContext).filter(v => !find(filtered, x => x === v));
rpcProtocol.assertRegistered(expected);
// Other instances

View File

@@ -11,7 +11,7 @@ import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/co
import { dispose, Disposable, DisposableStore } from 'vs/base/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
import { ResourceMap } from 'vs/base/common/map';
import { coalesce } from 'vs/base/common/arrays';
import { coalesce, firstIndex } from 'vs/base/common/arrays';
// {{SQL CARBON EDIT}}
import { QueryInput } from 'sql/workbench/parts/query/common/queryInput';
@@ -740,7 +740,7 @@ export class EditorGroup extends Disposable {
if (editor instanceof QueryInput && editor.matchInputInstanceType(FileEditorInput) && !editor.isDirty() && await editor.inputFileExists() === false && this.editors.length > 1) {
// remove from editors list so that they do not get restored
this.editors.splice(n, 1);
let index = this.mru.findIndex(e => e.matches(editor));
let index = firstIndex(this.mru, e => e.matches(editor));
// remove from MRU list otherwise later if we try to close them it leaves a sticky active editor with no data
this.mru.splice(index, 1);

View File

@@ -26,7 +26,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import { IExtensionsConfiguration, ConfigurationKey, ShowRecommendationsOnlyOnDemandKey, IExtensionsViewlet, IExtensionsWorkbenchService, EXTENSIONS_CONFIG } from 'vs/workbench/contrib/extensions/common/extensions';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { flatten, distinct, shuffle, coalesce } from 'vs/base/common/arrays';
import { flatten, distinct, shuffle, coalesce, firstIndex } from 'vs/base/common/arrays';
import { guessMimeTypes, MIME_UNKNOWN } from 'vs/base/common/mime';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { IRequestService, asJson } from 'vs/platform/request/common/request';
@@ -1209,7 +1209,7 @@ export class ExtensionTipsService extends Disposable implements IExtensionTipsSe
recommendationMessage = localize('VisualizerExtensionsRecommended', "Azure Data Studio has extension recommendations for data visualization.\nOnce installed, you can select the Visualizer icon to visualize your query results.");
}
Promise.all([getRecommendationPromise, getLocalExtensionPromise]).then(() => {
if (!recommendations.every(rec => { return localExtensions.findIndex(local => local.identifier.id.toLocaleLowerCase() === rec.extensionId.toLocaleLowerCase()) !== -1; })) {
if (!recommendations.every(rec => { return firstIndex(localExtensions, local => local.identifier.id.toLocaleLowerCase() === rec.extensionId.toLocaleLowerCase()) !== -1; })) {
return new Promise<void>(c => {
this.notificationService.prompt(
Severity.Info,

View File

@@ -34,7 +34,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { distinct, coalesce } from 'vs/base/common/arrays';
import { distinct, coalesce, firstIndex } from 'vs/base/common/arrays';
import { IExperimentService, IExperiment, ExperimentActionType } from 'vs/workbench/contrib/experiments/common/experimentService';
import { alert } from 'vs/base/browser/ui/aria/aria';
import { IListContextMenuEvent } from 'vs/base/browser/ui/list/list';
@@ -653,8 +653,8 @@ export class ExtensionsListView extends ViewletPanel {
// sort the marketplace extensions
pager.firstPage.sort((a, b) => {
let isRecommendedA: boolean = recommmended.findIndex(ext => ext.extensionId === `${a.publisher}.${a.name}`) > -1;
let isRecommendedB: boolean = recommmended.findIndex(ext => ext.extensionId === `${b.publisher}.${b.name}`) > -1;
let isRecommendedA: boolean = firstIndex(recommmended, ext => ext.extensionId === `${a.publisher}.${a.name}`) > -1;
let isRecommendedB: boolean = firstIndex(recommmended, ext => ext.extensionId === `${b.publisher}.${b.name}`) > -1;
// sort recommeded extensions before other extensions
if (isRecommendedA !== isRecommendedB) {
@@ -686,7 +686,7 @@ export class ExtensionsListView extends ViewletPanel {
// filter out installed extensions and the extensions not in the recommended list
pager.firstPage = pager.firstPage.filter((p) => {
const extensionId = `${p.publisher}.${p.name}`;
return installedExtensions.indexOf(extensionId) === -1 && recommmended.findIndex(ext => ext.extensionId === extensionId) !== -1;
return installedExtensions.indexOf(extensionId) === -1 && firstIndex(recommmended, ext => ext.extensionId === extensionId) !== -1;
});
pager.total = pager.firstPage.length;
pager.pageSize = pager.firstPage.length;

View File

@@ -210,7 +210,7 @@ export class ExtensionHostProcessManager extends Disposable {
// Check that no named customers are missing
// {{SQL CARBON EDIT}} filter out services we don't expose
const filtered: ProxyIdentifier<any>[] = [MainContext.MainThreadDebugService, MainContext.MainThreadTask];
const expected: ProxyIdentifier<any>[] = Object.keys(MainContext).map((key) => (<any>MainContext)[key]).filter(v => !filtered.includes(v));
const expected: ProxyIdentifier<any>[] = Object.keys(MainContext).map((key) => (<any>MainContext)[key]).filter(v => !filtered.some(x => x === v));
this._extensionHostProcessRPCProtocol.assertRegistered(expected);
return this._extensionHostProcessRPCProtocol.getProxy(ExtHostContext.ExtHostExtensionService);