Skip to content

Commit d44f033

Browse files
authored
Merge pull request #909 from fortran-lang/refactor/sources
Refactor extension layout
2 parents 39f79ac + 8780f87 commit d44f033

32 files changed

+265
-221
lines changed

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,14 @@ module.exports = {
1111
'@typescript-eslint/no-explicit-any': 0,
1212
'@typescript-eslint/explicit-module-boundary-types': 0,
1313
'@typescript-eslint/no-non-null-assertion': 0,
14+
15+
'import/order': [
16+
'error',
17+
{
18+
'alphabetize': { order: 'asc' },
19+
'newlines-between': 'always',
20+
'groups': ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
21+
},
22+
],
1423
},
1524
};
File renamed without changes.

src/extension.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
'use strict';
22

3+
import * as fs from 'fs';
4+
import * as path from 'path';
5+
36
import * as vscode from 'vscode';
7+
48
import * as pkg from '../package.json';
5-
import * as path from 'path';
6-
import * as fs from 'fs';
79

8-
import { FortranCompletionProvider } from './features/completion-provider';
9-
import { FortranDocumentSymbolProvider } from './features/document-symbol-provider';
10-
import { FortranFormattingProvider } from './features/formatting-provider';
10+
import { WhatsNew } from './commands/commands';
11+
import { FortranCompletionProvider } from './fallback-features/completion-provider';
12+
import { FortranDocumentSymbolProvider } from './fallback-features/document-symbol-provider';
13+
import { FortranHoverProvider } from './fallback-features/hover-provider';
14+
import { FortranFormattingProvider } from './format/provider';
15+
import { FortranLintingProvider } from './lint/provider';
1116
import { FortlsClient } from './lsp/client';
12-
import { FortranHoverProvider } from './features/hover-provider';
13-
import { FortranLintingProvider } from './features/linter-provider';
14-
import { EXTENSION_ID, FortranDocumentSelector } from './lib/tools';
1517
import { getConfigLogLevel, Logger } from './services/logging';
16-
import { WhatsNew } from './features/commands';
18+
import { EXTENSION_ID, FortranDocumentSelector } from './util/tools';
1719

1820
// Make it global to catch errors when activation fails
1921
const logger = new Logger(

src/features/completion-provider.ts renamed to src/fallback-features/completion-provider.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { CancellationToken, TextDocument, Position, Hover } from 'vscode';
2-
import * as fs from 'fs';
31
import * as vscode from 'vscode';
4-
import { isPositionInString, FORTRAN_KEYWORDS } from '../lib/helper';
5-
import { getDeclaredFunctions } from '../lib/functions';
6-
import { EXTENSION_ID } from '../lib/tools';
2+
import { Position, TextDocument } from 'vscode';
3+
74
import { Logger } from '../services/logging';
5+
import { FORTRAN_KEYWORDS, isPositionInString } from '../util/helper';
6+
import { EXTENSION_ID } from '../util/tools';
7+
8+
import { getDeclaredFunctions } from './functions';
89
import intrinsics from './intrinsics.json';
910

1011
class CaseCoverter {

src/features/document-symbol-provider.ts renamed to src/fallback-features/document-symbol-provider.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { CancellationToken, TextDocument, TextLine, SymbolInformation } from 'vscode';
2-
32
import * as vscode from 'vscode';
3+
44
import {
55
parseFunction as getDeclaredFunction,
66
parseSubroutine as getDeclaredSubroutine,
7-
} from '../lib/functions';
8-
import { parseVars as getDeclaredVar } from '../lib/variables';
9-
import { EXTENSION_ID } from '../lib/tools';
7+
} from './functions';
8+
import { parseVars as getDeclaredVar } from './variables';
109

1110
type SymbolType = 'subroutine' | 'function' | 'variable';
1211
type ParserFunc = (document: TextDocument, line: TextLine) => SymbolInformation | undefined;
File renamed without changes.

src/features/hover-provider.ts renamed to src/fallback-features/hover-provider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { CancellationToken, TextDocument, Position, Hover } from 'vscode';
2+
23
import { Logger } from '../services/logging';
4+
35
import intrinsics from './intrinsics.json';
46

57
export class FortranHoverProvider {
File renamed without changes.

src/lib/variables.ts renamed to src/fallback-features/variables.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* c8 ignore start */
22
import * as vscode from 'vscode';
3+
34
import { Variable } from './functions';
45

56
const varibleDecRegEx =

src/features/formatting-provider.ts renamed to src/format/provider.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
'use strict';
22

3-
import * as fs from 'fs';
43
import * as path from 'path';
5-
import * as which from 'which';
4+
65
import * as vscode from 'vscode';
7-
import * as cp from 'child_process';
6+
import which from 'which';
87

98
import { Logger } from '../services/logging';
109
import {
@@ -14,7 +13,7 @@ import {
1413
getWholeFileRange,
1514
spawnAsPromise,
1615
pathRelToAbs,
17-
} from '../lib/tools';
16+
} from '../util/tools';
1817

1918
export class FortranFormattingProvider implements vscode.DocumentFormattingEditProvider {
2019
private readonly workspace = vscode.workspace.getConfiguration(EXTENSION_ID);
File renamed without changes.

src/features/linter-provider.ts renamed to src/lint/provider.ts

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
'use strict';
22

3+
import * as cp from 'child_process';
34
import * as fs from 'fs';
45
import * as path from 'path';
5-
import * as cp from 'child_process';
6-
import which from 'which';
6+
7+
import { glob } from 'glob';
78
import * as semver from 'semver';
89
import * as vscode from 'vscode';
9-
import { glob } from 'glob';
10+
import which from 'which';
1011

1112
import * as pkg from '../../package.json';
13+
import {
14+
BuildDebug,
15+
BuildRun,
16+
InitLint,
17+
CleanLintFiles,
18+
RescanLint,
19+
CleanLintDiagnostics,
20+
} from '../commands/commands';
1221
import { Logger } from '../services/logging';
13-
import { GNULinter, GNUModernLinter, IntelLinter, LFortranLinter, NAGLinter } from '../lib/linters';
22+
import { GlobPaths } from '../util/glob-paths';
23+
import { arraysEqual } from '../util/helper';
1424
import {
1525
EXTENSION_ID,
1626
resolveVariables,
@@ -19,17 +29,9 @@ import {
1929
spawnAsPromise,
2030
isFortran,
2131
shellTask,
22-
} from '../lib/tools';
23-
import { arraysEqual } from '../lib/helper';
24-
import {
25-
BuildDebug,
26-
BuildRun,
27-
InitLint,
28-
CleanLintFiles,
29-
RescanLint,
30-
CleanLintDiagnostics,
31-
} from './commands';
32-
import { GlobPaths } from '../lib/glob-paths';
32+
} from '../util/tools';
33+
34+
import { GNULinter, GNUModernLinter, IntelLinter, LFortranLinter, NAGLinter } from './compilers';
3335

3436
const GNU = new GNULinter();
3537
const GNU_NEW = new GNUModernLinter();

src/lsp/client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
'use strict';
22

3+
import { spawnSync } from 'child_process';
34
import * as os from 'os';
45
import * as path from 'path';
6+
57
import * as vscode from 'vscode';
6-
import { spawnSync } from 'child_process';
78
import { commands, window, workspace, TextDocument } from 'vscode';
89
import { LanguageClient, LanguageClientOptions, ServerOptions } from 'vscode-languageclient/node';
10+
11+
import { RestartLS } from '../commands/commands';
12+
import { Logger } from '../services/logging';
913
import {
1014
EXTENSION_ID,
1115
FortranDocumentSelector,
@@ -14,9 +18,7 @@ import {
1418
getOuterMostWorkspaceFolder,
1519
pipInstall,
1620
resolveVariables,
17-
} from '../lib/tools';
18-
import { Logger } from '../services/logging';
19-
import { RestartLS } from '../features/commands';
21+
} from '../util/tools';
2022

2123
// The clients are non member variables of the class because they need to be
2224
// shared for command registration. The command operates on the client and not

src/services/logging.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { OutputChannel, window, workspace, WorkspaceConfiguration } from 'vscode';
2-
import { EXTENSION_ID } from '../lib/tools';
2+
3+
import { EXTENSION_ID } from '../util/tools';
34

45
export enum LogLevel {
56
DEBUG = 0,
File renamed without changes.
File renamed without changes.

src/lib/tools.ts renamed to src/util/tools.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import * as assert from 'assert';
2+
import * as cp from 'child_process';
13
import * as os from 'os';
24
import * as path from 'path';
5+
36
import * as vscode from 'vscode';
4-
import * as assert from 'assert';
5-
import * as cp from 'child_process';
7+
68
import { isString, isArrayOfString } from './helper';
79

810
export const LS_NAME = 'fortls';

test/integration/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import path from 'path';
2-
import Mocha from 'mocha';
2+
33
import { glob } from 'glob';
4+
import Mocha from 'mocha';
45

56
export async function run(): Promise<void> {
67
// Create the mocha test

0 commit comments

Comments
 (0)