Remove unnecessary access path progress for unsupported languages

This commit is contained in:
Koen Vlaswinkel
2024-04-10 16:05:56 +02:00
parent acb6b8b490
commit 232d4c3f41

View File

@@ -348,11 +348,7 @@ export class ModelEditorView extends AbstractWebview<
withProgress((progress) => this.loadMethods(progress), { withProgress((progress) => this.loadMethods(progress), {
cancellable: false, cancellable: false,
}), }),
withProgress((progress) => this.loadAccessPathSuggestions(progress), { this.loadAccessPathSuggestions(),
cancellable: false,
location: ProgressLocation.Window,
title: "Loading access path suggestions",
}),
]); ]);
void telemetryListener?.sendUIInteraction("model-editor-switch-modes"); void telemetryListener?.sendUIInteraction("model-editor-switch-modes");
@@ -410,11 +406,7 @@ export class ModelEditorView extends AbstractWebview<
await this.generateModeledMethodsOnStartup(); await this.generateModeledMethodsOnStartup();
}), }),
this.loadExistingModeledMethods(), this.loadExistingModeledMethods(),
withProgress((progress) => this.loadAccessPathSuggestions(progress), { this.loadAccessPathSuggestions(),
cancellable: false,
location: ProgressLocation.Window,
title: "Loading access path suggestions",
}),
]); ]);
} }
@@ -559,9 +551,7 @@ export class ModelEditorView extends AbstractWebview<
} }
} }
protected async loadAccessPathSuggestions( protected async loadAccessPathSuggestions(): Promise<void> {
progress: ProgressCallback,
): Promise<void> {
const mode = this.modelingStore.getMode(this.databaseItem); const mode = this.modelingStore.getMode(this.databaseItem);
const modelsAsDataLanguage = getModelsAsDataLanguage(this.language); const modelsAsDataLanguage = getModelsAsDataLanguage(this.language);
@@ -570,46 +560,55 @@ export class ModelEditorView extends AbstractWebview<
return; return;
} }
try { await withProgress(
const suggestions = await runSuggestionsQuery(mode, { async (progress) => {
parseResults: (results) => try {
accessPathSuggestions.parseResults( const suggestions = await runSuggestionsQuery(mode, {
results, parseResults: (results) =>
modelsAsDataLanguage, 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, this.app.logger,
), this.app.telemetry,
queryConstraints: accessPathSuggestions.queryConstraints(mode), redactableError(
cliServer: this.cliServer, asError(e),
queryRunner: this.queryRunner, )`Failed to fetch access path suggestions: ${getErrorMessage(e)}`,
queryStorageDir: this.queryStorageDir, );
databaseItem: this.databaseItem, }
progress, },
token: this.cancellationTokenSource.token, {
logger: this.app.logger, cancellable: false,
}); location: ProgressLocation.Window,
title: "Loading access path suggestions",
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)}`,
);
}
} }
protected async generateModeledMethods(): Promise<void> { protected async generateModeledMethods(): Promise<void> {