Skip to content
Snippets Groups Projects
Commit 87c26f3a authored by s1995588's avatar s1995588
Browse files

Merge branch 'main' of https://gitlab.utwente.nl/dp-group-14/ide-plugin into main

parents e49f49ec 087160bc
No related branches found
No related tags found
No related merge requests found
......@@ -142,7 +142,7 @@
}
}
constantsUl.innerHTML = "";
constantsUl.innerHTML = "";
for (const file of constants) {
if (file.uri === uri) {
for (const constant of file.constants) {
......@@ -151,6 +151,10 @@
break;
}
}
constantsUl.innerHTML = constantsUl.innerHTML === ""
? "There are no undefined constants."
: constantsUl.innerHTML;
vscode.setState({ tools: oldState.tools, constants: constants, options: oldState.options, currentUri: uri });
}
......@@ -160,7 +164,7 @@
*/
function updateOptions(options) {
const optionsUl = document.querySelector("#options");
optionsUl.innerHTML = "";
optionsUl.innerHTML = options.length === 0 ? "There are no undefined options." : "";
for (const option of options) {
addOptionItem(optionsUl, option.name, option.value);
}
......
media/modest-icon.png

4.81 KiB | W: | H:

media/modest-icon.png

40.6 KiB | W: | H:

media/modest-icon.png
media/modest-icon.png
media/modest-icon.png
media/modest-icon.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -20,6 +20,10 @@ ul {
padding-left: var(--container-paddding);
}
h3 {
padding-top: 8px;
}
body > *,
form > * {
margin-block-start: var(--input-margin-vertical);
......
{
"name": "modestextension",
"displayName": "ModestExtension",
"description": "Adding language support for the Modest Toolset",
"displayName": "Modest",
"description": "Language support for the Modest Toolset",
"icon": "media/modest-icon.png",
"version": "0.0.1",
"publisher": "ModestExtension developers",
"publisher": "ModestExtension-developers",
"license": "SEE LICENSE IN LICENSE",
"engines": {
"vscode": "^1.52.0"
......@@ -21,6 +22,7 @@
"jani",
"automata"
],
"preview": true,
"qna": false,
"contributes": {
"commands": [
......@@ -36,8 +38,8 @@
"command": "analysisResults.copyValue",
"title": "Copy value",
"icon": {
"light": "media/light/copy.svg",
"dark": "media/dark/copy.svg"
"light": "media/light/copy.svg",
"dark": "media/dark/copy.svg"
}
},
{
......@@ -51,9 +53,13 @@
{
"command": "analysisResults.export",
"title": "Export to JSON file"
},
{
"command": "analysisResults.openInEditor",
"title": "Open in editor"
}
],
"menus":{
"menus": {
"view/title": [
{
"command": "analysisResults.load",
......@@ -66,9 +72,9 @@
],
"view/item/context": [
{
"command": "analysisResults.copyValue",
"when": "view == analysisResults",
"group": "inline"
"command": "analysisResults.copyValue",
"when": "view == analysisResults",
"group": "inline"
},
{
"command": "analysisResults.copyValue",
......@@ -77,6 +83,10 @@
{
"command": "analysisResults.copyItem",
"when": "view == analysisResults"
},
{
"command": "analysisResults.openInEditor",
"when": "view == analysisResults"
}
]
},
......@@ -207,4 +217,4 @@
"vscode-codicons": "0.0.15",
"vscode-languageclient": "^7.0.0"
}
}
}
\ No newline at end of file
......@@ -11,12 +11,14 @@ export class AnalysisResultsProvider
readonly onDidChangeTreeData: vscode.Event<Result | undefined | null | void> =
this._onDidChangeTreeData.event;
private jsonObject: any | null;
private jsonObject: any;
private jsonPath: string;
private modestFile: string;
constructor() {
this.jsonPath = "";
this.jsonObject = null;
this.jsonPath = "";
this.modestFile = "";
}
refresh(): void {
......@@ -46,8 +48,9 @@ export class AnalysisResultsProvider
}
}
setJsonObject(jsonObject: JSON) {
setJsonObject(jsonObject: JSON | any) {
this.jsonObject = jsonObject;
this.modestFile = jsonObject["file"].split("/").pop().replace(".modest", "");
this.refresh();
}
......@@ -57,10 +60,12 @@ export class AnalysisResultsProvider
}
setJsonPath(newPath: string) {
this.jsonPath = newPath;
var jsonFile = fs.readFileSync(newPath, "utf-8");
var jsonObject = JSON.parse(jsonFile.trim());
this.setJsonObject(jsonObject);
if (this.pathExists(newPath)) {
this.jsonPath = newPath;
var jsonFile = fs.readFileSync(newPath, "utf-8");
var jsonObject = JSON.parse(jsonFile.trim());
this.setJsonObject(jsonObject);
}
}
dataToResult(data: JSON[]) {
......@@ -120,6 +125,14 @@ export class AnalysisResultsProvider
return this.jsonObject;
}
getJsonPath() {
return this.jsonPath;
}
getModestFile() {
return this.modestFile;
}
private pathExists(p: string): boolean {
try {
fs.accessSync(p);
......
......@@ -210,6 +210,11 @@ export function activate(context: ExtensionContext) {
(res: Result) => copyToClipboard(`${res.getLabel()}: ${res.getValue()}`)
);
vscode.commands.registerCommand(
"analysisResults.openInEditor",
(res: Result) => openInEditor(res.getLabel(), res.getValue())
);
vscode.commands.registerCommand(
"analysisResults.load",
() => loadResults(analysisResultsProvider)
......@@ -313,6 +318,27 @@ function exportResults(provider: AnalysisResultsProvider) {
});
}
function openInEditor(label: string, value: string) {
if(vscode.workspace.workspaceFolders !== undefined) {
let wsPath = vscode.workspace.workspaceFolders[0].uri.path;
const date = new Date().toISOString().split('.')[0];
const newFile = vscode.Uri.parse(`untitled:${wsPath}/analysis/${label}-${date}.txt`);
vscode.workspace.openTextDocument(newFile).then(async document => {
const edit = new vscode.WorkspaceEdit();
const regex = new RegExp('(\\)|\\.),', 'gm');
var newText = value.replace(regex, "$1,\n");
console.log(newText);
edit.insert(newFile, new vscode.Position(0, 0), newText);
const success = await vscode.workspace.applyEdit(edit);
if (success) {
vscode.window.showTextDocument(document);
} else {
vscode.window.showInformationMessage(`Could not open ${label} in editor.`);
}
});
}
}
class ModestSidebarProvider implements vscode.WebviewViewProvider {
public static readonly viewType = "modest.modestSidebar";
......@@ -408,14 +434,15 @@ class ModestSidebarProvider implements vscode.WebviewViewProvider {
<title>Modest run dialog</title>
</head>
<body>
<h3>Select tool</h3>
<div id="run-box">
<select class="tools-dropdown" id="tools"> </select>
<button id="run-button"><i class="codicon codicon-play"></i></button>
</div>
<h3>Constants</h3>
<ul class="option-list" id="constants"> </ul>
<ul class="option-list" id="constants">There are no undefined constants.</ul>
<h3>Options</h3>
<ul class="option-list" id="options"> </ul>
<ul class="option-list" id="options">There are no undefined options.</ul>
<script nonce="${nonce}" src="${scriptUri}"></script>
</body>
</html>`;
......
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