Skip to content

Commit

Permalink
bin path not hard coded anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
naum_tomov committed Jan 9, 2024
1 parent ba321e2 commit 30ced3d
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

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

9 changes: 9 additions & 0 deletions .idea/VerCorsPlugin.iml

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

16 changes: 16 additions & 0 deletions .idea/checkstyle-idea.xml

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

19 changes: 19 additions & 0 deletions .idea/codeStyles/Project.xml

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

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

6 changes: 6 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
],
"main": "./out/extension.js",
"contributes": {
"configuration": {
"properties": {
"vercorsplugin.vercorsPath": {
"type": "string",
"description": "Path to the VerCors bin directory"
}
}
},
"languages": [
{
"id": "pvl",
Expand Down Expand Up @@ -39,6 +47,14 @@
"light": "resources\\run.svg",
"dark": "resources\\run.svg"
}
},
{
"command": "extension.setVercorsPath",
"title": "Set VerCors Path"
},
{
"command": "extension.refreshEntry",
"title": "Refresh"
}
],
"viewsContainers": {
Expand Down
4 changes: 4 additions & 0 deletions resources/folder-black.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions resources/folder-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 37 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Import the module and reference it with the alias vscode in your code below
import * as vscode from 'vscode';

import {VerCorsPathProvider} from './settingsView'

let outputChannel: vscode.OutputChannel;

/**
Expand All @@ -16,6 +18,20 @@ function activate(context: vscode.ExtensionContext) {

// Add the disposable to the context so it can be disposed of later
context.subscriptions.push(disposable);

let disposableSetPath = vscode.commands.registerCommand('extension.setVercorsPath', () => {
setVercorsPath();
});

context.subscriptions.push(disposableSetPath);

const vercorsPathProvider = new VerCorsPathProvider();
vscode.window.registerTreeDataProvider('vcpView', vercorsPathProvider);

vscode.commands.registerCommand('extension.refreshEntry', () =>
vercorsPathProvider.refresh()
);

}

/**
Expand All @@ -38,15 +54,18 @@ function activate(context: vscode.ExtensionContext) {
// Get the URI (Uniform Resource Identifier) of the current file
const uri = editor!.document.uri;
const filePath = uri.fsPath;
const command = `C:\\Users\\naumt\\Downloads\\vercors-2.0.0-windows\\vercors-2.0.0\\bin\\vercors ${filePath}`;
const vercorsPath = vscode.workspace.getConfiguration().get('vercorsplugin.vercorsPath') as string;
const command = `${vercorsPath}\\vercors ${filePath}`;



// Create the output channel if it doesn't exist
if (!outputChannel) {
outputChannel = vscode.window.createOutputChannel('Vercors Output');
}

// Clear previous content in the output channel
outputChannel.clear();
outputChannel.clear();

// Execute the command and send output to the output channel
const childProcess = require('child_process');
Expand All @@ -63,3 +82,19 @@ function activate(context: vscode.ExtensionContext) {
// Show the output channel
outputChannel.show(vscode.ViewColumn.Three); // Change the ViewColumn as needed
}


function setVercorsPath() {
vscode.window.showInputBox({
prompt: "Enter the path to the VerCors bin directory",
placeHolder: "C:\\path\\to\\vercors\\bin",
validateInput: (text) => {
// Optional: Add validation logic here if needed
return text.trim().length === 0 ? "Path cannot be empty" : null;
}
}).then((path) => {
if (path !== undefined) {
vscode.workspace.getConfiguration().update('vercorsplugin.vercorsPath', path, true);
}
});
}
44 changes: 44 additions & 0 deletions src/settingsView.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as vscode from 'vscode';
import * as path from 'path';

export class VerCorsPathProvider implements vscode.TreeDataProvider<vscode.TreeItem> {

private _onDidChangeTreeData: vscode.EventEmitter<void | vscode.TreeItem | null | undefined> = new vscode.EventEmitter<void | vscode.TreeItem | null | undefined>();
readonly onDidChangeTreeData: vscode.Event<void | vscode.TreeItem | null | undefined> = this._onDidChangeTreeData.event;

getTreeItem(element: vscode.TreeItem): vscode.TreeItem | Thenable<vscode.TreeItem> {
return element;
}

getChildren(element?: vscode.TreeItem | undefined): vscode.ProviderResult<vscode.TreeItem[]> {
// No children in this simple example
if (element) {
return Promise.resolve([]);
} else {
// Fetch the current path from the configuration
const vercorsPath = vscode.workspace.getConfiguration().get('vercorsplugin.vercorsPath') as string;
const label = `Set VerCors Binary Location`;

// Create a TreeItem with the current path as its label
const setPathCommand = new vscode.TreeItem(label, vscode.TreeItemCollapsibleState.None);
setPathCommand.command = {
command: 'extension.setVercorsPath',
title: "Set VerCors Path",
arguments: []
};

setPathCommand.tooltip = vercorsPath ? `Current VerCors Path: ${vercorsPath}` : "Set the path to the VerCors binary";

// Set the icon path using the Uri.file method
setPathCommand.iconPath = {
light: vscode.Uri.file(path.join(__filename, '..', '..', 'resources', 'folder-black.svg')),
dark: vscode.Uri.file(path.join(__filename, '..', '..', 'resources', 'folder-light.svg'))
};
return Promise.resolve([setPathCommand]);
}
}

refresh(): void {
this._onDidChangeTreeData.fire();
}
}
8 changes: 8 additions & 0 deletions test.pvl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class test {

ensures \result == 0;
int test1() {
return 0;
}

}

0 comments on commit 30ced3d

Please sign in to comment.