Add more areas to strict null (#7243)

* add more areas to strict null

* fix compile errors

* fix tests

* fix checks

* address PR comments
This commit is contained in:
Anthony Dresser
2019-09-18 12:27:19 -07:00
committed by GitHub
parent 373828d76f
commit aad9c0f965
35 changed files with 193 additions and 184 deletions

View File

@@ -67,7 +67,7 @@ declare module 'azdata' {
}
export interface SerializeDataResult {
messages: string;
messages?: string;
succeeded: boolean;
}

View File

@@ -19,7 +19,7 @@ export const IBackupService = createDecorator<IBackupService>(SERVICE_ID);
export interface IBackupService {
_serviceBrand: undefined;
getBackupConfigInfo(connectionUri: string): Thenable<azdata.BackupConfigInfo>;
getBackupConfigInfo(connectionUri: string): Promise<azdata.BackupConfigInfo | undefined>;
/**
* Backup a data source using the provided connection

View File

@@ -27,12 +27,12 @@ export class BackupService implements IBackupService {
/**
* Get database metadata needed to populate backup UI
*/
public getBackupConfigInfo(connectionUri: string): Thenable<azdata.BackupConfigInfo> {
public getBackupConfigInfo(connectionUri: string): Promise<azdata.BackupConfigInfo | undefined> {
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) {
let provider = this._providers[providerId];
if (provider) {
return provider.getBackupConfigInfo(connectionUri);
return Promise.resolve(provider.getBackupConfigInfo(connectionUri));
}
}
return Promise.resolve(undefined);
@@ -57,7 +57,7 @@ export class BackupService implements IBackupService {
});
}
private getProvider(connectionUri: string): { provider: azdata.BackupProvider, providerName: string } {
private getProvider(connectionUri: string): { provider: azdata.BackupProvider, providerName: string } | undefined {
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) {
return { provider: this._providers[providerId], providerName: providerId };

View File

@@ -31,7 +31,7 @@ export class SingleConnectionMetadataService {
private _uri: string
) { }
get metadata(): Observable<ProviderMetadata> {
get metadata(): Observable<ProviderMetadata | undefined> {
return Observable.fromPromise(this._metadataService.getMetadata(this._uri));
}

View File

@@ -5,7 +5,7 @@
import { ConnectionProviderProperties } from 'sql/workbench/parts/connection/common/connectionProviderExtension';
import * as azdata from 'sqlops';
import * as azdata from 'azdata';
import { Event } from 'vs/base/common/event';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@@ -35,12 +35,12 @@ export interface ICapabilitiesService {
/**
* Retrieve a list of registered capabilities providers
*/
getCapabilities(provider: string): ProviderFeatures;
getCapabilities(provider: string): ProviderFeatures | undefined;
/**
* get the old version of provider information
*/
getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities;
getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities | undefined;
/**
* Register a capabilities provider

View File

@@ -122,11 +122,11 @@ export class CapabilitiesService extends Disposable implements ICapabilitiesServ
/**
* Retrieve a list of registered server capabilities
*/
public getCapabilities(provider: string): ProviderFeatures {
public getCapabilities(provider: string): ProviderFeatures | undefined {
return this._providers.get(provider);
}
public getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities {
public getLegacyCapabilities(provider: string): azdata.DataProtocolServerCapabilities | undefined {
return this._legacyProviders.get(provider);
}

View File

@@ -23,11 +23,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
let connectionProvider: azdata.ConnectionOption[] = [
{
name: 'connectionName',
displayName: undefined,
description: undefined,
groupName: undefined,
categoryValues: undefined,
defaultValue: undefined,
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.connectionName,
@@ -35,11 +35,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
},
{
name: 'serverName',
displayName: undefined,
description: undefined,
groupName: undefined,
categoryValues: undefined,
defaultValue: undefined,
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.serverName,
@@ -47,11 +47,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
},
{
name: 'databaseName',
displayName: undefined,
description: undefined,
groupName: undefined,
categoryValues: undefined,
defaultValue: undefined,
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.databaseName,
@@ -59,11 +59,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
},
{
name: 'userName',
displayName: undefined,
description: undefined,
groupName: undefined,
categoryValues: undefined,
defaultValue: undefined,
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.userName,
@@ -71,11 +71,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
},
{
name: 'authenticationType',
displayName: undefined,
description: undefined,
groupName: undefined,
categoryValues: undefined,
defaultValue: undefined,
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.authType,
@@ -83,11 +83,11 @@ export class TestCapabilitiesService implements ICapabilitiesService {
},
{
name: 'password',
displayName: undefined,
description: undefined,
groupName: undefined,
categoryValues: undefined,
defaultValue: undefined,
displayName: undefined!,
description: undefined!,
groupName: undefined!,
categoryValues: undefined!,
defaultValue: undefined!,
isIdentity: true,
isRequired: true,
specialValueType: ConnectionOptionSpecialType.password,
@@ -125,7 +125,7 @@ export class TestCapabilitiesService implements ICapabilitiesService {
// Event Emitters
public get onProviderRegisteredEvent(): Event<azdata.DataProtocolServerCapabilities> {
return undefined;
return Event.None;
}
public isFeatureAvailable(featureName: Action, connectionManagementInfo: ConnectionManagementInfo): boolean {
@@ -133,7 +133,7 @@ export class TestCapabilitiesService implements ICapabilitiesService {
}
public onCapabilitiesReady(): Promise<void> {
return Promise.resolve(null);
return Promise.resolve();
}
public fireCapabilitiesRegistered(providerFeatures: ProviderFeatures): void {

View File

@@ -13,7 +13,7 @@ export const FILE_SCHEMA: string = 'file';
export function resolveCurrentDirectory(uri: string, rootPath: string): string | undefined {
let sqlUri = URI.parse(uri);
let currentDirectory: string;
let currentDirectory: string | undefined;
// use current directory of the sql file if sql file is saved
if (sqlUri.scheme === FILE_SCHEMA) {
@@ -30,12 +30,15 @@ export function resolveCurrentDirectory(uri: string, rootPath: string): string |
return currentDirectory;
}
export function resolveFilePath(uri: string, filePath: string, rootPath: string): string {
export function resolveFilePath(uri: string, filePath: string, rootPath: string): string | undefined {
let currentDirectory = resolveCurrentDirectory(uri, rootPath);
return normalize(join(currentDirectory, filePath));
if (currentDirectory) {
return normalize(join(currentDirectory, filePath));
}
return undefined;
}
export function getRootPath(contextService: IWorkspaceContextService): string {
export function getRootPath(contextService: IWorkspaceContextService): string | undefined {
let isWorkspace = contextService.getWorkbenchState() === WorkbenchState.WORKSPACE;
if (isWorkspace) {
let folder = contextService.getWorkspace().folders[0];

View File

@@ -110,7 +110,7 @@ export interface IConnectionManagementService {
onIntelliSenseCacheComplete(handle: number, connectionUri: string): void;
onConnectionChangedNotification(handle: number, changedConnInfo: azdata.ChangedConnectionInfo);
onConnectionChangedNotification(handle: number, changedConnInfo: azdata.ChangedConnectionInfo): void;
getConnectionGroups(providers?: string[]): ConnectionProfileGroup[];

View File

@@ -22,7 +22,7 @@ import * as Constants from 'sql/platform/connection/common/constants';
*/
export class ConnectionProfile extends ProviderConnectionInfo implements interfaces.IConnectionProfile {
public parent: ConnectionProfileGroup = null;
public parent?: ConnectionProfileGroup;
private _id: string;
public savePassword: boolean;
private _groupName: string;
@@ -88,7 +88,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
this._id = generateUuid();
}
public getParent(): ConnectionProfileGroup {
public getParent(): ConnectionProfileGroup | undefined {
return this.parent;
}
@@ -103,11 +103,11 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
this._id = value;
}
public get azureTenantId(): string {
public get azureTenantId(): string | undefined {
return this.options['azureTenantId'];
}
public set azureTenantId(value: string) {
public set azureTenantId(value: string | undefined) {
this.options['azureTenantId'] = value;
}
@@ -185,7 +185,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
databaseName: this.databaseName,
authenticationType: this.authenticationType,
getOptionsKey: this.getOptionsKey,
matches: undefined,
matches: this.matches,
groupId: this.groupId,
groupFullName: this.groupFullName,
password: this.password,
@@ -244,22 +244,24 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa
public static convertToProfileStore(
capabilitiesService: ICapabilitiesService,
connectionProfile: interfaces.IConnectionProfile): interfaces.IConnectionProfileStore {
connectionProfile: interfaces.IConnectionProfile): interfaces.IConnectionProfileStore | undefined {
if (connectionProfile) {
let connectionInfo = ConnectionProfile.fromIConnectionProfile(capabilitiesService, connectionProfile);
let profile: interfaces.IConnectionProfileStore = {
options: {},
groupId: connectionProfile.groupId,
providerName: connectionInfo.providerName,
savePassword: connectionInfo.savePassword,
id: connectionInfo.id
};
if (connectionInfo) {
let profile: interfaces.IConnectionProfileStore = {
options: {},
groupId: connectionProfile.groupId,
providerName: connectionInfo.providerName,
savePassword: connectionInfo.savePassword,
id: connectionInfo.id
};
profile.options = connectionInfo.options;
profile.options = connectionInfo.options;
return profile;
} else {
return undefined;
return profile;
}
}
return undefined;
}
}

View File

@@ -8,7 +8,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
export interface IConnectionProfileGroup {
id: string;
parentId: string;
parentId?: string;
name: string;
color: string;
description: string;
@@ -18,7 +18,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
public children: ConnectionProfileGroup[];
public connections: ConnectionProfile[];
public parentId: string;
public parentId?: string;
private _isRenamed: boolean;
public constructor(
public name: string,
@@ -53,8 +53,8 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
return this.name;
}
public get fullName(): string {
let fullName: string = (this.id === 'root') ? undefined : this.name;
public get fullName(): string | undefined {
let fullName: string | undefined = (this.id === 'root') ? undefined : this.name;
if (this.parent) {
let parentFullName = this.parent.fullName;
if (parentFullName) {
@@ -156,7 +156,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
public isAncestorOf(node: ConnectionProfileGroup | ConnectionProfile): boolean {
let isAncestor = false;
let currentNode = node;
let currentNode: ConnectionProfileGroup | ConnectionProfile | undefined = node;
while (currentNode) {
if (currentNode.parent && currentNode.parent.id === this.id) {
isAncestor = true;
@@ -195,7 +195,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
}
public static getConnectionsInGroup(group: ConnectionProfileGroup): ConnectionProfile[] {
let connections = [];
let connections: ConnectionProfile[] = [];
if (group && group.connections) {
group.connections.forEach((con) => connections.push(con));
}
@@ -208,7 +208,7 @@ export class ConnectionProfileGroup extends Disposable implements IConnectionPro
}
public static getSubgroups(group: ConnectionProfileGroup): ConnectionProfileGroup[] {
let subgroups = [];
let subgroups: ConnectionProfileGroup[] = [];
if (group && group.children) {
group.children.forEach((grp) => subgroups.push(grp));
group.children.forEach((subgroup) => {

View File

@@ -104,27 +104,27 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
}
public get connectionName(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.connectionName);
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.connectionName)!;
}
public get serverName(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.serverName);
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.serverName)!;
}
public get databaseName(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.databaseName);
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.databaseName)!;
}
public get userName(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.userName);
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.userName)!;
}
public get password(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.password);
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.password)!;
}
public get authenticationType(): string {
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.authType);
return this.getSpecialTypeOptionValue(ConnectionOptionSpecialType.authType)!;
}
public set connectionName(value: string) {
@@ -206,7 +206,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
return isPasswordRequired;
}
private getSpecialTypeOptionValue(type: string): string {
private getSpecialTypeOptionValue(type: string): string | undefined {
let name = this.getSpecialTypeOptionName(type);
if (name) {
return this.options[name];
@@ -243,7 +243,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
let idValues: string[] = [];
for (let index = 0; index < idNames.length; index++) {
let value = this.options[idNames[index]];
let value = this.options[idNames[index]!];
value = value ? value : '';
idValues.push(`${idNames[index]}${ProviderConnectionInfo.nameValueSeparator}${value}`);
}
@@ -266,7 +266,7 @@ export class ProviderConnectionInfo extends Disposable implements azdata.Connect
return providerId;
}
public getSpecialTypeOptionName(type: string): string {
public getSpecialTypeOptionName(type: string): string | undefined {
if (this._serverCapabilities) {
let optionMetadata = this._serverCapabilities.connectionOptions.find(o => o.specialValueType === type);
return !!optionMetadata ? optionMetadata.name : undefined;

View File

@@ -31,7 +31,7 @@ suite('ConnectionStore', () => {
groupId: '',
groupFullName: '',
getOptionsKey: undefined,
matches: undefined,
matches: () => false,
providerName: mssqlProviderName,
options: {},
saveProfile: true,

View File

@@ -46,7 +46,7 @@ export class FileBrowserService implements IFileBrowserService {
return this._onPathValidate.event;
}
public openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean> {
public openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
const provider = this.getProvider(ownerUri);
if (provider) {
@@ -67,7 +67,7 @@ export class FileBrowserService implements IFileBrowserService {
&& fileBrowserOpenedParams.fileTree.rootNode
&& fileBrowserOpenedParams.fileTree.selectedNode
) {
let fileTree = this.convertFileTree(null, fileBrowserOpenedParams.fileTree.rootNode, fileBrowserOpenedParams.fileTree.selectedNode.fullPath, fileBrowserOpenedParams.ownerUri);
let fileTree = this.convertFileTree(undefined, fileBrowserOpenedParams.fileTree.rootNode, fileBrowserOpenedParams.fileTree.selectedNode.fullPath, fileBrowserOpenedParams.ownerUri);
this._onAddFileTree.fire({ rootNode: fileTree.rootNode, selectedNode: fileTree.selectedNode, expandedNodes: fileTree.expandedNodes });
} else {
let genericErrorMessage = localize('fileBrowserErrorMessage', "An error occured while loading the file browser.");
@@ -77,7 +77,7 @@ export class FileBrowserService implements IFileBrowserService {
}
}
public expandFolderNode(fileNode: FileNode): Thenable<FileNode[]> {
public expandFolderNode(fileNode: FileNode): Promise<FileNode[]> {
this._pathToFileNodeMap[fileNode.fullPath] = fileNode;
let self = this;
return new Promise<FileNode[]>((resolve, reject) => {
@@ -117,7 +117,7 @@ export class FileBrowserService implements IFileBrowserService {
}
}
public validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean> {
public validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
const provider = this.getProvider(ownerUri);
if (provider) {
@@ -136,10 +136,10 @@ export class FileBrowserService implements IFileBrowserService {
this._onPathValidate.fire(fileBrowserValidatedParams);
}
public closeFileBrowser(ownerUri: string): Thenable<azdata.FileBrowserCloseResponse> {
public closeFileBrowser(ownerUri: string): Promise<azdata.FileBrowserCloseResponse | undefined> {
let provider = this.getProvider(ownerUri);
if (provider) {
return provider.closeFileBrowser(ownerUri);
return Promise.resolve(provider.closeFileBrowser(ownerUri));
}
return Promise.resolve(undefined);
}
@@ -147,7 +147,8 @@ export class FileBrowserService implements IFileBrowserService {
private generateResolveMapKey(ownerUri: string, expandPath: string): string {
return ownerUri + ':' + expandPath;
}
private getProvider(connectionUri: string): azdata.FileBrowserProvider {
private getProvider(connectionUri: string): azdata.FileBrowserProvider | undefined {
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) {
return this._providers[providerId];
@@ -156,10 +157,10 @@ export class FileBrowserService implements IFileBrowserService {
}
}
private convertFileTree(parentNode: FileNode, fileTreeNode: azdata.FileTreeNode, expandPath: string, ownerUri: string): FileBrowserTree {
private convertFileTree(parentNode: FileNode | undefined, fileTreeNode: azdata.FileTreeNode, expandPath: string, ownerUri: string): FileBrowserTree {
FileBrowserService.fileNodeId += 1;
let expandedNodes: FileNode[] = [];
let selectedNode: FileNode;
let selectedNode: FileNode | undefined;
let fileNode = new FileNode(FileBrowserService.fileNodeId.toString(),
fileTreeNode.name,
fileTreeNode.fullPath,

View File

@@ -24,35 +24,35 @@ export interface IFileBrowserService {
/**
* Open file browser
*/
openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Thenable<boolean>;
openFileBrowser(ownerUri: string, expandPath: string, fileFilters: string[], changeFilter: boolean): Promise<boolean>;
/**
* Event called when file browser is opened
*/
onFileBrowserOpened(handle: number, fileBrowserOpenedParams: azdata.FileBrowserOpenedParams);
onFileBrowserOpened(handle: number, fileBrowserOpenedParams: azdata.FileBrowserOpenedParams): void;
/**
* Expand folder node
*/
expandFolderNode(fileNode: FileNode): Thenable<FileNode[]>;
expandFolderNode(fileNode: FileNode): Promise<FileNode[]>;
/**
* Event called when children nodes are retrieved
*/
onFolderNodeExpanded(handle: number, fileBrowserExpandedParams: azdata.FileBrowserExpandedParams);
onFolderNodeExpanded(handle: number, fileBrowserExpandedParams: azdata.FileBrowserExpandedParams): void;
/**
* Validate selected file paths
*/
validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Thenable<boolean>;
validateFilePaths(ownerUri: string, serviceType: string, selectedFiles: string[]): Promise<boolean>;
/**
* Event called when the validation is complete
*/
onFilePathsValidated(handle: number, fileBrowserValidatedParams: azdata.FileBrowserValidatedParams);
onFilePathsValidated(handle: number, fileBrowserValidatedParams: azdata.FileBrowserValidatedParams): void;
/**
* Close file browser
*/
closeFileBrowser(ownerUri: string): Thenable<azdata.FileBrowserCloseResponse>;
closeFileBrowser(ownerUri: string): Promise<azdata.FileBrowserCloseResponse | undefined>;
}

View File

@@ -14,13 +14,13 @@ export const IMetadataService = createDecorator<IMetadataService>(SERVICE_ID);
export interface IMetadataService {
_serviceBrand: undefined;
getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata>;
getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata | undefined>;
getDatabaseNames(connectionUri: string): Thenable<string[]>;
getTableInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]>;
getTableInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[] | undefined>;
getViewInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]>;
getViewInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[] | undefined>;
/**
* Register a metadata provider
@@ -37,7 +37,7 @@ export class MetadataService implements IMetadataService {
constructor(@IConnectionManagementService private _connectionService: IConnectionManagementService) {
}
public getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata> {
public getMetadata(connectionUri: string): Thenable<azdata.ProviderMetadata | undefined> {
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) {
let provider = this._providers[providerId];
@@ -61,7 +61,7 @@ export class MetadataService implements IMetadataService {
return Promise.resolve([]);
}
public getTableInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]> {
public getTableInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[] | undefined> {
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) {
let provider = this._providers[providerId];
@@ -73,7 +73,7 @@ export class MetadataService implements IMetadataService {
return Promise.resolve(undefined);
}
public getViewInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[]> {
public getViewInfo(connectionUri: string, metadata: azdata.ObjectMetadata): Thenable<azdata.ColumnMetadata[] | undefined> {
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) {
let provider = this._providers[providerId];

View File

@@ -27,7 +27,7 @@ export interface IModelView extends IView {
setProperties(componentId: string, properties: { [key: string]: any }): void;
setDataProvider(handle: number, componentId: string, context: any): void;
refreshDataProvider(componentId: string, item: any): void;
registerEvent(componentId: string);
registerEvent(componentId: string): void;
onEvent: Event<IModelViewEventArgs>;
validate(componentId: string): Thenable<boolean>;
readonly onDestroy: Event<void>;

View File

@@ -13,7 +13,7 @@ export const SERVICE_ID = 'modelViewService';
export interface IModelViewService {
_serviceBrand: undefined;
onRegisteredModelView: Event<IModelView>;
registerModelView(widget: IModelView);
registerModelView(widget: IModelView): void;
}
export const IModelViewService = createDecorator<IModelViewService>(SERVICE_ID);

View File

@@ -23,10 +23,4 @@ export interface ISqlOAuthService {
* @return Promise to return an authorization code
*/
performOAuthAuthorization(eventId: string, url: string, silent: boolean): void;
/**
* Registers a handler for the oauth-reply event on the IPC channel
* @param handler Handler to call when the event is triggered
*/
registerOAuthCallback(handler: (event, args) => void): void;
}

View File

@@ -32,12 +32,4 @@ export class SqlOAuthService implements ISqlOAuthService {
}
);
}
/**
* Registers a handler for the oauth-reply event on the IPC channel
* @param handler Handler to call when the event is triggered
*/
registerOAuthCallback(handler: (event, args) => void): void {
electron.ipcRenderer.on('oauth-reply', handler);
}
}

View File

@@ -25,7 +25,7 @@ export enum ScriptOperation {
export interface IScriptingService {
_serviceBrand: undefined;
script(connectionUri: string, metadata: azdata.ObjectMetadata, operation: ScriptOperation, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult>;
script(connectionUri: string, metadata: azdata.ObjectMetadata, operation: ScriptOperation, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult | undefined>;
/**
* Register a scripting provider
@@ -45,7 +45,7 @@ export interface IScriptingService {
/**
* Returns the result for an operation if the operation failed
*/
getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult;
getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult | undefined;
}
export class ScriptingService implements IScriptingService {
@@ -63,7 +63,7 @@ export class ScriptingService implements IScriptingService {
/**
* Call the service for scripting based on provider and scripting operation
*/
public script(connectionUri: string, metadata: azdata.ObjectMetadata, operation: ScriptOperation, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult> {
public script(connectionUri: string, metadata: azdata.ObjectMetadata, operation: ScriptOperation, paramDetails: azdata.ScriptingParamDetails): Thenable<azdata.ScriptingResult | undefined> {
let providerId: string = this._connectionService.getProviderIdFromUri(connectionUri);
if (providerId) {
@@ -91,7 +91,7 @@ export class ScriptingService implements IScriptingService {
* Returns the result for an operation if the operation failed
* @param operationId Operation Id
*/
public getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult {
public getOperationFailedResult(operationId: string): azdata.ScriptingCompleteResult | undefined {
if (operationId && operationId in this.failedScriptingOperations) {
return this.failedScriptingOperations[operationId];
} else {

View File

@@ -51,7 +51,7 @@ export interface ISerializationService {
serializeResults(request: SerializeDataParams): Promise<azdata.SerializeDataResult>;
getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider;
getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider | undefined;
}
function getBatchSize(totalRows: number, currentIndex: number): number {
@@ -90,7 +90,7 @@ export class SerializationService implements ISerializationService {
}
public getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider {
public getSaveResultsFeatureMetadataProvider(ownerUri: string): azdata.FeatureMetadataProvider | undefined {
let providerId: string = this._connectionService.getProviderIdFromUri(ownerUri);
let providerCapabilities = this._capabilitiesService.getLegacyCapabilities(providerId);

View File

@@ -28,7 +28,7 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
let disposable: IDisposable;
let id: string;
if (types.isString(idOrTask)) {
disposable = CommandsRegistry.registerCommand(idOrTask, handler);
disposable = CommandsRegistry.registerCommand(idOrTask, handler!);
id = idOrTask;
} else {
if (idOrTask.iconClass) {
@@ -52,8 +52,8 @@ export const TaskRegistry: ITaskRegistry = new class implements ITaskRegistry {
};
}
getOrCreateTaskIconClassName(item: ICommandAction): string {
let iconClass = null;
getOrCreateTaskIconClassName(item: ICommandAction): string | undefined {
let iconClass: string | undefined;
if (this.taskIdToIconClassNameMap.has(item.id)) {
iconClass = this.taskIdToIconClassNameMap.get(item.id);
} else if (item.iconLocation) {
@@ -74,17 +74,19 @@ export abstract class Task {
public readonly id: string;
public readonly title: string;
public readonly iconPathDark: string;
public readonly iconPath: { dark: URI; light?: URI; };
private readonly _iconClass: string;
private readonly _description: ITaskHandlerDescription;
public readonly iconPath?: { dark: URI; light?: URI; };
private readonly _iconClass?: string;
private readonly _description?: ITaskHandlerDescription;
constructor(private opts: ITaskOptions) {
this.id = opts.id;
this.title = opts.title;
this.iconPath = {
dark: opts.iconPath ? URI.parse(opts.iconPath.dark) : undefined,
light: opts.iconPath ? URI.parse(opts.iconPath.light) : undefined,
};
if (opts.iconPath.dark) {
this.iconPath = {
dark: URI.parse(opts.iconPath.dark),
light: opts.iconPath.light ? URI.parse(opts.iconPath.light) : undefined,
};
}
this._iconClass = opts.iconClass;
this._description = opts.description;
}

View File

@@ -16,7 +16,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
export interface ITaskOptions {
id: string;
title: string;
iconPath: { dark: string; light: string; };
iconPath: { dark: string; light?: string; };
description?: ITaskHandlerDescription;
iconClass?: string;
}
@@ -55,6 +55,6 @@ export interface ITaskRegistry {
registerTask(id: string, command: ITaskHandler): IDisposable;
registerTask(command: ITask): IDisposable;
getTasks(): string[];
getOrCreateTaskIconClassName(item: ICommandAction): string;
getOrCreateTaskIconClassName(item: ICommandAction): string | undefined;
onTaskRegistered: Event<string>;
}

View File

@@ -36,12 +36,12 @@ export class TaskNode {
/**
* sever name
*/
public serverName: string;
public serverName?: string;
/**
* Database Name
*/
public databaseName: string;
public databaseName?: string;
/**
* Provider Name
@@ -99,7 +99,7 @@ export class TaskNode {
*/
public script: string;
constructor(taskName: string, serverName: string, databaseName: string, taskId: string = undefined, taskExecutionMode: TaskExecutionMode = TaskExecutionMode.execute, isCancelable: boolean = true) {
constructor(taskName: string, serverName?: string, databaseName?: string, taskId: string | undefined = undefined, taskExecutionMode: TaskExecutionMode = TaskExecutionMode.execute, isCancelable: boolean = true) {
this.id = taskId || generateUuid();
this.taskName = taskName;

View File

@@ -25,11 +25,11 @@ export interface ITaskService {
handleTaskComplete(eventArgs: TaskStatusChangeArgs): void;
getAllTasks(): TaskNode;
getNumberOfInProgressTasks(): number;
onNewTaskCreated(handle: number, taskInfo: azdata.TaskInfo);
createNewTask(taskInfo: azdata.TaskInfo);
updateTask(taskProgressInfo: azdata.TaskProgressInfo);
onTaskStatusChanged(handle: number, taskProgressInfo: azdata.TaskProgressInfo);
cancelTask(providerId: string, taskId: string): Thenable<boolean>;
onNewTaskCreated(handle: number, taskInfo: azdata.TaskInfo): void;
createNewTask(taskInfo: azdata.TaskInfo): void;
updateTask(taskProgressInfo: azdata.TaskProgressInfo): void;
onTaskStatusChanged(handle: number, taskProgressInfo: azdata.TaskProgressInfo): void;
cancelTask(providerId: string, taskId: string): Promise<boolean | undefined>;
/**
* Register a ObjectExplorer provider
*/
@@ -56,7 +56,7 @@ export class TaskService implements ITaskService {
@IQueryEditorService private queryEditorService: IQueryEditorService,
@IConnectionManagementService private connectionManagementService: IConnectionManagementService
) {
this._taskQueue = new TaskNode('Root', undefined, undefined);
this._taskQueue = new TaskNode('Root');
this._onTaskComplete = new Emitter<TaskNode>();
this._onAddNewTask = new Emitter<TaskNode>();
@@ -105,19 +105,21 @@ export class TaskService implements ITaskService {
this.updateTask(taskProgressInfo);
}
public cancelTask(providerId: string, taskId: string): Thenable<boolean> {
public cancelTask(providerId: string, taskId: string): Promise<boolean | undefined> {
let task = this.getTaskInQueue(taskId);
task.status = TaskStatus.Canceling;
this._onTaskComplete.fire(task);
if (providerId) {
let provider = this._providers[providerId];
if (provider && provider.cancelTask) {
return provider.cancelTask({
taskId: taskId
});
if (task) {
task.status = TaskStatus.Canceling;
this._onTaskComplete.fire(task);
if (providerId) {
let provider = this._providers[providerId];
if (provider && provider.cancelTask) {
return Promise.resolve(provider.cancelTask({
taskId: taskId
}));
}
} else {
return Promise.resolve(true);
}
} else {
return Promise.resolve(true);
}
return Promise.resolve(undefined);
}
@@ -222,7 +224,7 @@ export class TaskService implements ITaskService {
}
private getTaskInQueue(taskId: string): TaskNode {
private getTaskInQueue(taskId: string): TaskNode | undefined {
if (this._taskQueue.hasChildren) {
return this._taskQueue.children.find(x => x.id === taskId);
}

View File

@@ -14,7 +14,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
export interface IComponent extends IDisposable {
descriptor: IComponentDescriptor;
modelStore: IModelStore;
layout();
layout(): void;
registerEventHandler(handler: (event: IComponentEventArgs) => void): IDisposable;
clearContainer?: () => void;
addToContainer?: (componentDescriptor: IComponentDescriptor, config: any, index?: number) => void;
@@ -76,7 +76,7 @@ export interface IModelStore {
* Creates and saves the reference of a component descriptor.
* This can be used during creation of a component later
*/
createComponentDescriptor(type: string, createComponentDescriptor): IComponentDescriptor;
createComponentDescriptor(type: string, createComponentDescriptor: string): IComponentDescriptor;
/**
* gets the descriptor for a previously created component ID
*/

View File

@@ -47,7 +47,7 @@ export function scriptSelect(connectionProfile: IConnectionProfile, metadata: az
connectionService.connectIfNotConnected(connectionProfile).then(connectionResult => {
let paramDetails: azdata.ScriptingParamDetails = getScriptingParamDetails(connectionService, connectionResult, metadata);
scriptingService.script(connectionResult, metadata, ScriptOperation.Select, paramDetails).then(result => {
if (result.script) {
if (result && result.script) {
queryEditorService.newSqlEditor(result.script).then((owner: IConnectableInput) => {
// Connect our editor to the input connection
let options: IConnectionCompletionOptions = {
@@ -82,7 +82,7 @@ export function scriptEditSelect(connectionProfile: IConnectionProfile, metadata
connectionService.connectIfNotConnected(connectionProfile).then(connectionResult => {
let paramDetails: azdata.ScriptingParamDetails = getScriptingParamDetails(connectionService, connectionResult, metadata);
scriptingService.script(connectionResult, metadata, ScriptOperation.Select, paramDetails).then(result => {
if (result.script) {
if (result && result.script) {
queryEditorService.newEditDataEditor(metadata.schema, metadata.name, result.script).then((owner: EditDataInput) => {
// Connect our editor
let options: IConnectionCompletionOptions = {

View File

@@ -26,7 +26,7 @@ export const Extensions = {
export interface IConnectionProviderRegistry {
registerConnectionProvider(id: string, properties: ConnectionProviderProperties): void;
getProperties(id: string): ConnectionProviderProperties;
getProperties(id: string): ConnectionProviderProperties | undefined;
readonly onNewProvider: Event<{ id: string, properties: ConnectionProviderProperties }>;
readonly providers: { [id: string]: ConnectionProviderProperties };
}
@@ -41,7 +41,7 @@ class ConnectionProviderRegistryImpl implements IConnectionProviderRegistry {
this._onNewProvider.fire({ id, properties });
}
public getProperties(id: string): ConnectionProviderProperties {
public getProperties(id: string): ConnectionProviderProperties | undefined {
return this._providers.get(id);
}

View File

@@ -257,7 +257,7 @@ class DataResourceDataProvider implements IGridDataProvider {
return serializer.handleSerialization(this.documentUri, format, (filePath) => this.doSerialize(serializer, filePath, format, selection));
}
private async doSerialize(serializer: ResultSerializer, filePath: string, format: SaveFormat, selection: Slick.Range[]): Promise<SaveResultsResponse> {
private doSerialize(serializer: ResultSerializer, filePath: string, format: SaveFormat, selection: Slick.Range[]): Promise<SaveResultsResponse | undefined> {
// TODO implement selection support
let columns = this.resultSet.columnInfo;
let rowLength = this.rows.length;
@@ -296,8 +296,7 @@ class DataResourceDataProvider implements IGridDataProvider {
getRowRange: (rowStart, numberOfRows) => getRows(rowStart, numberOfRows),
rowCount: rowLength
});
let result = await this._serializationService.serializeResults(serializeRequestParams);
return result;
return this._serializationService.serializeResults(serializeRequestParams);
}
/**

View File

@@ -32,7 +32,7 @@ let prevSavePath: string;
export interface SaveResultsResponse {
succeeded: boolean;
messages: string;
messages?: string;
}
interface ICsvConfig {
@@ -94,7 +94,7 @@ export class ResultSerializer {
/**
* Handle save request by getting filename from user and sending request to service
*/
public handleSerialization(uri: string, format: SaveFormat, sendRequest: ((filePath: string) => Promise<SaveResultsResponse>)): Thenable<void> {
public handleSerialization(uri: string, format: SaveFormat, sendRequest: ((filePath: string) => Promise<SaveResultsResponse | undefined>)): Thenable<void> {
const self = this;
return this.promptForFilepath(format, uri).then(filePath => {
if (filePath) {
@@ -103,7 +103,7 @@ export class ResultSerializer {
}
return self.doSave(filePath, format, () => sendRequest(filePath));
}
return Promise.resolve(undefined);
return Promise.resolve();
});
}
@@ -331,19 +331,19 @@ export class ResultSerializer {
/**
* Send request to sql tools service to save a result set
*/
private async doSave(filePath: string, format: string, sendRequest: () => Promise<SaveResultsResponse>): Promise<void> {
private async doSave(filePath: string, format: string, sendRequest: () => Promise<SaveResultsResponse | undefined>): Promise<void> {
this.logToOutputChannel(LocalizedConstants.msgSaveStarted + filePath);
// send message to the sqlserverclient for converting results to the requested format and saving to filepath
try {
let result = await sendRequest();
if (result.messages) {
if (!result || result.messages) {
this._notificationService.notify({
severity: Severity.Error,
message: LocalizedConstants.msgSaveFailed + result.messages
message: LocalizedConstants.msgSaveFailed + (result ? result.messages : '')
});
this.logToOutputChannel(LocalizedConstants.msgSaveFailed + result.messages);
this.logToOutputChannel(LocalizedConstants.msgSaveFailed + (result ? result.messages : ''));
} else {
this.promptFileSavedNotification(filePath);
this.logToOutputChannel(LocalizedConstants.msgSaveSucceeded + filePath);

View File

@@ -10,6 +10,6 @@ import { FileNode } from 'sql/workbench/services/fileBrowser/common/fileNode';
*/
export class FileBrowserTree {
public rootNode: FileNode;
public selectedNode: FileNode;
public selectedNode?: FileNode;
public expandedNodes: FileNode[];
}

View File

@@ -33,7 +33,7 @@ export class FileNode {
/**
* Parent node
*/
public parent: FileNode;
public parent?: FileNode;
/**
* Children nodes
@@ -55,7 +55,7 @@ export class FileNode {
*/
public hasChildren: boolean;
constructor(id: string, name: string, fullPath: string, isFile: boolean, isExpanded: boolean, ownerUri: string, parent: FileNode) {
constructor(id: string, name: string, fullPath: string, isFile: boolean, isExpanded: boolean, ownerUri: string, parent?: FileNode) {
if (id) {
this.id = id;
} else {
@@ -69,4 +69,4 @@ export class FileNode {
this.isExpanded = isExpanded;
this.parent = parent;
}
}
}