Skip to content

Commit 1711d2c

Browse files
committed
Update with npm run format
1 parent 4f6e0b8 commit 1711d2c

13 files changed

+276
-279
lines changed

src/extension.ts

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
// src/extension.ts
2-
import * as which from 'which'
3-
import * as vscode from 'vscode'
2+
import * as which from 'which';
3+
import * as vscode from 'vscode';
44

5-
import FortranLintingProvider from './features/linter-provider'
6-
import FortranHoverProvider from './features/hover-provider'
7-
import { FortranCompletionProvider } from './features/completion-provider'
8-
import { FortranDocumentSymbolProvider } from './features/document-symbol-provider'
5+
import FortranLintingProvider from './features/linter-provider';
6+
import FortranHoverProvider from './features/hover-provider';
7+
import { FortranCompletionProvider } from './features/completion-provider';
8+
import { FortranDocumentSymbolProvider } from './features/document-symbol-provider';
99

10-
import { FortranLangServer } from './lang-server'
11-
import { FORTRAN_DOCUMENT_SELECTOR, EXTENSION_ID, promptForMissingTool } from './lib/helper'
12-
import { LoggingService } from './services/logging-service'
13-
import * as pkg from '../package.json'
14-
import { LANG_SERVER_TOOL_ID } from './lib/tools'
10+
import { FortranLangServer } from './lang-server';
11+
import { FORTRAN_DOCUMENT_SELECTOR, EXTENSION_ID, promptForMissingTool } from './lib/helper';
12+
import { LoggingService } from './services/logging-service';
13+
import * as pkg from '../package.json';
14+
import { LANG_SERVER_TOOL_ID } from './lib/tools';
1515

1616
export function activate(context: vscode.ExtensionContext) {
17-
const loggingService = new LoggingService()
18-
const extensionConfig = vscode.workspace.getConfiguration(EXTENSION_ID)
17+
const loggingService = new LoggingService();
18+
const extensionConfig = vscode.workspace.getConfiguration(EXTENSION_ID);
1919

20-
loggingService.logInfo(`Extension Name: ${pkg.displayName}`)
21-
loggingService.logInfo(`Extension Version: ${pkg.version}`)
20+
loggingService.logInfo(`Extension Name: ${pkg.displayName}`);
21+
loggingService.logInfo(`Extension Version: ${pkg.version}`);
2222

2323
if (extensionConfig.get('linterEnabled', true)) {
24-
let linter = new FortranLintingProvider(loggingService)
25-
linter.activate(context.subscriptions)
26-
vscode.languages.registerCodeActionsProvider(FORTRAN_DOCUMENT_SELECTOR, linter)
27-
loggingService.logInfo('Linter is enabled')
24+
const linter = new FortranLintingProvider(loggingService);
25+
linter.activate(context.subscriptions);
26+
vscode.languages.registerCodeActionsProvider(FORTRAN_DOCUMENT_SELECTOR, linter);
27+
loggingService.logInfo('Linter is enabled');
2828
} else {
29-
loggingService.logInfo('Linter is not enabled')
29+
loggingService.logInfo('Linter is not enabled');
3030
}
3131

3232
if (extensionConfig.get('provideCompletion', true)) {
33-
let completionProvider = new FortranCompletionProvider(loggingService)
33+
const completionProvider = new FortranCompletionProvider(loggingService);
3434
vscode.languages.registerCompletionItemProvider(
3535
FORTRAN_DOCUMENT_SELECTOR,
3636
completionProvider
37-
)
37+
);
3838
} else {
39-
loggingService.logInfo('Completion Provider is not enabled')
39+
loggingService.logInfo('Completion Provider is not enabled');
4040
}
4141

4242
if (extensionConfig.get('provideHover', true)) {
43-
let hoverProvider = new FortranHoverProvider(loggingService)
44-
vscode.languages.registerHoverProvider(FORTRAN_DOCUMENT_SELECTOR, hoverProvider)
45-
loggingService.logInfo('Hover Provider is enabled')
43+
const hoverProvider = new FortranHoverProvider(loggingService);
44+
vscode.languages.registerHoverProvider(FORTRAN_DOCUMENT_SELECTOR, hoverProvider);
45+
loggingService.logInfo('Hover Provider is enabled');
4646
} else {
47-
loggingService.logInfo('Hover Provider is not enabled')
47+
loggingService.logInfo('Hover Provider is not enabled');
4848
}
4949

5050
if (extensionConfig.get('provideSymbols', true)) {
51-
let symbolProvider = new FortranDocumentSymbolProvider()
51+
const symbolProvider = new FortranDocumentSymbolProvider();
5252
vscode.languages.registerDocumentSymbolProvider(
5353
FORTRAN_DOCUMENT_SELECTOR,
5454
symbolProvider
55-
)
56-
loggingService.logInfo('Symbol Provider is enabled')
55+
);
56+
loggingService.logInfo('Symbol Provider is enabled');
5757
} else {
58-
loggingService.logInfo('Symbol Provider is not enabled')
58+
loggingService.logInfo('Symbol Provider is not enabled');
5959
}
6060

6161
// Check if the language server is installed and if not prompt to install it
6262
if (!which.sync('fortls', { nothrow: true })) {
63-
let msg = `It is highly recommended to use the fortran-language-server to
63+
const msg = `It is highly recommended to use the fortran-language-server to
6464
enable hover, peeking, gotos and many more.
6565
For a full list of features the language server adds see:
6666
https://github.com/hansec/fortran-language-server`;
@@ -69,7 +69,7 @@ export function activate(context: vscode.ExtensionContext) {
6969

7070
// Check that Fortran Intellisense is installed and if not prompt to install
7171
if (!vscode.extensions.getExtension('hansec.fortran-ls')) {
72-
let msg = `It is highly recommended to install the Fortran IntelliSense
72+
const msg = `It is highly recommended to install the Fortran IntelliSense
7373
extension. The extension is used to interface with the
7474
fortran-language-server.
7575
For a full list of features provided by the extension see:
@@ -81,15 +81,15 @@ export function activate(context: vscode.ExtensionContext) {
8181
// VS Code extension Fortran IntelliSense
8282
const useInternalFLInterface = false;
8383
if (useInternalFLInterface) {
84-
const langServer = new FortranLangServer(context, extensionConfig)
85-
langServer.start()
84+
const langServer = new FortranLangServer(context, extensionConfig);
85+
langServer.start();
8686
langServer.onReady().then(() => {
87-
const capabilities = langServer.getCapabilities()
87+
const capabilities = langServer.getCapabilities();
8888
if (!capabilities) {
8989
return vscode.window.showErrorMessage(
9090
'The language server is not able to serve any features at the moment.'
91-
)
91+
);
9292
}
93-
})
93+
});
9494
}
9595
}

src/features/completion-provider.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
1-
import { CancellationToken, TextDocument, Position, Hover } from 'vscode'
2-
import * as fs from 'fs'
3-
import * as vscode from 'vscode'
4-
import { isPositionInString, intrinsics, FORTRAN_KEYWORDS } from '../lib/helper'
5-
import { getDeclaredFunctions } from '../lib/functions'
1+
import { CancellationToken, TextDocument, Position, Hover } from 'vscode';
2+
import * as fs from 'fs';
3+
import * as vscode from 'vscode';
4+
import { isPositionInString, intrinsics, FORTRAN_KEYWORDS } from '../lib/helper';
5+
import { getDeclaredFunctions } from '../lib/functions';
66

7-
import { EXTENSION_ID } from '../lib/helper'
8-
import { LoggingService } from '../services/logging-service'
7+
import { EXTENSION_ID } from '../lib/helper';
8+
import { LoggingService } from '../services/logging-service';
99

1010
class CaseCoverter {
1111
preferredCase: string
1212
static LOWER = 'lowercase'
1313
static UPPER = 'uppercase'
1414

1515
constructor(preferredCase: string = CaseCoverter.LOWER) {
16-
this.preferredCase = preferredCase
16+
this.preferredCase = preferredCase;
1717
}
1818

1919
convert(word: string): string {
2020
if (this.preferredCase === CaseCoverter.LOWER) {
21-
return this.toLower(word)
21+
return this.toLower(word);
2222
} else if (this.preferredCase === CaseCoverter.UPPER) {
23-
return this.toUpper(word)
23+
return this.toUpper(word);
2424
}
2525

26-
throw new Error(`the provided case ${this.preferredCase} is not supported`)
26+
throw new Error(`the provided case ${this.preferredCase} is not supported`);
2727
}
2828

2929
toLower(word: string) {
30-
return word.toLowerCase()
30+
return word.toLowerCase();
3131
}
3232
toUpper(word: string) {
33-
return word.toUpperCase()
33+
return word.toUpperCase();
3434
}
3535
}
3636

@@ -48,7 +48,7 @@ export class FortranCompletionProvider
4848
position,
4949
token,
5050
vscode.workspace.getConfiguration(EXTENSION_ID)
51-
)
51+
);
5252
}
5353

5454
public provideCompletionItemsInternal(
@@ -58,51 +58,51 @@ export class FortranCompletionProvider
5858
config: vscode.WorkspaceConfiguration
5959
): Thenable<vscode.CompletionItem[]> {
6060
return new Promise<vscode.CompletionItem[]>((resolve, reject) => {
61-
let lineText = document.lineAt(position.line).text
62-
let lineTillCurrentPosition = lineText.substr(0, position.character)
61+
const lineText = document.lineAt(position.line).text;
62+
const lineTillCurrentPosition = lineText.substr(0, position.character);
6363
// nothing to complete
6464
if (lineText.match(/^\s*\/\//)) {
65-
return resolve([])
65+
return resolve([]);
6666
}
6767

68-
let inString = isPositionInString(document, position)
68+
const inString = isPositionInString(document, position);
6969
if (!inString && lineTillCurrentPosition.endsWith('"')) {
7070
// completing a string
71-
return resolve([])
71+
return resolve([]);
7272
}
7373

74-
let currentWord = this.getCurrentWord(document, position)
74+
const currentWord = this.getCurrentWord(document, position);
7575

7676
if (currentWord.match(/^\d+$/)) {
7777
// starts with a number
78-
return resolve([])
78+
return resolve([]);
7979
}
8080

81-
const caseConverter = new CaseCoverter(config.get('preferredCase'))
81+
const caseConverter = new CaseCoverter(config.get('preferredCase'));
8282

8383
if (currentWord.length === 0) {
84-
resolve([])
84+
resolve([]);
8585
}
8686

8787
const intrinsicSuggestions = this.getIntrinsicSuggestions(
8888
currentWord,
8989
caseConverter
90-
)
90+
);
9191

9292
// add keyword suggestions
93-
const keywordSuggestions = this.getKeywordSuggestions(currentWord)
93+
const keywordSuggestions = this.getKeywordSuggestions(currentWord);
9494

9595
const functionSuggestions = this.getFunctionSuggestions(
9696
document,
9797
currentWord
98-
)
98+
);
9999

100100
return resolve([
101101
...intrinsicSuggestions,
102102
...keywordSuggestions,
103103
...functionSuggestions,
104-
])
105-
})
104+
]);
105+
});
106106
}
107107

108108
private getIntrinsicSuggestions(
@@ -115,8 +115,8 @@ export class FortranCompletionProvider
115115
return new vscode.CompletionItem(
116116
caseConverter.convert(intrinsic),
117117
vscode.CompletionItemKind.Method
118-
)
119-
})
118+
);
119+
});
120120
}
121121

122122
private getKeywordSuggestions(currentWord: string): vscode.CompletionItem[] {
@@ -126,36 +126,36 @@ export class FortranCompletionProvider
126126
return new vscode.CompletionItem(
127127
keyword.toLowerCase(),
128128
vscode.CompletionItemKind.Keyword
129-
)
130-
})
129+
);
130+
});
131131
}
132132

133133
private getFunctionSuggestions(
134134
document: TextDocument,
135135
currentWord: string
136136
): vscode.CompletionItem[] {
137-
const functions = getDeclaredFunctions(document)
137+
const functions = getDeclaredFunctions(document);
138138
// check for available functions
139139
return functions
140140
.filter((fun) => fun.name.startsWith(currentWord))
141141
.map((fun) => {
142142
return new vscode.CompletionItem(
143143
`${fun.name}(`,
144144
vscode.CompletionItemKind.Function
145-
)
146-
})
145+
);
146+
});
147147
}
148148

149149
private getCurrentWord(document: TextDocument, position: Position): string {
150-
let wordAtPosition = document.getWordRangeAtPosition(position)
151-
let currentWord = ''
150+
const wordAtPosition = document.getWordRangeAtPosition(position);
151+
let currentWord = '';
152152
if (wordAtPosition && wordAtPosition.start.character < position.character) {
153-
let word = document.getText(wordAtPosition)
153+
const word = document.getText(wordAtPosition);
154154
currentWord = word.substr(
155155
0,
156156
position.character - wordAtPosition.start.character
157-
)
157+
);
158158
}
159-
return currentWord
159+
return currentWord;
160160
}
161161
}

0 commit comments

Comments
 (0)