mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-10 02:02:35 -05:00
Consolidate 2 context endpoints to just one (#24276)
This commit is contained in:
13
src/sql/azdata.proposed.d.ts
vendored
13
src/sql/azdata.proposed.d.ts
vendored
@@ -1783,13 +1783,6 @@ declare module 'azdata' {
|
||||
}
|
||||
|
||||
export namespace contextualization {
|
||||
export interface GenerateServerContextualizationResult {
|
||||
/**
|
||||
* The generated server context.
|
||||
*/
|
||||
context: string | undefined;
|
||||
}
|
||||
|
||||
export interface GetServerContextualizationResult {
|
||||
/**
|
||||
* The retrieved server context.
|
||||
@@ -1798,12 +1791,6 @@ declare module 'azdata' {
|
||||
}
|
||||
|
||||
export interface ServerContextualizationProvider extends DataProvider {
|
||||
/**
|
||||
* Generates server context.
|
||||
* @param ownerUri The URI of the connection to generate context for.
|
||||
*/
|
||||
generateServerContextualization(ownerUri: string): Thenable<GenerateServerContextualizationResult>;
|
||||
|
||||
/**
|
||||
* Gets server context, which can be in the form of create scripts but is left up each provider.
|
||||
* @param ownerUri The URI of the connection to get context for.
|
||||
|
||||
@@ -573,10 +573,9 @@ export class MainThreadDataProtocol extends Disposable implements MainThreadData
|
||||
});
|
||||
}
|
||||
|
||||
// Database server contextualization handler
|
||||
// Server contextualization handler
|
||||
public $registerServerContextualizationProvider(providerId: string, handle: number): void {
|
||||
this._serverContextualizationService.registerProvider(providerId, <azdata.contextualization.ServerContextualizationProvider>{
|
||||
generateServerContextualization: (ownerUri: string) => this._proxy.$generateServerContextualization(handle, ownerUri),
|
||||
getServerContextualization: (ownerUri: string) => this._proxy.$getServerContextualization(handle, ownerUri)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -970,11 +970,7 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
|
||||
return this._resolveProvider<azdata.executionPlan.ExecutionPlanProvider>(handle).isExecutionPlan(value);
|
||||
}
|
||||
|
||||
// Database Server Contextualization API
|
||||
|
||||
public override $generateServerContextualization(handle: number, ownerUri: string): Thenable<azdata.contextualization.GenerateServerContextualizationResult> {
|
||||
return this._resolveProvider<azdata.contextualization.ServerContextualizationProvider>(handle).generateServerContextualization(ownerUri);
|
||||
}
|
||||
// Server Contextualization API
|
||||
|
||||
public override $getServerContextualization(handle: number, ownerUri: string): Thenable<azdata.contextualization.GetServerContextualizationResult> {
|
||||
return this._resolveProvider<azdata.contextualization.ServerContextualizationProvider>(handle).getServerContextualization(ownerUri);
|
||||
|
||||
@@ -595,10 +595,6 @@ export abstract class ExtHostDataProtocolShape {
|
||||
* Determines if the provided value is an execution plan and returns the appropriate file extension.
|
||||
*/
|
||||
$isExecutionPlan(handle: number, value: string): Thenable<azdata.executionPlan.IsExecutionPlanResult> { throw ni(); }
|
||||
/**
|
||||
* Generates server context.
|
||||
*/
|
||||
$generateServerContextualization(handle: number, ownerUri: string): Thenable<azdata.contextualization.GenerateServerContextualizationResult> { throw ni(); }
|
||||
/**
|
||||
* Gets server context.
|
||||
*/
|
||||
|
||||
@@ -75,43 +75,12 @@ export class ServerContextualizationService extends Disposable implements IServe
|
||||
|
||||
const getServerContextualizationResult = await this.getServerContextualization(uri);
|
||||
if (getServerContextualizationResult.context) {
|
||||
this._logService.info(`Server contextualization was previously generated for the URI (${uri}) connection, so sending that to Copilot for context.`);
|
||||
this._logService.info(`Server contextualization was retrieved for the URI (${uri}) connection, so sending that to Copilot for context.`);
|
||||
|
||||
await this.sendServerContextualizationToCopilot(getServerContextualizationResult.context);
|
||||
}
|
||||
else {
|
||||
this._logService.info(`Server contextualization was not previously generated for the URI (${uri}) connection. Generating now...`);
|
||||
|
||||
const generateServerContextualizationResult = await this.generateServerContextualization(uri);
|
||||
if (generateServerContextualizationResult.context) {
|
||||
this._logService.info(`Server contextualization was generated for the URI (${uri}) connection, so sending that to Copilot.`);
|
||||
|
||||
await this.sendServerContextualizationToCopilot(generateServerContextualizationResult.context);
|
||||
}
|
||||
else {
|
||||
this._logService.warn(`Server contextualization was not generated for the URI (${uri}) connection, so no context will be sent to Copilot.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates server context
|
||||
* @param ownerUri The URI of the connection to generate context for.
|
||||
*/
|
||||
private async generateServerContextualization(ownerUri: string): Promise<azdata.contextualization.GenerateServerContextualizationResult> {
|
||||
const providerName = this._connectionManagementService.getProviderIdFromUri(ownerUri);
|
||||
const handler = this.getProvider(providerName);
|
||||
if (handler) {
|
||||
this._logService.info(`Generating server contextualization for ${ownerUri}`);
|
||||
|
||||
return await handler.generateServerContextualization(ownerUri);
|
||||
}
|
||||
else {
|
||||
this._logService.info(`No server contextualization provider found for ${ownerUri}`);
|
||||
|
||||
return Promise.resolve({
|
||||
context: undefined
|
||||
});
|
||||
this._logService.warn(`Server contextualization was not generated for the URI (${uri}) connection, so no context will be sent to Copilot.`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user