Skip to content

Commit 52387f8

Browse files
committed
Fix linter not working
1 parent 52c107d commit 52387f8

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

src/features/linter-provider.ts

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import ChildProcess = cp.ChildProcess;
77
import * as vscode from 'vscode';
88

99
export default class FortranLintingProvider {
10-
1110

1211
constructor(){
1312
// filename:line:col: is common for multiline and single line warnings
@@ -17,7 +16,7 @@ export default class FortranLintingProvider {
1716

1817
private diagnosticCollection: vscode.DiagnosticCollection;
1918
private doModernFortranLint(textDocument: vscode.TextDocument) {
20-
let errorRegex:RegExp = /^([^:]*):([0-9]+):([0-9]+):\n\s(.*)\n.*\n(Error|Warning):\s(.*)$/gm;
19+
let errorRegex:RegExp = /^([^:]*):([0-9]+):([0-9]+):\n\s(.*)\n.*\n(Error|Warning|Fatal Error):\s(.*)$/gm;
2120
console.log(textDocument.languageId);
2221
if (textDocument.languageId !== 'fortran90') {
2322
return;
@@ -35,12 +34,12 @@ export default class FortranLintingProvider {
3534
childProcess.stderr.on('data', (data) => {
3635
decoded += data;
3736
});
38-
childProcess.stdout.on('end', () => {
37+
childProcess.stderr.on('end', () => {
3938
let decodedOriginal = decoded;
4039

41-
let myArray;
42-
while ((myArray = errorRegex.exec(decoded)) !== null) {
43-
let elements: string[] = myArray.slice(1);
40+
let matchesArray:string[];
41+
while ((matchesArray = errorRegex.exec(decoded)) !== null) {
42+
let elements: string[] = matchesArray.slice(1); // get captured expressions
4443
let startLine = parseInt(elements[1]);
4544
let startColumn = parseInt(elements[2])
4645
let type = elements[4]; //error or warning
@@ -71,27 +70,11 @@ export default class FortranLintingProvider {
7170
}];
7271
}
7372

74-
private runCodeAction(document: vscode.TextDocument, range: vscode.Range, message: string): any {
75-
let fromRegex: RegExp = /.*Replace:(.*)==>.*/g
76-
let fromMatch: RegExpExecArray = fromRegex.exec(message.replace(/\s/g, ''));
77-
let from = fromMatch[1];
78-
let to: string = document.getText(range).replace(/\s/g, '')
79-
if (from === to) {
80-
let newText = /.*==>\s(.*)/g.exec(message)[1]
81-
let edit = new vscode.WorkspaceEdit();
82-
edit.replace(document.uri, range, newText);
83-
return vscode.workspace.applyEdit(edit);
84-
} else {
85-
vscode.window.showErrorMessage("The suggestion was not applied because it is out of date. You might have tried to apply the same edit twice.");
86-
}
87-
}
88-
8973
private command: vscode.Disposable;
9074

9175
public activate(subscriptions: vscode.Disposable[]) {
9276

93-
this.command = vscode.commands.registerCommand(FortranLintingProvider.commandId, this.runCodeAction, this);
94-
subscriptions.push(this);
77+
9578
this.diagnosticCollection = vscode.languages.createDiagnosticCollection();
9679

9780
vscode.workspace.onDidOpenTextDocument(this.doModernFortranLint, this, subscriptions);
@@ -101,7 +84,7 @@ export default class FortranLintingProvider {
10184

10285
vscode.workspace.onDidSaveTextDocument(this.doModernFortranLint, this);
10386

104-
// Hlint all open haskell documents
87+
// Run gfortran in all open fortran files
10588
vscode.workspace.textDocuments.forEach(this.doModernFortranLint, this);
10689
}
10790

0 commit comments

Comments
 (0)