Skip to content

Commit

Permalink
Add progressbar while starting rascal repl
Browse files Browse the repository at this point in the history
So that windows users now whats happening until #187 gets resolved
  • Loading branch information
DavyLandman committed Oct 5, 2022
1 parent bb2a151 commit 22d1ac9
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions rascal-vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,26 +263,36 @@ function registerImportModule() {
}

async function startTerminal(uri: vscode.Uri | undefined, ...extraArgs: string[]) {
if (!rascalClient) {
rascalClient = activateRascalLanguageClient();
}
console.log("Starting:" + uri + extraArgs);
if (uri && !uri.path.endsWith(".rsc")) {
// do not try to figure out a rascal project path when the focus is not a rascal file
uri = undefined;
}
const rascal = await rascalClient;
const serverConfig = await rascal.sendRequest<IDEServicesConfiguration>("rascal/supplyIDEServicesConfiguration");
const compilationPath = await rascal.sendRequest<string[]>("rascal/supplyProjectCompilationClasspath", { uri: uri?.toString() });

const terminal = vscode.window.createTerminal({
cwd: path.dirname(uri?.fsPath || ""),
shellPath: await getJavaExecutable(),
shellArgs: buildShellArgs(compilationPath, serverConfig, ...extraArgs),
name: 'Rascal Terminal',
});
return vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
cancellable: false,
title: "Rascal terminal"
}, async (progress) => {
progress.report({message: "Starting rascal-lsp"});
if (!rascalClient) {
rascalClient = activateRascalLanguageClient();
}
console.log(`Starting Rascal REPL: on ${uri} and with args: ${extraArgs}`);
if (uri && !uri.path.endsWith(".rsc")) {
// do not try to figure out a rascal project path when the focus is not a rascal file
uri = undefined;
}
const rascal = await rascalClient;
progress.report({increment: 25, message: "Requesting IDE configuration"});
const serverConfig = await rascal.sendRequest<IDEServicesConfiguration>("rascal/supplyIDEServicesConfiguration");
progress.report({increment: 25, message: "Calculating project class path"});
const compilationPath = await rascal.sendRequest<string[]>("rascal/supplyProjectCompilationClasspath", { uri: uri?.toString() });
progress.report({increment: 25, message: "Creating terminal"});
const terminal = vscode.window.createTerminal({
cwd: path.dirname(uri?.fsPath || ""),
shellPath: await getJavaExecutable(),
shellArgs: buildShellArgs(compilationPath, serverConfig, ...extraArgs),
name: 'Rascal Terminal',
});

terminal.show(false);
terminal.show(false);
progress.report({increment: 25, message: "Finished creating terminal"});
});
}

function buildShellArgs(classPath: string[], ide: IDEServicesConfiguration, ...extraArgs: string[]) {
Expand Down

0 comments on commit 22d1ac9

Please sign in to comment.