From acb6b8b4903e9f6a95bf2f709926ed1bddd78bb9 Mon Sep 17 00:00:00 2001 From: Koen Vlaswinkel Date: Wed, 10 Apr 2024 15:46:26 +0200 Subject: [PATCH 1/2] Remove `enableAccessPathSuggestions` config Access path suggestions will now be enabled for all languages which support it (which is currently only Ruby). --- extensions/ql-vscode/src/config.ts | 9 ------ .../src/model-editor/model-editor-view.ts | 29 +++++++------------ 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/extensions/ql-vscode/src/config.ts b/extensions/ql-vscode/src/config.ts index 0cfbbed2c..5a1c5c47e 100644 --- a/extensions/ql-vscode/src/config.ts +++ b/extensions/ql-vscode/src/config.ts @@ -737,10 +737,6 @@ const LLM_GENERATION_DEV_ENDPOINT = new Setting( const MODEL_EVALUATION = new Setting("evaluation", MODEL_SETTING); const MODEL_PACK_LOCATION = new Setting("packLocation", MODEL_SETTING); const ENABLE_PYTHON = new Setting("enablePython", MODEL_SETTING); -const ENABLE_ACCESS_PATH_SUGGESTIONS = new Setting( - "enableAccessPathSuggestions", - MODEL_SETTING, -); export type ModelConfigPackVariables = { database: string; @@ -758,7 +754,6 @@ export interface ModelConfig { variables: ModelConfigPackVariables, ): string; enablePython: boolean; - enableAccessPathSuggestions: boolean; } export class ModelConfigListener extends ConfigListener implements ModelConfig { @@ -813,10 +808,6 @@ export class ModelConfigListener extends ConfigListener implements ModelConfig { public get enablePython(): boolean { return !!ENABLE_PYTHON.getValue(); } - - public get enableAccessPathSuggestions(): boolean { - return !!ENABLE_ACCESS_PATH_SUGGESTIONS.getValue(); - } } const GITHUB_DATABASE_SETTING = new Setting("githubDatabase", ROOT_SETTING); diff --git a/extensions/ql-vscode/src/model-editor/model-editor-view.ts b/extensions/ql-vscode/src/model-editor/model-editor-view.ts index 7ccd9c89d..fb91b31cf 100644 --- a/extensions/ql-vscode/src/model-editor/model-editor-view.ts +++ b/extensions/ql-vscode/src/model-editor/model-editor-view.ts @@ -348,17 +348,11 @@ export class ModelEditorView extends AbstractWebview< withProgress((progress) => this.loadMethods(progress), { cancellable: false, }), - // Only load access path suggestions if the feature is enabled - this.modelConfig.enableAccessPathSuggestions - ? withProgress( - (progress) => this.loadAccessPathSuggestions(progress), - { - cancellable: false, - location: ProgressLocation.Window, - title: "Loading access path suggestions", - }, - ) - : undefined, + withProgress((progress) => this.loadAccessPathSuggestions(progress), { + cancellable: false, + location: ProgressLocation.Window, + title: "Loading access path suggestions", + }), ]); void telemetryListener?.sendUIInteraction("model-editor-switch-modes"); @@ -416,14 +410,11 @@ export class ModelEditorView extends AbstractWebview< await this.generateModeledMethodsOnStartup(); }), this.loadExistingModeledMethods(), - // Only load access path suggestions if the feature is enabled - this.modelConfig.enableAccessPathSuggestions - ? withProgress((progress) => this.loadAccessPathSuggestions(progress), { - cancellable: false, - location: ProgressLocation.Window, - title: "Loading access path suggestions", - }) - : undefined, + withProgress((progress) => this.loadAccessPathSuggestions(progress), { + cancellable: false, + location: ProgressLocation.Window, + title: "Loading access path suggestions", + }), ]); } From 232d4c3f41bf98e8283bdb29e9d3f09433014150 Mon Sep 17 00:00:00 2001 From: Koen Vlaswinkel Date: Wed, 10 Apr 2024 16:05:56 +0200 Subject: [PATCH 2/2] Remove unnecessary access path progress for unsupported languages --- .../src/model-editor/model-editor-view.ts | 103 +++++++++--------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/extensions/ql-vscode/src/model-editor/model-editor-view.ts b/extensions/ql-vscode/src/model-editor/model-editor-view.ts index fb91b31cf..e1433029c 100644 --- a/extensions/ql-vscode/src/model-editor/model-editor-view.ts +++ b/extensions/ql-vscode/src/model-editor/model-editor-view.ts @@ -348,11 +348,7 @@ export class ModelEditorView extends AbstractWebview< withProgress((progress) => this.loadMethods(progress), { cancellable: false, }), - withProgress((progress) => this.loadAccessPathSuggestions(progress), { - cancellable: false, - location: ProgressLocation.Window, - title: "Loading access path suggestions", - }), + this.loadAccessPathSuggestions(), ]); void telemetryListener?.sendUIInteraction("model-editor-switch-modes"); @@ -410,11 +406,7 @@ export class ModelEditorView extends AbstractWebview< await this.generateModeledMethodsOnStartup(); }), this.loadExistingModeledMethods(), - withProgress((progress) => this.loadAccessPathSuggestions(progress), { - cancellable: false, - location: ProgressLocation.Window, - title: "Loading access path suggestions", - }), + this.loadAccessPathSuggestions(), ]); } @@ -559,9 +551,7 @@ export class ModelEditorView extends AbstractWebview< } } - protected async loadAccessPathSuggestions( - progress: ProgressCallback, - ): Promise { + protected async loadAccessPathSuggestions(): Promise { const mode = this.modelingStore.getMode(this.databaseItem); const modelsAsDataLanguage = getModelsAsDataLanguage(this.language); @@ -570,46 +560,55 @@ export class ModelEditorView extends AbstractWebview< return; } - try { - const suggestions = await runSuggestionsQuery(mode, { - parseResults: (results) => - accessPathSuggestions.parseResults( - results, - modelsAsDataLanguage, + await withProgress( + async (progress) => { + try { + const suggestions = await runSuggestionsQuery(mode, { + parseResults: (results) => + accessPathSuggestions.parseResults( + results, + modelsAsDataLanguage, + this.app.logger, + ), + queryConstraints: accessPathSuggestions.queryConstraints(mode), + cliServer: this.cliServer, + queryRunner: this.queryRunner, + queryStorageDir: this.queryStorageDir, + databaseItem: this.databaseItem, + progress, + token: this.cancellationTokenSource.token, + logger: this.app.logger, + }); + + if (!suggestions) { + return; + } + + const options: AccessPathSuggestionOptions = { + input: parseAccessPathSuggestionRowsToOptions(suggestions.input), + output: parseAccessPathSuggestionRowsToOptions(suggestions.output), + }; + + await this.postMessage({ + t: "setAccessPathSuggestions", + accessPathSuggestions: options, + }); + } catch (e: unknown) { + void showAndLogExceptionWithTelemetry( this.app.logger, - ), - queryConstraints: accessPathSuggestions.queryConstraints(mode), - cliServer: this.cliServer, - queryRunner: this.queryRunner, - queryStorageDir: this.queryStorageDir, - databaseItem: this.databaseItem, - progress, - token: this.cancellationTokenSource.token, - logger: this.app.logger, - }); - - if (!suggestions) { - return; - } - - const options: AccessPathSuggestionOptions = { - input: parseAccessPathSuggestionRowsToOptions(suggestions.input), - output: parseAccessPathSuggestionRowsToOptions(suggestions.output), - }; - - await this.postMessage({ - t: "setAccessPathSuggestions", - accessPathSuggestions: options, - }); - } catch (e: unknown) { - void showAndLogExceptionWithTelemetry( - this.app.logger, - this.app.telemetry, - redactableError( - asError(e), - )`Failed to fetch access path suggestions: ${getErrorMessage(e)}`, - ); - } + this.app.telemetry, + redactableError( + asError(e), + )`Failed to fetch access path suggestions: ${getErrorMessage(e)}`, + ); + } + }, + { + cancellable: false, + location: ProgressLocation.Window, + title: "Loading access path suggestions", + }, + ); } protected async generateModeledMethods(): Promise {