@@ -7,7 +7,6 @@ import ChildProcess = cp.ChildProcess;
7
7
import * as vscode from 'vscode' ;
8
8
9
9
export default class FortranLintingProvider {
10
-
11
10
12
11
constructor ( ) {
13
12
// filename:line:col: is common for multiline and single line warnings
@@ -17,7 +16,7 @@ export default class FortranLintingProvider {
17
16
18
17
private diagnosticCollection : vscode . DiagnosticCollection ;
19
18
private doModernFortranLint ( textDocument : vscode . TextDocument ) {
20
- let errorRegex :RegExp = / ^ ( [ ^ : ] * ) : ( [ 0 - 9 ] + ) : ( [ 0 - 9 ] + ) : \n \s ( .* ) \n .* \n ( E r r o r | W a r n i n g ) : \s ( .* ) $ / gm;
19
+ let errorRegex :RegExp = / ^ ( [ ^ : ] * ) : ( [ 0 - 9 ] + ) : ( [ 0 - 9 ] + ) : \n \s ( .* ) \n .* \n ( E r r o r | W a r n i n g | F a t a l E r r o r ) : \s ( .* ) $ / gm;
21
20
console . log ( textDocument . languageId ) ;
22
21
if ( textDocument . languageId !== 'fortran90' ) {
23
22
return ;
@@ -35,12 +34,12 @@ export default class FortranLintingProvider {
35
34
childProcess . stderr . on ( 'data' , ( data ) => {
36
35
decoded += data ;
37
36
} ) ;
38
- childProcess . stdout . on ( 'end' , ( ) => {
37
+ childProcess . stderr . on ( 'end' , ( ) => {
39
38
let decodedOriginal = decoded ;
40
39
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
44
43
let startLine = parseInt ( elements [ 1 ] ) ;
45
44
let startColumn = parseInt ( elements [ 2 ] )
46
45
let type = elements [ 4 ] ; //error or warning
@@ -71,27 +70,11 @@ export default class FortranLintingProvider {
71
70
} ] ;
72
71
}
73
72
74
- private runCodeAction ( document : vscode . TextDocument , range : vscode . Range , message : string ) : any {
75
- let fromRegex : RegExp = / .* R e p l a c e : ( .* ) = = > .* / 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
-
89
73
private command : vscode . Disposable ;
90
74
91
75
public activate ( subscriptions : vscode . Disposable [ ] ) {
92
76
93
- this . command = vscode . commands . registerCommand ( FortranLintingProvider . commandId , this . runCodeAction , this ) ;
94
- subscriptions . push ( this ) ;
77
+
95
78
this . diagnosticCollection = vscode . languages . createDiagnosticCollection ( ) ;
96
79
97
80
vscode . workspace . onDidOpenTextDocument ( this . doModernFortranLint , this , subscriptions ) ;
@@ -101,7 +84,7 @@ export default class FortranLintingProvider {
101
84
102
85
vscode . workspace . onDidSaveTextDocument ( this . doModernFortranLint , this ) ;
103
86
104
- // Hlint all open haskell documents
87
+ // Run gfortran in all open fortran files
105
88
vscode . workspace . textDocuments . forEach ( this . doModernFortranLint , this ) ;
106
89
}
107
90
0 commit comments