Skip to content
Snippets Groups Projects
Commit c16ded3a authored by Sytze de Witte's avatar Sytze de Witte
Browse files

save as text implemented + minor bugfix regex

parent 835fd93c
No related branches found
No related tags found
No related merge requests found
......@@ -272,7 +272,7 @@ export class Result extends vscode.TreeItem {
// Icons for other types of model formats (e.g. JANI) can be added here...
}
const plottableRegex = /\((\d+\.?\d*[e|E]?\d*),\s*(\d+\.?\d*[e|E]?\d*)\)/gm; // (num, num), num in the form of 1, 2.3, 4e5, 4.5e6
const plottableRegex = /\((-?\d+\.?\d*[e|E]?-?\d*),\s*(-?\d+\.?\d*[e|E]?-?\d*)\)/gm; // (num, num), num in the form of -1, 2.3, 4e5, 4.5e6
if (value.match(plottableRegex)) {
this.isPlottable = true;
}
......
......@@ -292,7 +292,7 @@ export function activate(context: ExtensionContext) {
context.subscriptions.push(vscode.commands.registerCommand(
"analysisResults.openInCompView",
() => analysisResultsCompProvider.setJsonObject(analysisResultsProvider.getJsonObject())
() => analysisResultsCompProvider.setJsonObject(analysisResultsProvider.getJsonObject(), analysisResultsProvider.getTextOutput())
));
context.subscriptions.push(vscode.commands.registerCommand(
......@@ -355,10 +355,12 @@ function saveAsText(prov: AnalysisResultsProvider) {
: undefined;
vscode.window.showSaveDialog({ defaultUri: defaultUri }).then(f => {
if (f) {
fs.writeFileSync(f.fsPath, JSON.stringify(prov.getJsonObject()));
fs.writeFileSync(f.fsPath, prov.getTextOutput());
}
});
}
} else {
vscode.window.showErrorMessage("No text version available.");
}
}
function openInEditor(prov: AnalysisResultsProvider, res: Result) {
......@@ -476,12 +478,13 @@ function openFileInEditor(prov: AnalysisResultsProvider) {
async function clearView(prov: AnalysisResultsProvider) {
if (prov.getJsonObject()) {
const undo = prov.getJsonObject();
const jsonObject = prov.getJsonObject();
const textOutput = prov.getTextOutput();
prov.setJsonObject(null);
var choice = await vscode.window.showInformationMessage("Analysis results view has been cleared.", "Undo");
if (choice === "Undo") {
prov.setJsonObject(undo);
prov.setJsonObject(jsonObject, textOutput);
}
}
}
......@@ -523,7 +526,7 @@ function plotValue(res: Result, context: ExtensionContext) {
var dataPoints: {x: number, y: number}[] = [];
const value = res.getValue();
const regex = /\((\d+\.?\d*[e|E]?\d*),\s*(\d+\.?\d*[e|E]?\d*)\)/gm; // (num, num), num in the form of 1, 2.3, 4e5, 4.5e6
const regex = /\((-?\d+\.?\d*[e|E]?-?\d*),\s*(-?\d+\.?\d*[e|E]?-?\d*)\)/gm; // (num, num), num in the form of -1, 2.3, 4e5, 4.5e6
let matches = (value.match(regex) || []).map(e => [e.replace(regex, '$1'), e.replace(regex, '$2')]);
matches.forEach((element) => {
......
......@@ -129,7 +129,7 @@ function runTool(uri: string, toolName: string, constants: { name: string; value
if (data.runToken === jsonObject.runToken) {
if (data.data && data.data !== "") {
try {
analysisResultsProvider.setJsonObject(JSON.parse(data.data.trim()), "No text version available."); // TODO: text version
analysisResultsProvider.setJsonObject(JSON.parse(data.data.trim()), data.text);
const treeRoot = analysisResultsProvider.getTreeRoot();
treeView.reveal(treeRoot, { focus: false, select: false, expand: true });
} catch (error) {
......
......@@ -25,7 +25,8 @@ export interface ProgressIndication {
export interface ResultNotification {
runToken: string,
data: string
data: string,
text: string
}
//#endregion
......@@ -42,4 +43,4 @@ export function getNonce() {
}
return text;
}
//#endregion
\ No newline at end of file
//#endregion
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