Skip to content

Commit 12f379f

Browse files
committed
Merge branch '1117-update-vscode-extension-to-use-latest-nodejs-lts-version' into 'master'
Resolve "Update VSCode extension to use latest nodejs LTS version" Closes #1117 See merge request eng/ide/ada_language_server!1154
2 parents 64e2e73 + de9d194 commit 12f379f

File tree

7 files changed

+838
-2563
lines changed

7 files changed

+838
-2563
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,5 @@ subprojects/
105105

106106
# Temporary testsuite's files and directories
107107
testsuite/ada_lsp/project_symlinks/link
108+
109+
out

integration/vscode/ada/package-lock.json

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

integration/vscode/ada/package.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"publisher": "AdaCore",
77
"license": "GPL-3.0",
88
"engines": {
9-
"vscode": "^1.67.0"
9+
"vscode": "^1.71.2"
1010
},
1111
"categories": [
1212
"Programming Languages",
@@ -475,22 +475,22 @@
475475
]
476476
},
477477
"devDependencies": {
478-
"@types/glob": "7.2.0",
479-
"@types/mocha": "9.1.1",
480-
"@types/node": "14.17.6",
481-
"@types/vscode": "1.64.0",
482-
"@typescript-eslint/eslint-plugin": "5.21.0",
483-
"@typescript-eslint/parser": "5.21.0",
484-
"@vscode/test-electron": "2.1.3",
485-
"eslint": "8.14.0",
486-
"eslint-config-prettier": "8.5.0",
487-
"eslint-plugin-prettier": "4.0.0",
488-
"eslint-plugin-tsdoc": "0.2.16",
489-
"glob": "7.2.0",
490-
"mocha": "9.2.2",
491-
"prettier": "2.6.2",
492-
"typescript": "4.6.3",
493-
"vscode-tmgrammar-test": "0.0.11"
478+
"@types/mocha": "10.0.1",
479+
"@types/node": "18.15.3",
480+
"@types/vscode": "1.71.0",
481+
"@types/ws": "8.5.4",
482+
"@typescript-eslint/eslint-plugin": "5.54.0",
483+
"@typescript-eslint/parser": "5.55.0",
484+
"@vscode/test-electron": "2.3.0",
485+
"eslint": "8.36.0",
486+
"eslint-config-prettier": "8.7.0",
487+
"eslint-plugin-prettier": "4.2.1",
488+
"eslint-plugin-tsdoc": "0.2.17",
489+
"glob": "9.3.0",
490+
"mocha": "10.2.0",
491+
"prettier": "2.8.4",
492+
"typescript": "4.9.5",
493+
"vscode-tmgrammar-test": "0.1.1"
494494
},
495495
"scripts": {
496496
"vscode:prepublish": "npm run esbuild-base -- --minify",
@@ -502,11 +502,11 @@
502502
"test": "node ./out/test/runTest.js"
503503
},
504504
"dependencies": {
505-
"@types/command-exists": "^1.2.0",
506-
"command-exists": "^1.2.9",
505+
"@types/command-exists": "1.2.0",
506+
"command-exists": "1.2.9",
507507
"fp-ts": "2.12.0",
508508
"process": "0.11.10",
509509
"vscode-languageclient": "7.0.0",
510-
"ws": "8.5.0"
510+
"ws": "8.13.0"
511511
}
512-
}
512+
}

integration/vscode/ada/src/extension.ts

Lines changed: 61 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -139,29 +139,27 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
139139
// Create the language client
140140
return new LanguageClient(id, name, serverOptions, clientOptions);
141141
}
142+
142143
// Create the GPR language client and start it.
143144
const gprClient = createClient('gpr', 'GPR Language Server', ['--language-gpr'], '**/.{gpr}');
144145
context.subscriptions.push(gprClient.start());
146+
145147
// Create the Ada language client and start it.
146-
const client = createClient('ada', 'Ada Language Server', [], '**/.{adb,ads,adc,ada}');
148+
const alsClient = createClient('ada', 'Ada Language Server', [], '**/.{adb,ads,adc,ada}');
147149
const alsMiddleware: Middleware = {
148-
executeCommand: alsCommandExecutor(client),
150+
executeCommand: alsCommandExecutor(alsClient),
149151
};
150-
client.clientOptions.middleware = alsMiddleware;
151-
client.registerFeature(new ALSClientFeatures());
152-
153-
const disposable = client.start();
154-
// Push the disposable to the context's subscriptions so that the
155-
// client can be deactivated on extension deactivation
156-
context.subscriptions.push(disposable);
152+
alsClient.clientOptions.middleware = alsMiddleware;
153+
alsClient.registerFeature(new ALSClientFeatures());
154+
context.subscriptions.push(gprClient.start());
157155

158156
// Take active editor URI and call execute 'als-other-file' command in LSP
159157
function otherFileHandler() {
160158
const activeEditor = vscode.window.activeTextEditor;
161159
if (!activeEditor) {
162160
return;
163161
}
164-
void client.sendRequest(ExecuteCommandRequest.type, {
162+
void alsClient.sendRequest(ExecuteCommandRequest.type, {
165163
command: 'als-other-file',
166164
arguments: [
167165
{
@@ -205,69 +203,66 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
205203
// projects' source directories are not placed under the root project's directory).
206204
// Do nothing is the user did not setup any workspace file.
207205
if (vscode.workspace.workspaceFile !== undefined) {
208-
await client.onReady().then(async () => {
209-
await client
210-
.sendRequest<[ALSSourceDirDescription]>('workspace/alsSourceDirs')
211-
.then(async (source_dirs) => {
212-
const workspace_folders = vscode.workspace.workspaceFolders ?? [];
213-
const workspace_dirs_to_add: { uri: vscode.Uri; name?: string | undefined }[] =
214-
[];
206+
await alsClient
207+
.sendRequest<[ALSSourceDirDescription]>('workspace/alsSourceDirs')
208+
.then(async (source_dirs) => {
209+
const workspace_folders = vscode.workspace.workspaceFolders ?? [];
210+
const workspace_dirs_to_add: { uri: vscode.Uri; name?: string | undefined }[] = [];
215211

216-
for (const source_dir of source_dirs) {
217-
const source_dir_uri = vscode.Uri.parse(source_dir.uri);
218-
const source_dir_path = source_dir_uri.path;
212+
for (const source_dir of source_dirs) {
213+
const source_dir_uri = vscode.Uri.parse(source_dir.uri);
214+
const source_dir_path = source_dir_uri.path;
219215

220-
const is_subdirectory = (dir: string, parent: string) => {
221-
// Use lower-case on Windows since drives can be specified in VS Code
222-
// either with lower or upper case characters.
223-
if (process.platform == 'win32') {
224-
dir = dir.toLowerCase();
225-
parent = parent.toLowerCase();
226-
}
216+
const is_subdirectory = (dir: string, parent: string) => {
217+
// Use lower-case on Windows since drives can be specified in VS Code
218+
// either with lower or upper case characters.
219+
if (process.platform == 'win32') {
220+
dir = dir.toLowerCase();
221+
parent = parent.toLowerCase();
222+
}
227223

228-
return dir.startsWith(parent + '/');
229-
};
224+
return dir.startsWith(parent + '/');
225+
};
230226

231-
// If the source directory is not under one of the workspace folders, push
232-
// this source directory to the workspace folders to add later.
233-
if (
234-
!workspace_folders.some((workspace_folder) =>
235-
is_subdirectory(source_dir_path, workspace_folder.uri.path)
236-
)
237-
) {
238-
workspace_dirs_to_add.push({
239-
name: source_dir.name,
240-
uri: source_dir_uri,
241-
});
242-
}
227+
// If the source directory is not under one of the workspace folders, push
228+
// this source directory to the workspace folders to add later.
229+
if (
230+
!workspace_folders.some((workspace_folder) =>
231+
is_subdirectory(source_dir_path, workspace_folder.uri.path)
232+
)
233+
) {
234+
workspace_dirs_to_add.push({
235+
name: source_dir.name,
236+
uri: source_dir_uri,
237+
});
243238
}
239+
}
244240

245-
// If there are some source directories missing in the workspace, ask the user
246-
// to add them in his workspace.
247-
if (workspace_dirs_to_add.length > 0) {
248-
await vscode.window
249-
.showInformationMessage(
250-
'Some project source directories are not ' +
251-
'listed in your workspace: do you want to add them?',
252-
'Yes',
253-
'No'
254-
)
255-
.then((answer) => {
256-
if (answer === 'Yes') {
257-
for (const workspace_dir of workspace_dirs_to_add) {
258-
vscode.workspace.updateWorkspaceFolders(
259-
vscode.workspace.workspaceFolders
260-
? vscode.workspace.workspaceFolders.length
261-
: 0,
262-
null,
263-
workspace_dir
264-
);
265-
}
241+
// If there are some source directories missing in the workspace, ask the user
242+
// to add them in his workspace.
243+
if (workspace_dirs_to_add.length > 0) {
244+
await vscode.window
245+
.showInformationMessage(
246+
'Some project source directories are not ' +
247+
'listed in your workspace: do you want to add them?',
248+
'Yes',
249+
'No'
250+
)
251+
.then((answer) => {
252+
if (answer === 'Yes') {
253+
for (const workspace_dir of workspace_dirs_to_add) {
254+
vscode.workspace.updateWorkspaceFolders(
255+
vscode.workspace.workspaceFolders
256+
? vscode.workspace.workspaceFolders.length
257+
: 0,
258+
null,
259+
workspace_dir
260+
);
266261
}
267-
});
268-
}
269-
});
270-
});
262+
}
263+
});
264+
}
265+
});
271266
}
272267
}
273268

integration/vscode/ada/src/gnatTaskProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
----------------------------------------------------------------------------*/
1717

1818
import * as vscode from 'vscode';
19-
import commandExists = require('command-exists');
19+
import commandExists from 'command-exists';
2020
import { SymbolKind } from 'vscode';
2121

2222
/**
Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import * as path from 'path';
2-
import * as Mocha from 'mocha';
3-
import * as glob from 'glob';
1+
import { resolve } from 'path';
2+
import { Glob, GlobOptionsWithFileTypesUnset } from 'glob';
3+
import Mocha from 'mocha';
44

55
export function run(): Promise<void> {
66
// Create the mocha test
@@ -9,29 +9,25 @@ export function run(): Promise<void> {
99
color: true,
1010
});
1111

12-
const testsRoot = path.resolve(__dirname, '..');
12+
const testsRoot = resolve(__dirname, '..');
1313

1414
return new Promise((c, e) => {
15-
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
16-
if (err) {
17-
return e(err);
18-
}
19-
20-
// Add files to the test suite
21-
files.forEach((f) => mocha.addFile(path.resolve(testsRoot, f)));
22-
23-
try {
24-
// Run the mocha test
25-
mocha.run((failures) => {
26-
if (failures > 0) {
27-
e(new Error(`${failures} tests failed.`));
28-
} else {
29-
c();
30-
}
31-
});
32-
} catch (err) {
33-
e(err);
34-
}
35-
});
15+
const globOptions: GlobOptionsWithFileTypesUnset = { cwd: testsRoot };
16+
const g = new Glob('**/**.test.js', globOptions);
17+
for (const file of g) {
18+
mocha.addFile(resolve(testsRoot, file));
19+
}
20+
try {
21+
// Run the mocha test
22+
mocha.run((failures) => {
23+
if (failures > 0) {
24+
e(new Error(`${failures} tests failed.`));
25+
} else {
26+
c();
27+
}
28+
});
29+
} catch (err) {
30+
e(err);
31+
}
3632
});
3733
}

integration/vscode/ada/tsconfig.json

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
{
2-
"compilerOptions": {
3-
"module": "commonjs",
4-
"target": "ES2020",
5-
"outDir": "out",
6-
"lib": [
7-
"ES2020"
8-
],
9-
"sourceMap": true,
10-
"rootDir": "src",
11-
"declaration": true,
12-
"declarationMap": true,
13-
"strict": true,
14-
"removeComments": true,
15-
"moduleResolution": "node",
16-
"forceConsistentCasingInFileNames": true,
17-
"noImplicitReturns": true,
18-
"noFallthroughCasesInSwitch": true,
19-
"noUnusedParameters": true
20-
},
21-
"exclude": [
22-
"node_modules",
23-
"out"
24-
]
2+
"compilerOptions": {
3+
"module": "commonjs",
4+
"target": "ES2020",
5+
"outDir": "out",
6+
"lib": [
7+
"ES2020"
8+
],
9+
"sourceMap": true,
10+
"rootDir": "src",
11+
"declaration": true,
12+
"declarationMap": true,
13+
"strict": true,
14+
"removeComments": true,
15+
"moduleResolution": "node",
16+
"esModuleInterop": true,
17+
"forceConsistentCasingInFileNames": true,
18+
"noImplicitReturns": true,
19+
"noFallthroughCasesInSwitch": true,
20+
"noUnusedParameters": true
21+
},
22+
"exclude": [
23+
"node_modules",
24+
"out"
25+
]
2526
}

0 commit comments

Comments
 (0)