mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-17 09:35:37 -05:00
Remove typings and replace missing methods with vscodes (#8217)
* remove typings and replace missing methods with vscodes * fix strict-null-checks * fix tests
This commit is contained in:
@@ -15,6 +15,8 @@ import {
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { UpdateAccountListEventParams } from 'sql/platform/accounts/common/eventTypes';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadAccountManagement)
|
||||
export class MainThreadAccountManagement extends Disposable implements MainThreadAccountManagementShape {
|
||||
@@ -36,7 +38,7 @@ export class MainThreadAccountManagement extends Disposable implements MainThrea
|
||||
return;
|
||||
}
|
||||
|
||||
const providerMetadataIndex = Object.values(this._providerMetadata).findIndex((providerMetadata: azdata.AccountProviderMetadata) => providerMetadata.id === e.providerId);
|
||||
const providerMetadataIndex = firstIndex(values(this._providerMetadata), (providerMetadata: azdata.AccountProviderMetadata) => providerMetadata.id === e.providerId);
|
||||
if (providerMetadataIndex === -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { MainThreadDashboardWebviewShape, SqlMainContext, ExtHostDashboardWebvie
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { IDashboardViewService, IDashboardWebview } from 'sql/platform/dashboard/browser/dashboardViewService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadDashboardWebview)
|
||||
export class MainThreadDashboardWebview implements MainThreadDashboardWebviewShape {
|
||||
@@ -23,7 +24,7 @@ export class MainThreadDashboardWebview implements MainThreadDashboardWebviewSha
|
||||
) {
|
||||
this._proxy = context.getProxy(SqlExtHostContext.ExtHostDashboardWebviews);
|
||||
viewService.onRegisteredWebview(e => {
|
||||
if (this.knownWidgets.includes(e.id)) {
|
||||
if (find(this.knownWidgets, x => x === e.id)) {
|
||||
let handle = MainThreadDashboardWebview._handlePool++;
|
||||
this._dialogs.set(handle, e);
|
||||
this._proxy.$registerWidget(handle, e.id, e.connection, e.serverInfo);
|
||||
|
||||
@@ -25,6 +25,7 @@ import { ISerializationService } from 'sql/platform/serialization/common/seriali
|
||||
import { IFileBrowserService } from 'sql/platform/fileBrowser/common/interfaces';
|
||||
import { IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
/**
|
||||
* Main thread class for handling data protocol management registration.
|
||||
@@ -521,7 +522,7 @@ export class MainThreadDataProtocol extends Disposable implements MainThreadData
|
||||
}
|
||||
|
||||
public $onObjectExplorerNodeExpanded(providerId: string, expandResponse: azdata.ObjectExplorerExpandInfo): void {
|
||||
let expandInfo: NodeExpandInfoWithProviderId = Object.assign({ providerId: providerId }, expandResponse);
|
||||
let expandInfo: NodeExpandInfoWithProviderId = assign({ providerId: providerId }, expandResponse);
|
||||
this._objectExplorerService.onNodeExpanded(expandInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IModelViewService } from 'sql/platform/modelComponents/browser/modelViewService';
|
||||
import { IItemConfig, IComponentShape } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IModelView } from 'sql/platform/model/browser/modelViewService';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
|
||||
@extHostNamedCustomer(SqlMainContext.MainThreadModelView)
|
||||
@@ -29,7 +30,7 @@ export class MainThreadModelView extends Disposable implements MainThreadModelVi
|
||||
super();
|
||||
this._proxy = _context.getProxy(SqlExtHostContext.ExtHostModelView);
|
||||
viewService.onRegisteredModelView(view => {
|
||||
if (this.knownWidgets.includes(view.id)) {
|
||||
if (find(this.knownWidgets, x => x === view.id)) {
|
||||
let handle = MainThreadModelView._handlePool++;
|
||||
this._dialogs.set(handle, view);
|
||||
this._proxy.$registerWidget(handle, view.id, view.connection, view.serverInfo);
|
||||
|
||||
@@ -33,6 +33,7 @@ import { viewColumnToEditorGroup } from 'vs/workbench/api/common/shared/editor';
|
||||
import { notebookModeId } from 'sql/workbench/browser/customInputConverter';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
class MainThreadNotebookEditor extends Disposable {
|
||||
private _contentChangedEmitter = new Emitter<NotebookContentChange>();
|
||||
@@ -372,7 +373,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
let cell: ICellModel;
|
||||
if (cellUri) {
|
||||
let uriString = URI.revive(cellUri).toString();
|
||||
cell = editor.cells.find(c => c.cellUri.toString() === uriString);
|
||||
cell = find(editor.cells, c => c.cellUri.toString() === uriString);
|
||||
// If it's markdown what should we do? Show notification??
|
||||
} else {
|
||||
// Use the active cell in this case, or 1st cell if there's none active
|
||||
@@ -394,11 +395,11 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
let endCell: ICellModel;
|
||||
if (startCellUri) {
|
||||
let uriString = URI.revive(startCellUri).toString();
|
||||
startCell = editor.cells.find(c => c.cellUri.toString() === uriString);
|
||||
startCell = find(editor.cells, c => c.cellUri.toString() === uriString);
|
||||
}
|
||||
if (endCellUri) {
|
||||
let uriString = URI.revive(endCellUri).toString();
|
||||
endCell = editor.cells.find(c => c.cellUri.toString() === uriString);
|
||||
endCell = find(editor.cells, c => c.cellUri.toString() === uriString);
|
||||
}
|
||||
return editor.runAllCells(startCell, endCell);
|
||||
}
|
||||
@@ -412,7 +413,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
|
||||
let cell: ICellModel;
|
||||
if (cellUri) {
|
||||
let uriString = URI.revive(cellUri).toString();
|
||||
cell = editor.cells.find(c => c.cellUri.toString() === uriString);
|
||||
cell = find(editor.cells, c => c.cellUri.toString() === uriString);
|
||||
// If it's markdown what should we do? Show notification??
|
||||
} else {
|
||||
// Use the active cell in this case, or 1st cell if there's none active
|
||||
|
||||
@@ -13,6 +13,8 @@ import {
|
||||
import { AzureResource } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
|
||||
export class ExtHostAccountManagement extends ExtHostAccountManagementShape {
|
||||
private _handlePool: number = 0;
|
||||
@@ -94,7 +96,7 @@ export class ExtHostAccountManagement extends ExtHostAccountManagementShape {
|
||||
return this.$getAllAccounts().then(() => {
|
||||
for (const handle in this._accounts) {
|
||||
const providerHandle = parseInt(handle);
|
||||
if (this._accounts[handle].findIndex((acct) => acct.key.accountId === account.key.accountId) !== -1) {
|
||||
if (firstIndex(this._accounts[handle], (acct) => acct.key.accountId === account.key.accountId) !== -1) {
|
||||
return this._withProvider(providerHandle, (provider: azdata.AccountProvider) => provider.getSecurityToken(account, resource));
|
||||
}
|
||||
}
|
||||
@@ -115,7 +117,7 @@ export class ExtHostAccountManagement extends ExtHostAccountManagementShape {
|
||||
let self = this;
|
||||
|
||||
// Look for any account providers that have the same provider ID
|
||||
let matchingProviderIndex = Object.values(this._providers).findIndex((provider: AccountProviderWithMetadata) => {
|
||||
let matchingProviderIndex = firstIndex(values(this._providers), (provider: AccountProviderWithMetadata) => {
|
||||
return provider.metadata.id === providerMetadata.id;
|
||||
});
|
||||
if (matchingProviderIndex >= 0) {
|
||||
|
||||
@@ -12,6 +12,7 @@ import { SqlMainContext, MainThreadDataProtocolShape, ExtHostDataProtocolShape }
|
||||
import { DataProviderType } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IURITransformer } from 'vs/base/common/uriIpc';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
|
||||
@@ -71,7 +72,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
if (!providersForType) {
|
||||
return undefined;
|
||||
}
|
||||
return providersForType.find(provider => provider.providerId === providerId) as T;
|
||||
return find(providersForType, provider => provider.providerId === providerId) as T;
|
||||
}
|
||||
|
||||
public getProvidersByType<T extends azdata.DataProvider>(providerType: azdata.DataProviderType): T[] {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { IMainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { deepClone } from 'vs/base/common/objects';
|
||||
import { deepClone, assign } from 'vs/base/common/objects';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as nls from 'vs/nls';
|
||||
|
||||
@@ -15,6 +15,7 @@ import * as azdata from 'azdata';
|
||||
import { SqlMainContext, ExtHostModelViewShape, MainThreadModelViewShape, ExtHostModelViewTreeViewsShape } from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { IItemConfig, ModelComponentTypes, IComponentShape, IComponentEventArgs, ComponentEventType, ColumnSizingMode } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
class ModelBuilderImpl implements azdata.ModelBuilder {
|
||||
private nextComponentId: number;
|
||||
@@ -269,7 +270,7 @@ class ComponentBuilderImpl<T extends azdata.Component> implements azdata.Compone
|
||||
|
||||
withProperties<U>(properties: U): azdata.ComponentBuilder<T> {
|
||||
// Keep any properties that may have been set during initial object construction
|
||||
this._component.properties = Object.assign({}, this._component.properties, properties);
|
||||
this._component.properties = assign({}, this._component.properties, properties);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -343,7 +344,7 @@ class FormContainerBuilder extends GenericContainerBuilder<azdata.FormContainer,
|
||||
});
|
||||
}
|
||||
|
||||
return new InternalItemConfig(componentWrapper, Object.assign({}, itemLayout, {
|
||||
return new InternalItemConfig(componentWrapper, assign({}, itemLayout || {}, {
|
||||
title: formComponent.title,
|
||||
actions: actions,
|
||||
isFormComponent: true,
|
||||
@@ -409,8 +410,8 @@ class FormContainerBuilder extends GenericContainerBuilder<azdata.FormContainer,
|
||||
let result: boolean = false;
|
||||
if (componentGroup && componentGroup.components !== undefined) {
|
||||
let firstComponent = componentGroup.components[0];
|
||||
let index = this._component.itemConfigs.findIndex(x => x.component.id === firstComponent.component.id);
|
||||
if (index) {
|
||||
let index = firstIndex(this._component.itemConfigs, x => x.component.id === firstComponent.component.id);
|
||||
if (index !== -1) {
|
||||
result = this._component.removeItemAt(index - 1);
|
||||
}
|
||||
componentGroup.components.forEach(element => {
|
||||
@@ -606,7 +607,7 @@ class ComponentWrapper implements azdata.Component {
|
||||
}
|
||||
|
||||
public removeItem(item: azdata.Component): boolean {
|
||||
let index = this.itemConfigs.findIndex(c => c.component.id === item.id);
|
||||
let index = firstIndex(this.itemConfigs, c => c.component.id === item.id);
|
||||
if (index >= 0 && index < this.itemConfigs.length) {
|
||||
return this.removeItemAt(index);
|
||||
}
|
||||
@@ -638,7 +639,7 @@ class ComponentWrapper implements azdata.Component {
|
||||
}
|
||||
|
||||
public updateProperties(properties: { [key: string]: any }): Thenable<void> {
|
||||
this.properties = Object.assign(this.properties, properties);
|
||||
this.properties = assign(this.properties, properties);
|
||||
return this.notifyPropertyChanged();
|
||||
}
|
||||
|
||||
@@ -647,7 +648,7 @@ class ComponentWrapper implements azdata.Component {
|
||||
}
|
||||
|
||||
public updateCssStyles(cssStyles: { [key: string]: string }): Thenable<void> {
|
||||
this.properties.CSSStyles = Object.assign(this.properties.CSSStyles || {}, cssStyles);
|
||||
this.properties.CSSStyles = assign(this.properties.CSSStyles || {}, cssStyles);
|
||||
return this.notifyPropertyChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import * as azdata from 'azdata';
|
||||
import * as vsTreeExt from 'vs/workbench/api/common/extHostTreeViews';
|
||||
import { Emitter } from 'vs/base/common/event';
|
||||
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
export class ExtHostModelViewTreeViews implements ExtHostModelViewTreeViewsShape {
|
||||
private _proxy: MainThreadModelViewShape;
|
||||
@@ -163,7 +164,7 @@ export class ExtHostTreeView<T> extends vsTreeExt.ExtHostTreeView<T> {
|
||||
protected createTreeNode(element: T, extensionTreeItem: azdata.TreeComponentItem, parent?: vsTreeExt.TreeNode): vsTreeExt.TreeNode {
|
||||
let node = super.createTreeNode(element, extensionTreeItem, parent);
|
||||
if (node.item) {
|
||||
node.item = Object.assign(node.item, { checked: extensionTreeItem.checked, enabled: extensionTreeItem.enabled });
|
||||
node.item = assign(node.item, { checked: extensionTreeItem.checked, enabled: extensionTreeItem.enabled });
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import { MainThreadNotebookDocumentsAndEditorsShape } from 'sql/workbench/api/co
|
||||
import { ExtHostNotebookDocumentData } from 'sql/workbench/api/common/extHostNotebookDocumentData';
|
||||
import { CellRange, ISingleNotebookEditOperation, ICellRange } from 'sql/workbench/api/common/sqlExtHostTypes';
|
||||
import { HideInputTag } from 'sql/workbench/parts/notebook/browser/models/cell';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
|
||||
export interface INotebookEditOperation {
|
||||
range: azdata.nb.CellRange;
|
||||
@@ -91,7 +92,7 @@ export class NotebookEditorEdit {
|
||||
value.metadata = { tags: [HideInputTag] };
|
||||
} else if (!value.metadata.tags) {
|
||||
value.metadata.tags = [HideInputTag];
|
||||
} else if (!value.metadata.tags.includes(HideInputTag)) {
|
||||
} else if (!find(value.metadata.tags, x => x === HideInputTag)) {
|
||||
value.metadata.tags.push(HideInputTag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
MainThreadResourceProviderShape,
|
||||
SqlMainContext,
|
||||
} from 'sql/workbench/api/common/sqlExtHost.protocol';
|
||||
import { values } from 'vs/base/common/collections';
|
||||
import { firstIndex } from 'vs/base/common/arrays';
|
||||
|
||||
export class ExtHostResourceProvider extends ExtHostResourceProviderShape {
|
||||
private _handlePool: number = 0;
|
||||
@@ -36,7 +38,7 @@ export class ExtHostResourceProvider extends ExtHostResourceProviderShape {
|
||||
let self = this;
|
||||
|
||||
// Look for any account providers that have the same provider ID
|
||||
let matchingProviderIndex = Object.values(this._providers).findIndex((provider: ResourceProviderWithMetadata) => {
|
||||
let matchingProviderIndex = firstIndex(values(this._providers), (provider: ResourceProviderWithMetadata) => {
|
||||
return provider.metadata.id === providerMetadata.id;
|
||||
});
|
||||
if (matchingProviderIndex >= 0) {
|
||||
|
||||
Reference in New Issue
Block a user