This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathverible.ts
85 lines (80 loc) · 3.3 KB
/
verible.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Copyright 2022
// Carlos Alberto Ruiz Naranjo [carlosruiznaranjo@gmail.com]
// Ismael Perez Rojo [ismaelprojo@gmail.com ]
//
// This file is part of colibri2
//
// Colibri is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Colibri is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with colibri2. If not, see <https://www.gnu.org/licenses/>.
import { Base_linter } from "./base_linter";
import * as common from "./common";
export class Verible extends Base_linter {
binary_linux = "verible-verilog-lint ";
binary_mac = "verible-verilog-lint ";
binary_windows = "verible-verilog-lint ";
constructor() {
super();
}
async delete_previus_lint() {
return true;
}
async lint(file: string, options: common.l_options): Promise<common.l_error[]> {
const result = await this.exec_linter(file, options);
try {
file = file.replace('\\ ', ' ');
let errors_str = result.stdout;
errors_str += '\n' + result.stderr;
const errors_str_lines = errors_str.split(/\r?\n/g);
const errors: common.l_error[] = [];
errors_str_lines.forEach((line) => {
if (line.startsWith(file)) {
line = line.replace(file, '');
const terms = line.split(':');
const line_num = parseInt(terms[1].trim());
const column_num = parseInt(terms[2].trim());
if (terms.length === 3) {
const error: common.l_error = {
severity: common.LINTER_ERROR_SEVERITY.WARNING,
description: terms[3].trim(),
code: '',
location: {
file: file,
position: [line_num - 1, column_num - 1]
}
};
errors.push(error);
} else if (terms.length > 3) {
let message = "";
for (let x = 3; x < terms.length - 1; ++x) {
message += terms[x].trim() + ":";
}
message += terms[terms.length - 1].trim();
const error: common.l_error = {
severity: common.LINTER_ERROR_SEVERITY.WARNING,
description: message,
code: '',
location: {
file: file,
position: [line_num - 1, column_num - 1]
}
};
errors.push(error);
}
}
});
return errors;
} catch (error) {
return [];
}
}
}