Skip to content

Commit 4c0b518

Browse files
Merge branch 'release/2.1.2' into dependabot/npm_and_yarn/handlebars-4.7.3
2 parents a39662d + 06eb066 commit 4c0b518

File tree

7 files changed

+56
-33
lines changed

7 files changed

+56
-33
lines changed

language-configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
{
2929
"open": "(/",
30-
"close": "/)"
30+
"close": "/"
3131
}
3232
],
3333
"surroundingPairs": [

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "linter-gfortran",
33
"displayName": "Modern Fortran",
44
"description": "Modern Fortran language support, including syntax highlighting and error detection.",
5-
"version": "2.1.1",
5+
"version": "2.1.2",
66
"publisher": "krvajalm",
77
"engines": {
88
"vscode": "^1.30.x"
@@ -120,6 +120,11 @@
120120
],
121121
"description": "Specify additional options to use when calling the gfortran compiler"
122122
},
123+
"fortran.provideSymbols": {
124+
"type": "boolean",
125+
"default": true,
126+
"description": "Enables or disables symbol functionality (disable if using 'Fortran IntelliSense')"
127+
},
123128
"fortran.symbols": {
124129
"type": [
125130
"array"
@@ -133,6 +138,16 @@
133138
],
134139
"description": "Specify what kind of symbols should be shown by the symbols' provider"
135140
},
141+
"fortran.provideHover": {
142+
"type": "boolean",
143+
"default": true,
144+
"description": "Enables or hover functionality (disable if using 'Fortran IntelliSense')"
145+
},
146+
"fortran.provideCompletion": {
147+
"type": "boolean",
148+
"default": true,
149+
"description": "Enables or disables completion functionality (disable if using 'Fortran IntelliSense')"
150+
},
136151
"fortran.preferredCase": {
137152
"type": "string",
138153
"default": "lowercase",

src/extension.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ import { FortranLangServer, checkForLangServer } from './lang-server'
1111

1212

1313
export function activate(context: vscode.ExtensionContext) {
14-
let hoverProvider = new FortranHoverProvider()
15-
let completionProvider = new FortranCompletionProvider()
16-
let symbolProvider = new FortranDocumentSymbolProvider()
1714

1815
const extensionConfig = vscode.workspace.getConfiguration(EXTENSION_ID)
1916

@@ -23,17 +20,30 @@ export function activate(context: vscode.ExtensionContext) {
2320
vscode.languages.registerCodeActionsProvider(FORTRAN_FREE_FORM_ID, linter)
2421
}
2522

26-
vscode.languages.registerCompletionItemProvider(
27-
FORTRAN_FREE_FORM_ID,
28-
completionProvider
29-
)
30-
vscode.languages.registerHoverProvider(FORTRAN_FREE_FORM_ID, hoverProvider)
31-
32-
vscode.languages.registerDocumentSymbolProvider(
33-
FORTRAN_FREE_FORM_ID,
34-
symbolProvider
35-
)
36-
23+
if (extensionConfig.get('provideCompletion', true)) {
24+
let completionProvider = new FortranCompletionProvider()
25+
vscode.languages.registerCompletionItemProvider(
26+
FORTRAN_FREE_FORM_ID,
27+
completionProvider
28+
)
29+
}
30+
31+
if (extensionConfig.get('provideHover', true)) {
32+
let hoverProvider = new FortranHoverProvider()
33+
vscode.languages.registerHoverProvider(
34+
FORTRAN_FREE_FORM_ID,
35+
hoverProvider
36+
)
37+
}
38+
39+
if (extensionConfig.get('provideSymbols', true)) {
40+
let symbolProvider = new FortranDocumentSymbolProvider()
41+
vscode.languages.registerDocumentSymbolProvider(
42+
FORTRAN_FREE_FORM_ID,
43+
symbolProvider
44+
)
45+
}
46+
3747
if (checkForLangServer(extensionConfig)) {
3848

3949
const langServer = new FortranLangServer(context, extensionConfig)

src/features/document-symbol-provider.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ export class FortranDocumentSymbolProvider
4444

4545
for (let i = 0; i < lines; i++) {
4646
let line: vscode.TextLine = document.lineAt(i);
47-
line = { ...line, text: line.text.trim() };
4847
if (line.isEmptyOrWhitespace) continue;
4948
let initialCharacter = line.text.trim().charAt(0);
5049
if (initialCharacter === "!" || initialCharacter === "#") continue;
@@ -75,12 +74,12 @@ export class FortranDocumentSymbolProvider
7574

7675
private parseSubroutineDefinition(line: TextLine) {
7776
try {
78-
const fun = getDeclaredSubroutine(line);
79-
if (fun) {
77+
const subroutine = getDeclaredSubroutine(line);
78+
if (subroutine) {
8079
let range = new vscode.Range(line.range.start, line.range.end);
8180
return new vscode.SymbolInformation(
82-
fun.name,
83-
vscode.SymbolKind.Method,
81+
subroutine.name,
82+
vscode.SymbolKind.Function,
8483
range
8584
);
8685
}
@@ -90,12 +89,11 @@ export class FortranDocumentSymbolProvider
9089
}
9190

9291
private parseFunctionDefinition(line: TextLine) {
93-
const subroutine = getDeclaredFunction(line);
94-
if (subroutine) {
92+
const fun = getDeclaredFunction(line);
93+
if (fun) {
9594
let range = new vscode.Range(line.range.start, line.range.end);
96-
9795
return new vscode.SymbolInformation(
98-
subroutine.name,
96+
fun.name,
9997
vscode.SymbolKind.Function,
10098
range
10199
);

src/lib/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export const parseSubroutine = (line: TextLine) => {
7474
return _parse(line, MethodType.Subroutine);
7575
};
7676
export const _parse = (line: TextLine, type: MethodType) => {
77-
const functionRegEx = /([a-zA-Z]+(\([\w.=]+\))*)*\s*\bfunction\b\s*([a-zA-Z_][a-z0-9_]*)\s*\((\s*[a-z_][a-z0-9_,\s]*)*\s*(\)|\&)\s*(result\([a-z_][\w]*(\)|\&))*/i;
77+
const functionRegEx = /(?<=([a-zA-Z]+(\([\w.=]+\))*)*)\s*\bfunction\b\s*([a-zA-Z_][a-z0-9_]*)\s*\((\s*[a-z_][a-z0-9_,\s]*)*\s*(?:\)|\&)\s*(result\([a-z_][\w]*(?:\)|\&))*/i;
7878
const subroutineRegEx = /^\s*(?!\bend\b)\w*\s*\bsubroutine\b\s*([a-z][a-z0-9_]*)\s*(?:\((\s*[a-z][a-z0-9_,\s]*)*\s*(\)|\&))*/i;
7979
const regEx =
8080
type === MethodType.Subroutine ? subroutineRegEx : functionRegEx;

src/lib/helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const _loadDocString = (keyword: string) => {
8787
};
8888

8989
export const getIncludeParams = (paths: string[]) => {
90-
return paths.map(path => `-I${path}`)
90+
return paths.map(path => `-I${path}`);
9191
};
9292

9393
export function isPositionInString(

0 commit comments

Comments
 (0)