@@ -7,6 +7,7 @@ import which from 'which';
77import * as semver from 'semver' ;
88import * as vscode from 'vscode' ;
99
10+ import * as pkg from '../../package.json' ;
1011import { Logger } from '../services/logging' ;
1112import { GNULinter , GNUModernLinter , IntelLinter , LFortranLinter , NAGLinter } from '../lib/linters' ;
1213import {
@@ -147,7 +148,7 @@ export class LinterSettings {
147148}
148149
149150export class FortranLintingProvider {
150- constructor ( private logger : Logger = new Logger ( ) ) {
151+ constructor ( private logger : Logger = new Logger ( ) , private storageUI : string = '' ) {
151152 // Register the Linter provider
152153 this . fortranDiagnostics = vscode . languages . createDiagnosticCollection ( 'Fortran' ) ;
153154 this . settings = new LinterSettings ( this . logger ) ;
@@ -206,9 +207,6 @@ export class FortranLintingProvider {
206207 context . subscriptions
207208 ) ;
208209
209- // This is where we should be storing the .mod files
210- // context.storageUri.fsPath;
211-
212210 vscode . workspace . onDidSaveTextDocument ( this . doLint , this ) ;
213211
214212 // Run gfortran in all open fortran files
@@ -243,29 +241,49 @@ export class FortranLintingProvider {
243241
244242 private async initialize ( ) {
245243 const files = await this . getFiles ( ) ;
246- for ( const file of files ) {
247- await this . doBuild ( await vscode . workspace . openTextDocument ( file ) ) ;
248- }
244+ const opts = {
245+ location : vscode . ProgressLocation . Window ,
246+ title : 'Initialization' ,
247+ cancellable : true ,
248+ } ;
249+ await vscode . window . withProgress ( opts , async ( progress , token ) => {
250+ token . onCancellationRequested ( ( ) => {
251+ console . log ( 'Canceled initialization' ) ;
252+ return ;
253+ } ) ;
254+ let i = 0 ;
255+ for ( const file of files ) {
256+ i ++ ;
257+ progress . report ( {
258+ message : `file ${ i } /${ files . length } ` ,
259+ } ) ;
260+ try {
261+ this . doBuild ( await vscode . workspace . openTextDocument ( file ) ) ;
262+ } catch ( error ) {
263+ continue ;
264+ }
265+ }
266+ } ) ;
249267 }
250268
251269 private async getFiles ( ) {
252270 const ignore = '**/*.{mod,smod,a,o,so}' ;
253- const files = await vscode . workspace . findFiles ( '**/*' , ignore ) ;
271+ // const regex = '**/*';
272+ const regex = `**/*{${
273+ // Free Form
274+ pkg . contributes . languages [ 0 ] . extensions . join ( ',' ) +
275+ ',' +
276+ // Fixed Form
277+ pkg . contributes . languages [ 1 ] . extensions . join ( ',' )
278+ } }`;
279+ const files = await vscode . workspace . findFiles ( regex , ignore ) ;
254280 const deps : vscode . Uri [ ] = [ ] ;
255281 for ( const file of files ) {
256282 if ( file . scheme !== 'file' ) continue ;
257283 try {
258- fs . accessSync ( file . fsPath , fs . constants . R_OK ) ;
259- try {
260- const doc = await vscode . workspace . openTextDocument ( file ) ;
261- if ( ! isFortran ( doc ) ) continue ;
262- deps . push ( file ) ;
263- } catch ( e ) {
264- // can't open document
265- continue ;
266- }
267- } catch ( e ) {
268- // no read access
284+ await fs . promises . access ( file . fsPath , fs . constants . R_OK ) ;
285+ deps . push ( file ) ;
286+ } catch ( error ) {
269287 continue ;
270288 }
271289 }
0 commit comments