feat: update error generation to consider file paths

This commit is contained in:
Guy C
2025-03-14 01:28:59 +00:00
parent d44eb24086
commit 051ef02011
3 changed files with 16 additions and 9 deletions

View File

@@ -15,8 +15,7 @@ function activate(context) {
if (document.languageId !== 'wacc') return;
let diagnostics = [];
let errors = generateErrors(document.getText());
let errors = generateErrors(document.getText(), document.fileName);
errors.forEach(error => {
console.log(error);
let range = new vscode.Range(error.line - 1 , error.column - 1, error.line - 1, error.column + error.size);
@@ -32,22 +31,21 @@ function deactivate() {
console.log('IntelliWACC is deactivating...');
}
function generateErrors(code) {
function generateErrors(code, filePath) {
try {
console.log("generating errors")
const fs = require('fs');
const tmpFilePath = '/tmp/temp_wacc_file.wacc';
const tmpFilePath = parse(filePath).dir + '/.temp_wacc_file.wacc';
fs.writeFileSync(tmpFilePath, code);
let output;
try {
// currently only works if the wacc compiler exe is in the parent directory
const waccExePath = `${__dirname}/wacc_exe`;
const waccExePath = `${__dirname}/wacc-compiler`;
output = execSync(`${waccExePath} ${tmpFilePath}`, { encoding: 'utf8', stdio: 'pipe' });
} catch (err) {
console.log("this aint working buddy")
console.log(err)
console.log("Error running compiler");
output = err.stdout;
console.log(output);
}
let errors = [];
errorRegex = /\(line ([\d]+), column ([\d]+)\):\n([^>]+)([^\^]+)([\^]+)\n([^\n]+)([^\(]*)/g

View File

@@ -20,7 +20,16 @@
"language": "wacc",
"scopeName": "source.wacc",
"path": "./syntaxes/wacc.tmLanguage.json"
}]
}],
"properties": {
"files.exclude": {
"type": "object",
"default": {
"**/.temp_wacc_file.*": true
},
"description": "Configure patterns for excluding files and folders."
}
}
},
"scripts": {
"vscode:prepublish": "npm run compile",

Binary file not shown.