Skip to content

Commit

Permalink
Merge pull request #23 from runtimeverification/raoul/progress-bar
Browse files Browse the repository at this point in the history
Show progress when launching a new debugging session
  • Loading branch information
RaoulSchaffranek authored Nov 11, 2024
2 parents 2c41ce2 + bdba146 commit a5ef0c9
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 75 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to the "Simbolik VSCode" extension will be documented in this file.

## [4.0.1] - 2024-11-11

- Show progress updates while starting a debugging session
- Hide build task output when the project compiles successfully

## [4.0.0] - 2024-11-09

- Fixed the web extension.
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"publisher": "runtimeverification",
"description": "Advanced Solidity and EVM Debugger",
"version": "4.0.0",
"version": "4.0.1",
"engines": {
"vscode": "^1.79.0"
},
Expand Down
3 changes: 2 additions & 1 deletion src/foundry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ function forgeBuildTask(file: vscode.Uri) {
})
);
task.isBackground = true;
task.presentationOptions.reveal = vscode.TaskRevealKind.Always;
task.presentationOptions.reveal = vscode.TaskRevealKind.Silent;
task.presentationOptions.clear = true;
return task;
}

Expand Down
144 changes: 76 additions & 68 deletions src/startDebugging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,78 +12,86 @@ export async function startDebugging(
contract: ContractDefinition,
method: FunctionDefinition
) {
const activeTextEditor = vscode.window.activeTextEditor;
if (!activeTextEditor) {
throw new Error('No active text editor.');
}

const workspaceFolder = vscode.workspace.getWorkspaceFolder(
activeTextEditor.document.uri
);
if (!workspaceFolder) {
throw new Error('No workspace folder.');
}

const parameters = method.parameters.flatMap((param: VariableDeclaration) => {
if (param.typeName === null) {
console.error(
`Missing TypeName for parameter ${param} in method ${method} in contract ${contract}`
);
return [];
}
const typeName: TypeName = param.typeName;
if (!('name' in typeName)) {
console.error(
`Missing name for TypeName for parameter ${param} in method ${method} in contract ${contract}`
);
return [];
return await vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: "Simbolik"
}, async (progress) => {
const activeTextEditor = vscode.window.activeTextEditor;
if (!activeTextEditor) {
throw new Error('No active text editor.');
}
if (typeof typeName.name !== 'string') {
console.error(
`Unexpected type for name of TypeName for parameter ${param} in method ${method} in contract ${contract}`
);
return [];

const workspaceFolder = vscode.workspace.getWorkspaceFolder(
activeTextEditor.document.uri
);
if (!workspaceFolder) {
throw new Error('No workspace folder.');
}
return [typeName.name];
});

const file = activeTextEditor.document.uri.toString();
const contractName = contract['name'];
const methodSignature = `${method['name']}(${parameters.join(',')})`;
const stopAtFirstOpcode = getConfigValue('stop-at-first-opcode', true);
const showSourcemaps = getConfigValue('show-sourcemaps', false);
const debugConfigName = `${contractName}.${methodSignature}`;
const jsonRpcUrl = getConfigValue('json-rpc-url', 'http://localhost:8545');
const sourcifyUrl = getConfigValue('sourcify-url', 'http://localhost:5555');
const autobuild = getConfigValue('autobuild', true);
if (autobuild) {
const build = forgeBuildTask(activeTextEditor.document.uri);
const buildExecution = await vscode.tasks.executeTask(build);
try {
await completed(buildExecution);
} catch (e) {
vscode.window.showErrorMessage('Failed to build project.');
const parameters = method.parameters.flatMap((param: VariableDeclaration) => {
if (param.typeName === null) {
console.error(
`Missing TypeName for parameter ${param} in method ${method} in contract ${contract}`
);
return [];
}
const typeName: TypeName = param.typeName;
if (!('name' in typeName)) {
console.error(
`Missing name for TypeName for parameter ${param} in method ${method} in contract ${contract}`
);
return [];
}
if (typeof typeName.name !== 'string') {
console.error(
`Unexpected type for name of TypeName for parameter ${param} in method ${method} in contract ${contract}`
);
return [];
}
return [typeName.name];
});

const file = activeTextEditor.document.uri.toString();
const contractName = contract['name'];
const methodSignature = `${method['name']}(${parameters.join(',')})`;
const stopAtFirstOpcode = getConfigValue('stop-at-first-opcode', true);
const showSourcemaps = getConfigValue('show-sourcemaps', false);
const debugConfigName = `${contractName}.${methodSignature}`;
const jsonRpcUrl = getConfigValue('json-rpc-url', 'http://localhost:8545');
const sourcifyUrl = getConfigValue('sourcify-url', 'http://localhost:5555');
const autobuild = getConfigValue('autobuild', true);
if (autobuild) {
progress.report({ message: "Compiling" });
const build = forgeBuildTask(activeTextEditor.document.uri);
const buildExecution = await vscode.tasks.executeTask(build);
try {
await completed(buildExecution);
} catch (e) {
vscode.window.showErrorMessage('Failed to build project.');
return;
}
}
}
const myFoundryRoot = await foundryRoot(activeTextEditor.document.uri);
const buildInfo = await loadBuildInfo(activeTextEditor.document.uri);
const myDebugConfig = debugConfig(
debugConfigName,
file,
contractName,
methodSignature,
stopAtFirstOpcode,
showSourcemaps,
jsonRpcUrl,
sourcifyUrl,
buildInfo,
myFoundryRoot
);
console.log(myDebugConfig);
const session = await vscode.debug.startDebugging(
workspaceFolder,
myDebugConfig
);
const myFoundryRoot = await foundryRoot(activeTextEditor.document.uri);
const buildInfo = await loadBuildInfo(activeTextEditor.document.uri);
const myDebugConfig = debugConfig(
debugConfigName,
file,
contractName,
methodSignature,
stopAtFirstOpcode,
showSourcemaps,
jsonRpcUrl,
sourcifyUrl,
buildInfo,
myFoundryRoot
);
console.log(myDebugConfig);
progress.report({message: "Launching testnet"});
const session = await vscode.debug.startDebugging(
workspaceFolder,
myDebugConfig
);
});
}

function completed(tastkExecution: vscode.TaskExecution): Promise<void> {
Expand Down

0 comments on commit a5ef0c9

Please sign in to comment.