Skip to content

Commit 99e52bd

Browse files
authored
Merge pull request #683 from fortran-lang/gnikit/issue680
feat: initialise linter for projects
2 parents 5f4f6db + 02246bb commit 99e52bd

File tree

9 files changed

+318
-69
lines changed

9 files changed

+318
-69
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99

1010
### Added
1111

12+
- Added new settings for disabling Linter initialization and display of initialization Diagnostics
13+
`fortran.linter.initialize` and `fortran.experimental.keepInitDiagnostics`
14+
- Added commands for Initializing, Cleaning build artefacts and Clearing the Diagnostics from the Linter
15+
- Added support for storing build artefacts in a separate cache directory
16+
([#614](https://github.com/fortran-lang/vscode-fortran-support/issues/614))
17+
- Added a naive initialization for Fortran source files present in the workspace.
18+
The implementation cannot deduce build order so it can partially work
19+
([#680](https://github.com/fortran-lang/vscode-fortran-support/issues/680))
1220
- Added User Interface tests for program installation
1321
- Added option to disable Release Notes from being displayed
1422
([#675](https://github.com/fortran-lang/vscode-fortran-support/issues/675))
@@ -38,6 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
3846

3947
### Changed
4048

49+
- Changed the activation events of the extension to include the `onCommand` for all register commands
4150
- Changed glob resolution module to `glob` from `fast-glob` due to bug #43
4251
([#681](https://github.com/fortran-lang/vscode-fortran-support/issues/681))
4352
- Changed how Python packages are installed for unittesting for performance

package.json

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,15 @@
5252
},
5353
"activationEvents": [
5454
"onLanguage:FortranFreeForm",
55-
"onLanguage:FortranFixedForm"
55+
"onLanguage:FortranFixedForm",
56+
"onCommand:fortran.analysis.restartLanguageServer",
57+
"onCommand:fortran.analysis.rescanLinter",
58+
"onCommand:fortran.analysis.cleanLinterDiagnostics",
59+
"onCommand:fortran.analysis.cleanLinterFiles",
60+
"onCommand:fortran.analysis.initLinter",
61+
"onCommand:fortran.analysis.showWhatsNew",
62+
"onCommand:fortran.build.run",
63+
"onCommand:fortran.build.debug"
5664
],
5765
"main": "./dist/extension.js",
5866
"extensionDependencies": [
@@ -231,6 +239,12 @@
231239
"markdownDescription": "Compiler used for linting support.",
232240
"order": 0
233241
},
242+
"fortran.linter.initialize": {
243+
"type": "boolean",
244+
"default": true,
245+
"markdownDescription": "Attempt to initialize the linter by mock-compiling all files in the workspace.",
246+
"order": 5
247+
},
234248
"fortran.linter.compilerPath": {
235249
"type": "string",
236250
"default": "",
@@ -257,7 +271,7 @@
257271
"fortran.linter.modOutput": {
258272
"type": "string",
259273
"default": "",
260-
"markdownDescription": "Global output directory for .mod files generated due to linting `-J<linter.modOutput>`. Can resolve internal variables with `~`, `${workspaceFolder}`, `${env}`, `${config}`, `${file}`, `${fileDirname}`, `${fileBasenameNoExtension}`.",
274+
"markdownDescription": "Output directory for .mod files generated due to linting `-J<linter.modOutput>`. By default this is an internal VS Code path unique to each workspace. Can resolve internal variables with `~`, `${workspaceFolder}`, `${env}`, `${config}`, `${file}`, `${fileDirname}`, `${fileBasenameNoExtension}`.",
261275
"order": 40
262276
},
263277
"fortran.linter.fypp.enabled": {
@@ -307,7 +321,7 @@
307321
"std",
308322
"gfortran5"
309323
],
310-
"markdownDescription": "ine numbering marker format, currently std`, `cpp` and `gfortran5` are supported, where `std` emits `#line` pragmas similar to standard tools, 'cpp' produces line directives as emitted by GNU cpp, and `gfortran5` cpp line directives with a workaround for a bug introduced in GFortran 5. Default: `cpp`.",
324+
"markdownDescription": "Line numbering marker format, currently std`, `cpp` and `gfortran5` are supported, where `std` emits `#line` pragmas similar to standard tools, 'cpp' produces line directives as emitted by GNU cpp, and `gfortran5` cpp line directives with a workaround for a bug introduced in GFortran 5. Default: `cpp`.",
311325
"order": 120
312326
},
313327
"fortran.linter.fypp.extraArgs": {
@@ -526,6 +540,19 @@
526540
}
527541
}
528542
},
543+
{
544+
"id": "experimental",
545+
"title": "Experimental",
546+
"order": 500,
547+
"properties": {
548+
"fortran.experimental.keepInitDiagnostics": {
549+
"type": "boolean",
550+
"default": true,
551+
"markdownDescription": "Keep (and show) all diagnostics generated from the initialization of the Linter, not just from opened files.",
552+
"order": 0
553+
}
554+
}
555+
},
529556
{
530557
"id": "deprecated",
531558
"title": "Deprecated Options",
@@ -581,7 +608,22 @@
581608
{
582609
"category": "Fortran",
583610
"command": "fortran.analysis.rescanLinter",
584-
"title": "Rescan Linter paths"
611+
"title": "Rescan Linter Include paths"
612+
},
613+
{
614+
"category": "Fortran",
615+
"command": "fortran.analysis.initLinter",
616+
"title": "Initialize Fortran Linter"
617+
},
618+
{
619+
"category": "Fortran",
620+
"command": "fortran.analysis.cleanLinterFiles",
621+
"title": "Clean Linter generated files"
622+
},
623+
{
624+
"category": "Fortran",
625+
"command": "fortran.analysis.cleanLinterDiagnostics",
626+
"title": "Clean All Linter Diagnostics"
585627
},
586628
{
587629
"category": "Fortran",
@@ -615,6 +657,24 @@
615657
"title": "Rescan Linter paths",
616658
"when": "!virtualWorkspace && shellExecutionSupported"
617659
},
660+
{
661+
"category": "Fortran",
662+
"command": "fortran.analysis.initLinter",
663+
"title": "Initialize Fortran Linter",
664+
"when": "!virtualWorkspace && shellExecutionSupported"
665+
},
666+
{
667+
"category": "Fortran",
668+
"command": "fortran.analysis.cleanLinterFiles",
669+
"title": "Clean Linter generated files",
670+
"when": "!virtualWorkspace && shellExecutionSupported"
671+
},
672+
{
673+
"category": "Fortran",
674+
"command": "fortran.analysis.cleanLinterDiagnostics",
675+
"title": "Clean All Linter Diagnostics",
676+
"when": "!virtualWorkspace && shellExecutionSupported"
677+
},
618678
{
619679
"category": "Fortran",
620680
"command": "fortran.analysis.showWhatsNew",
@@ -662,7 +722,7 @@
662722
"webpack": "webpack --mode production",
663723
"pretest": "npm run compile-dev && tsc -p tsconfig.test.json",
664724
"test": "npm run test:unit && npm run test:integration && npm run test:ui",
665-
"test:ui": "extest setup-and-run -i out/test/ui/*.js -m test/ui/.mocharc.js",
725+
"test:ui": "extest setup-and-run -i out/test/ui/*.js -m test/ui/.mocharc.js -s .vscode-test -e .vscode-test/extensions",
666726
"test:unit": "node ./out/test/unitTest/runTest.js",
667727
"test:integration": "node ./out/test/integration/runTest.js",
668728
"test:grammar-free": "vscode-tmgrammar-snap -s source.fortran.free -g ./syntaxes/fortran_free-form.tmLanguage.json \"./test/fortran/syntax/**/*{.f90,F90}\"",

src/extension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ export async function activate(context: vscode.ExtensionContext) {
4747
})
4848
);
4949
// Linter is always activated but will only lint if compiler !== Disabled
50-
const linter = new FortranLintingProvider(logger);
51-
linter.activate(context.subscriptions);
50+
const linterCache = path.join(context.storageUri.fsPath);
51+
const linter = new FortranLintingProvider(logger, linterCache);
52+
context.subscriptions.push(...(await linter.activate()));
5253
vscode.languages.registerCodeActionsProvider(FortranDocumentSelector(), linter);
5354

5455
if (formatterType !== 'Disabled') {

src/features/commands.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
export const RestartLS = 'fortran.analysis.restartLanguageServer';
66
export const RescanLint = 'fortran.analysis.rescanLinter';
7+
export const CleanLintDiagnostics = 'fortran.analysis.cleanLinterDiagnostics';
8+
export const CleanLintFiles = 'fortran.analysis.cleanLinterFiles';
9+
export const InitLint = 'fortran.analysis.initLinter';
710
export const WhatsNew = 'fortran.analysis.showWhatsNew';
811
export const BuildRun = 'fortran.build.run';
912
export const BuildDebug = 'fortran.build.debug';

0 commit comments

Comments
 (0)