Skip to content
Snippets Groups Projects
Commit 7512de2d authored by Stekelenburg, A.V. (Alexander, Student )'s avatar Stekelenburg, A.V. (Alexander, Student )
Browse files

Add progress bar to the run tool action

parent 087160bc
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ import {
FormattingOptions,
LanguageClient,
LanguageClientOptions,
ProgressType,
ServerOptions,
TextDocumentIdentifier,
TextEdit,
......@@ -23,7 +24,7 @@ import {
TransportKind,
} from "vscode-languageclient/node";
import { ModestCommands } from "./commands";
import { AnalysisResultsProvider, Result} from "./analysisResults";
import { AnalysisResultsProvider, Result } from "./analysisResults";
import * as path from "path";
import { fstat, existsSync } from "fs";
import * as fs from "fs";
......@@ -272,16 +273,28 @@ function getOptions(toolName: string) {
});
}
function runTool(uri: string, toolName: string, constants: { name: string; value: string; }[], options: {name: string; value: string;}[]) {
interface ProgressIndication {
message: string,
progress: number
}
function runTool(uri: string, toolName: string, constants: { name: string; value: string; }[], options: { name: string; value: string; }[]) {
let jsonObject = {
"TextDocument": TextDocumentIdentifier.create(uri),
"ToolName": toolName,
"Constants": constants,
"Options": options,
textDocument: TextDocumentIdentifier.create(uri),
toolName: toolName,
constants: constants,
options: options,
progressToken: uri + toolName + constants + options + Date.now()
};
client?.sendRequest<string>("modest/runTool", jsonObject).then(data => {
console.log(data);
analysisResultsProvider.setJsonString(data);
vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, title: "Running modest tool" }, async (progress, token) => {
let progressHandler = client?.onProgress(new ProgressType<ProgressIndication>(), jsonObject.progressToken, indication => {
progress.report({ message: indication.message, increment: indication.progress * 100 });
});
await client?.sendRequest<string>("modest/runTool", jsonObject).then(data => {
console.log(data);
analysisResultsProvider.setJsonString(data);
progressHandler?.dispose();
});
});
}
......@@ -299,15 +312,15 @@ function copyToClipboard(text: string) {
}
function loadResults(provider: AnalysisResultsProvider) {
vscode.window.showOpenDialog().then(fileUri => {
if (fileUri) {
var fpath = fileUri[0].fsPath;
provider.setJsonPath(fpath);
vscode.window.showInformationMessage(`Opened ${fpath.split("/").pop()}.`);
} else {
vscode.window.showInformationMessage(`Could not open selected file.`);
}
});
vscode.window.showOpenDialog().then(fileUri => {
if (fileUri) {
var fpath = fileUri[0].fsPath;
provider.setJsonPath(fpath);
vscode.window.showInformationMessage(`Opened ${fpath.split("/").pop()}.`);
} else {
vscode.window.showInformationMessage(`Could not open selected file.`);
}
});
}
function exportResults(provider: AnalysisResultsProvider) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment