Initial LiveShare extension scaffolding (#7170)

* LiveShare initial shared connection

* Various cleanups

* Fix type

* Fix hygiene
This commit is contained in:
Karl Burtram
2019-09-11 15:24:08 -07:00
committed by GitHub
parent 9765b0ed8e
commit 9df66deb81
33 changed files with 3126 additions and 36 deletions

View File

@@ -20,10 +20,6 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
this._proxy = mainContext.getProxy(SqlMainContext.MainThreadConnectionManagement);
}
public $getCurrentConnection(): Thenable<azdata.connection.ConnectionProfile> {
return this._proxy.$getCurrentConnectionProfile();
}
public $onConnectionEvent(handle: number, type: azdata.connection.ConnectionEventType, ownerUri: string, profile: azdata.IConnectionProfile): void {
let listener = this._connectionListeners[handle];
if (listener) {
@@ -37,10 +33,18 @@ export class ExtHostConnectionManagement extends ExtHostConnectionManagementShap
this._nextListenerHandle++;
}
public $getCurrentConnection(): Thenable<azdata.connection.ConnectionProfile> {
return this._proxy.$getCurrentConnectionProfile();
}
public $getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]> {
return this._proxy.$getConnections(activeConnectionsOnly);
}
public $getConnection(uri: string): Thenable<azdata.connection.ConnectionProfile> {
return this._proxy.$getConnection(uri);
}
// "sqlops" back-compat connection APIs
public $getActiveConnections(): Thenable<azdata.connection.Connection[]> {
return this._proxy.$getActiveConnections();

View File

@@ -251,6 +251,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
if (this.uriTransformer) {
ownerUri = URI.from(this.uriTransformer.transformIncoming(URI.parse(ownerUri))).toString(true);
}
return this._resolveProvider<azdata.QueryProvider>(handle).runQuery(ownerUri, selection, runOptions);
}
@@ -274,6 +275,10 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
}
}
$connectWithProfile(handle: number, ownerUri: string, profile: azdata.connection.ConnectionProfile): Thenable<void> {
return new Promise((r) => r());
}
$parseSyntax(handle: number, ownerUri: string, query: string): Thenable<azdata.SyntaxParseResult> {
return this._resolveProvider<azdata.QueryProvider>(handle).parseSyntax(ownerUri, query);
}

View File

@@ -26,6 +26,10 @@ class ExtHostQueryDocument implements azdata.queryeditor.QueryDocument {
public createQueryTab(tab: azdata.window.DialogTab): void {
this._proxy.$createQueryTab(this.uri, tab.title, tab.content);
}
public connect(connectionProfile: azdata.connection.ConnectionProfile): Thenable<void> {
return this._proxy.$connectWithProfile(this.uri, connectionProfile);
}
}
export class ExtHostQueryEditor implements ExtHostQueryEditorShape {

View File

@@ -118,7 +118,9 @@ export function createAdsApiFactory(accessor: ServicesAccessor): IAdsExtensionAp
registerConnectionEventListener(listener: azdata.connection.ConnectionEventListener): void {
return extHostConnectionManagement.$registerConnectionEventListener(mssqlProviderName, listener);
},
getConnection(uri: string): Thenable<azdata.connection.ConnectionProfile> {
return extHostConnectionManagement.$getConnection(uri);
},
// "sqlops" back-compat APIs
getActiveConnections(): Thenable<azdata.connection.Connection[]> {
console.warn('the method azdata.connection.getActiveConnections has been deprecated, replace it with azdata.connection.getConnections');

View File

@@ -180,6 +180,11 @@ export abstract class ExtHostDataProtocolShape {
*/
$setQueryExecutionOptions(handle: number, ownerUri: string, options: azdata.QueryExecutionOptions): Thenable<void> { throw ni(); }
/**
* Connect the editor document to the given profile
*/
$connectWithProfile(handle: number, ownerUri: string, profile: azdata.connection.ConnectionProfile): Thenable<void> { throw ni(); }
/**
* Disposes the cached information regarding a query
*/
@@ -578,6 +583,7 @@ export interface MainThreadDataProtocolShape extends IDisposable {
export interface MainThreadConnectionManagementShape extends IDisposable {
$registerConnectionEventListener(handle: number, providerId: string): void;
$getConnections(activeConnectionsOnly?: boolean): Thenable<azdata.connection.ConnectionProfile[]>;
$getConnection(uri: string): Thenable<azdata.connection.ConnectionProfile>;
$getActiveConnections(): Thenable<azdata.connection.Connection[]>;
$getCurrentConnection(): Thenable<azdata.connection.Connection>;
$getCurrentConnectionProfile(): Thenable<azdata.connection.ConnectionProfile>;
@@ -780,6 +786,7 @@ export interface ExtHostQueryEditorShape {
export interface MainThreadQueryEditorShape extends IDisposable {
$connect(fileUri: string, connectionId: string): Thenable<void>;
$connectWithProfile(fileUri: string, connectionProfile: azdata.connection.ConnectionProfile): Thenable<void>;
$runQuery(fileUri: string, runCurrentQuery?: boolean): void;
$createQueryTab(fileUri: string, title: string, content: string): void;
$setQueryExecutionOptions(fileUri: string, options: azdata.QueryExecutionOptions): Thenable<void>;

View File

@@ -564,25 +564,116 @@ export interface ISingleNotebookEditOperation {
}
export class ConnectionProfile {
get providerId(): string {
return this.options['providerId'];
}
providerId: string;
connectionId: string;
connectionName: string;
serverName: string;
databaseName: string;
userName: string;
password: string;
authenticationType: string;
savePassword: boolean;
groupFullName: string;
groupId: string;
saveProfile: boolean;
azureTenantId?: string;
options: { [name: string]: any };
set providerId(value: string) {
this.options['providerId'] = value;
}
static createFrom(options: any[]): ConnectionProfile {
// create from options
return undefined;
get connectionId(): string {
return this.options['connectionId'];
}
set connectionId(value: string) {
this.options['connectionId'] = value;
}
get connectionName(): string {
return this.options['connectionName'];
}
set connectionName(value: string) {
this.options['connectionName'] = value;
}
get serverName(): string {
return this.options['serverName'];
}
set serverName(value: string) {
this.options['serverName'] = value;
}
get databaseName(): string {
return this.options['databaseName'];
}
set databaseName(value: string) {
this.options['databaseName'] = value;
}
get userName(): string {
return this.options['userName'];
}
set userName(value: string) {
this.options['userName'] = value;
}
get password(): string {
return this.options['password'];
}
set password(value: string) {
this.options['password'] = value;
}
get authenticationType(): string {
return this.options['authenticationType'];
}
set authenticationType(value: string) {
this.options['authenticationType'] = value;
}
get savePassword(): boolean {
return this.options['savePassword'];
}
set savePassword(value: boolean) {
this.options['savePassword'] = value;
}
get groupFullName(): string {
return this.options['groupFullName'];
}
set groupFullName(value: string) {
this.options['groupFullName'] = value;
}
get groupId(): string {
return this.options['groupId'];
}
set groupId(value: string) {
this.options['groupId'] = value;
}
get saveProfile(): boolean {
return this.options['groupId'];
}
set saveProfile(value: boolean) {
this.options['groupId'] = value;
}
get azureTenantId(): string {
return this.options['azureTenantId'];
}
set azureTenantId(value: string) {
this.options['azureTenantId'] = value;
}
options: Map<string, any> = new Map<string, any>();
static createFrom(options: Map<string, any>): ConnectionProfile {
let profile = new ConnectionProfile();
profile.options = options;
return profile;
}
}