Archived
Move command line parsing to be a workbench contribution (#6524)
* move command line parsing to be a workbench contribution * move to electron-browser * update variable names
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
/*---------------------------------------------------------------------------------------------
|
||||||
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
import { Registry } from 'vs/platform/registry/common/platform';
|
||||||
|
import { IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
|
||||||
|
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||||
|
import { CommandLineWorkbenchContribution } from 'sql/workbench/parts/commandLine/electron-browser/commandLine';
|
||||||
|
|
||||||
|
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(CommandLineWorkbenchContribution, LifecyclePhase.Restored);
|
||||||
+2
-3
@@ -7,7 +7,6 @@ import * as azdata from 'azdata';
|
|||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||||
import { equalsIgnoreCase } from 'vs/base/common/strings';
|
import { equalsIgnoreCase } from 'vs/base/common/strings';
|
||||||
import { ICommandLineProcessing } from 'sql/workbench/services/commandLine/common/commandLine';
|
|
||||||
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
import { IConnectionManagementService, IConnectionCompletionOptions, ConnectionType, RunQueryOnConnectionMode } from 'sql/platform/connection/common/connectionManagement';
|
||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||||
@@ -27,9 +26,9 @@ import { QueryInput } from 'sql/workbench/parts/query/common/queryInput';
|
|||||||
import { URI } from 'vs/base/common/uri';
|
import { URI } from 'vs/base/common/uri';
|
||||||
import { ILogService } from 'vs/platform/log/common/log';
|
import { ILogService } from 'vs/platform/log/common/log';
|
||||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||||
|
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||||
|
|
||||||
export class CommandLineService implements ICommandLineProcessing {
|
export class CommandLineWorkbenchContribution implements IWorkbenchContribution {
|
||||||
public _serviceBrand: any;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
@ICapabilitiesService private _capabilitiesService: ICapabilitiesService,
|
||||||
+25
-25
@@ -8,7 +8,7 @@ import * as TypeMoq from 'typemoq';
|
|||||||
import * as azdata from 'azdata';
|
import * as azdata from 'azdata';
|
||||||
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile';
|
||||||
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup';
|
||||||
import { CommandLineService } from 'sql/workbench/services/commandLine/common/commandLineService';
|
import { CommandLineWorkbenchContribution } from 'sql/workbench/parts/commandLine/electron-browser/commandLine';
|
||||||
import * as Constants from 'sql/platform/connection/common/constants';
|
import * as Constants from 'sql/platform/connection/common/constants';
|
||||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
||||||
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService';
|
||||||
@@ -98,14 +98,15 @@ suite('commandLineService tests', () => {
|
|||||||
capabilitiesService = new TestCapabilitiesService();
|
capabilitiesService = new TestCapabilitiesService();
|
||||||
});
|
});
|
||||||
|
|
||||||
function getCommandLineService(connectionManagementService: IConnectionManagementService,
|
function getCommandLineContribution(
|
||||||
|
connectionManagementService: IConnectionManagementService,
|
||||||
configurationService: IConfigurationService,
|
configurationService: IConfigurationService,
|
||||||
capabilitiesService?: ICapabilitiesService,
|
capabilitiesService?: ICapabilitiesService,
|
||||||
commandService?: ICommandService,
|
commandService?: ICommandService,
|
||||||
editorService?: IEditorService,
|
editorService?: IEditorService,
|
||||||
logService?: ILogService
|
logService?: ILogService
|
||||||
): CommandLineService {
|
): CommandLineWorkbenchContribution {
|
||||||
let service = new CommandLineService(
|
return new CommandLineWorkbenchContribution(
|
||||||
capabilitiesService,
|
capabilitiesService,
|
||||||
connectionManagementService,
|
connectionManagementService,
|
||||||
undefined,
|
undefined,
|
||||||
@@ -117,7 +118,6 @@ suite('commandLineService tests', () => {
|
|||||||
undefined,
|
undefined,
|
||||||
logService
|
logService
|
||||||
);
|
);
|
||||||
return service;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getConfigurationServiceMock(showConnectDialogOnStartup: boolean): TypeMoq.Mock<IConfigurationService> {
|
function getConfigurationServiceMock(showConnectDialogOnStartup: boolean): TypeMoq.Mock<IConfigurationService> {
|
||||||
@@ -138,8 +138,8 @@ suite('commandLineService tests', () => {
|
|||||||
.returns(() => new Promise<string>((resolve, reject) => { resolve('unused'); }))
|
.returns(() => new Promise<string>((resolve, reject) => { resolve('unused'); }))
|
||||||
.verifiable(TypeMoq.Times.never());
|
.verifiable(TypeMoq.Times.never());
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object);
|
||||||
service.processCommandLine(new TestParsedArgs()).then(() => {
|
contribution.processCommandLine(new TestParsedArgs()).then(() => {
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
done();
|
done();
|
||||||
}, error => { assert.fail(error, null, 'processCommandLine rejected ' + error); done(); });
|
}, error => { assert.fail(error, null, 'processCommandLine rejected ' + error); done(); });
|
||||||
@@ -154,9 +154,9 @@ suite('commandLineService tests', () => {
|
|||||||
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
connectionManagementService.setup(c => c.connectIfNotConnected(TypeMoq.It.isAny(), TypeMoq.It.isAny()))
|
||||||
.verifiable(TypeMoq.Times.never());
|
.verifiable(TypeMoq.Times.never());
|
||||||
const configurationService = getConfigurationServiceMock(false);
|
const configurationService = getConfigurationServiceMock(false);
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object);
|
||||||
|
|
||||||
await service.processCommandLine(new TestParsedArgs());
|
await contribution.processCommandLine(new TestParsedArgs());
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -170,9 +170,9 @@ suite('commandLineService tests', () => {
|
|||||||
.returns(() => new Promise<string>((resolve, reject) => { resolve('unused'); }))
|
.returns(() => new Promise<string>((resolve, reject) => { resolve('unused'); }))
|
||||||
.verifiable(TypeMoq.Times.never());
|
.verifiable(TypeMoq.Times.never());
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object);
|
||||||
try {
|
try {
|
||||||
await service.processCommandLine(new TestParsedArgs());
|
await contribution.processCommandLine(new TestParsedArgs());
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
assert.fail(error, null, 'processCommandLine rejected ' + error);
|
assert.fail(error, null, 'processCommandLine rejected ' + error);
|
||||||
@@ -200,8 +200,8 @@ suite('commandLineService tests', () => {
|
|||||||
connectionManagementService.setup(c => c.getConnectionProfileById(TypeMoq.It.isAnyString())).returns(() => originalProfile);
|
connectionManagementService.setup(c => c.getConnectionProfileById(TypeMoq.It.isAnyString())).returns(() => originalProfile);
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
const logService = new NullLogService();
|
const logService = new NullLogService();
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService);
|
||||||
await service.processCommandLine(args);
|
await contribution.processCommandLine(args);
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -224,8 +224,8 @@ suite('commandLineService tests', () => {
|
|||||||
})
|
})
|
||||||
.verifiable(TypeMoq.Times.once());
|
.verifiable(TypeMoq.Times.once());
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object);
|
||||||
await service.processCommandLine(args);
|
await contribution.processCommandLine(args);
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
commandService.verifyAll();
|
commandService.verifyAll();
|
||||||
should(capturedArgs).be.undefined();
|
should(capturedArgs).be.undefined();
|
||||||
@@ -260,8 +260,8 @@ suite('commandLineService tests', () => {
|
|||||||
})
|
})
|
||||||
.verifiable(TypeMoq.Times.once());
|
.verifiable(TypeMoq.Times.once());
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object);
|
||||||
await service.processCommandLine(args);
|
await contribution.processCommandLine(args);
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
commandService.verifyAll();
|
commandService.verifyAll();
|
||||||
should(actualProfile).not.be.undefined();
|
should(actualProfile).not.be.undefined();
|
||||||
@@ -281,8 +281,8 @@ suite('commandLineService tests', () => {
|
|||||||
.returns(() => Promise.reject(new Error('myerror')))
|
.returns(() => Promise.reject(new Error('myerror')))
|
||||||
.verifiable(TypeMoq.Times.once());
|
.verifiable(TypeMoq.Times.once());
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, commandService.object);
|
||||||
assertThrowsAsync(async () => await service.processCommandLine(args));
|
assertThrowsAsync(async () => await contribution.processCommandLine(args));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('processCommandLine uses Integrated auth if no user name or auth type is passed', async () => {
|
test('processCommandLine uses Integrated auth if no user name or auth type is passed', async () => {
|
||||||
@@ -305,8 +305,8 @@ suite('commandLineService tests', () => {
|
|||||||
connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []);
|
connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []);
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
const logService = new NullLogService();
|
const logService = new NullLogService();
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService);
|
||||||
await service.processCommandLine(args);
|
await contribution.processCommandLine(args);
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -348,8 +348,8 @@ suite('commandLineService tests', () => {
|
|||||||
connectionManagementService.setup(x => x.getConnectionGroups(TypeMoq.It.isAny())).returns(() => [conProfGroup]);
|
connectionManagementService.setup(x => x.getConnectionGroups(TypeMoq.It.isAny())).returns(() => [conProfGroup]);
|
||||||
const configurationService = getConfigurationServiceMock(true);
|
const configurationService = getConfigurationServiceMock(true);
|
||||||
const logService = new NullLogService();
|
const logService = new NullLogService();
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService);
|
||||||
await service.processCommandLine(args);
|
await contribution.processCommandLine(args);
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -385,8 +385,8 @@ suite('commandLineService tests', () => {
|
|||||||
uri.toString(),
|
uri.toString(),
|
||||||
TypeMoq.It.is<IConnectionCompletionOptions>(i => i.params.input === queryInput.object && i.params.connectionType === ConnectionType.editor))
|
TypeMoq.It.is<IConnectionCompletionOptions>(i => i.params.input === queryInput.object && i.params.connectionType === ConnectionType.editor))
|
||||||
).verifiable(TypeMoq.Times.once());
|
).verifiable(TypeMoq.Times.once());
|
||||||
let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, editorService.object);
|
let contribution = getCommandLineContribution(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, editorService.object);
|
||||||
await service.processCommandLine(args);
|
await contribution.processCommandLine(args);
|
||||||
queryInput.verifyAll();
|
queryInput.verifyAll();
|
||||||
connectionManagementService.verifyAll();
|
connectionManagementService.verifyAll();
|
||||||
});
|
});
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/*---------------------------------------------------------------------------------------------
|
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
|
||||||
*--------------------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
|
||||||
import { ParsedArgs } from 'vs/platform/environment/common/environment';
|
|
||||||
|
|
||||||
export interface ICommandLineProcessing {
|
|
||||||
_serviceBrand: any;
|
|
||||||
/**
|
|
||||||
* Interprets the various Azure Data Studio-specific command line switches and
|
|
||||||
* performs the requisite tasks such as connecting to a server
|
|
||||||
*/
|
|
||||||
processCommandLine(args: ParsedArgs): Promise<void>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ICommandLineProcessing = createDecorator<ICommandLineProcessing>('commandLineService');
|
|
||||||
@@ -44,10 +44,6 @@ import { WorkbenchContextKeysHandler } from 'vs/workbench/browser/contextkeys';
|
|||||||
import { coalesce } from 'vs/base/common/arrays';
|
import { coalesce } from 'vs/base/common/arrays';
|
||||||
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
|
||||||
import { Layout } from 'vs/workbench/browser/layout';
|
import { Layout } from 'vs/workbench/browser/layout';
|
||||||
import { ICommandLineProcessing } from 'sql/workbench/services/commandLine/common/commandLine';
|
|
||||||
import { CommandLineService } from 'sql/workbench/services/commandLine/common/commandLineService';
|
|
||||||
import { IAdsTelemetryService } from 'sql/platform/telemetry/telemetry';
|
|
||||||
import { AdsTelemetryService } from 'sql/platform/telemetry/adsTelemetryService';
|
|
||||||
|
|
||||||
export class Workbench extends Layout {
|
export class Workbench extends Layout {
|
||||||
|
|
||||||
@@ -183,11 +179,6 @@ export class Workbench extends Layout {
|
|||||||
|
|
||||||
const instantiationService = new InstantiationService(serviceCollection, true);
|
const instantiationService = new InstantiationService(serviceCollection, true);
|
||||||
|
|
||||||
// {{SQL CARBON EDIT }}
|
|
||||||
// TODO@Davidshi commandLineService currently has no referents, so force its creation
|
|
||||||
serviceCollection.set(ICommandLineProcessing, instantiationService.createInstance(CommandLineService));
|
|
||||||
// {{SQL CARBON EDIT}} - End
|
|
||||||
|
|
||||||
// Wrap up
|
// Wrap up
|
||||||
instantiationService.invokeFunction(accessor => {
|
instantiationService.invokeFunction(accessor => {
|
||||||
const lifecycleService = accessor.get(ILifecycleService);
|
const lifecycleService = accessor.get(ILifecycleService);
|
||||||
|
|||||||
@@ -525,3 +525,5 @@ import 'sql/workbench/parts/dashboard/browser/containers/dashboardContainer.cont
|
|||||||
import 'sql/workbench/parts/dashboard/browser/containers/dashboardNavSection.contribution';
|
import 'sql/workbench/parts/dashboard/browser/containers/dashboardNavSection.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/containers/dashboardModelViewContainer.contribution';
|
import 'sql/workbench/parts/dashboard/browser/containers/dashboardModelViewContainer.contribution';
|
||||||
import 'sql/workbench/parts/dashboard/browser/core/dashboardTab.contribution';
|
import 'sql/workbench/parts/dashboard/browser/core/dashboardTab.contribution';
|
||||||
|
|
||||||
|
import 'sql/workbench/parts/commandLine/electron-browser/commandLine.contribution';
|
||||||
|
|||||||
Reference in New Issue
Block a user