Skip to content

Commit ab6733b

Browse files
committed
Merge branch 'topic/gnattest' into 'master'
Rework the GNATtest integration in VS Code See merge request eng/ide/ada_language_server!1505
2 parents 185c7ac + ceebd93 commit ab6733b

File tree

5 files changed

+831
-466
lines changed

5 files changed

+831
-466
lines changed

integration/vscode/ada/src/ExtensionState.ts

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import * as vscode from 'vscode';
2-
import { Disposable, LanguageClient } from 'vscode-languageclient/node';
2+
import { Disposable, ExecuteCommandRequest, LanguageClient } from 'vscode-languageclient/node';
33
import { AdaCodeLensProvider } from './AdaCodeLensProvider';
44
import { createClient } from './clients';
55
import { AdaInitialDebugConfigProvider, initializeDebugging } from './debugConfigProvider';
66
import { GnatTaskProvider } from './gnatTaskProvider';
7+
import { initializeTesting } from './gnattest';
78
import { GprTaskProvider } from './gprTaskProvider';
89
import { TERMINAL_ENV_SETTING_NAME } from './helpers';
910
import { registerTaskProviders } from './taskProviders';
@@ -31,6 +32,23 @@ export class ExtensionState {
3132
private registeredTaskProviders: Disposable[];
3233

3334
public readonly codelensProvider = new AdaCodeLensProvider();
35+
public readonly testController: vscode.TestController;
36+
public readonly testData: Map<vscode.TestItem, object> = new Map();
37+
38+
/**
39+
* The following fields are caches for ALS requests
40+
*/
41+
cachedProjectFile: string | undefined;
42+
cachedObjectDir: string | undefined;
43+
cachedMains: string[] | undefined;
44+
cachedExecutables: string[] | undefined;
45+
46+
public clearALSCache() {
47+
this.cachedProjectFile = undefined;
48+
this.cachedObjectDir = undefined;
49+
this.cachedMains = undefined;
50+
this.cachedExecutables = undefined;
51+
}
3452

3553
constructor(context: vscode.ExtensionContext) {
3654
this.context = context;
@@ -52,6 +70,7 @@ export class ExtensionState {
5270
const result = initializeDebugging(this.context);
5371
this.initialDebugConfigProvider = result.providerInitial;
5472
this.dynamicDebugConfigProvider = result.providerDynamic;
73+
this.testController = initializeTesting(context);
5574
}
5675

5776
public start = async () => {
@@ -110,6 +129,7 @@ export class ExtensionState {
110129
e.affectsConfiguration('ada.scenarioVariables') ||
111130
e.affectsConfiguration('ada.projectFile')
112131
) {
132+
this.clearALSCache();
113133
this.unregisterTaskProviders();
114134
this.registerTaskProviders();
115135
}
@@ -121,4 +141,60 @@ export class ExtensionState {
121141
void this.showReloadWindowPopup();
122142
}
123143
};
144+
145+
/**
146+
* @returns the full path of the main project file from the ALS
147+
*/
148+
public async getProjectFile(): Promise<string> {
149+
if (!this.cachedProjectFile) {
150+
this.cachedProjectFile = (await this.adaClient.sendRequest(ExecuteCommandRequest.type, {
151+
command: 'als-project-file',
152+
})) as string;
153+
}
154+
155+
return this.cachedProjectFile;
156+
}
157+
158+
/**
159+
*
160+
* @returns the full path of the project object directory obtained from the ALS
161+
*/
162+
public async getObjectDir(): Promise<string> {
163+
if (!this.cachedObjectDir) {
164+
this.cachedObjectDir = (await this.adaClient.sendRequest(ExecuteCommandRequest.type, {
165+
command: 'als-object-dir',
166+
})) as string;
167+
}
168+
169+
return this.cachedObjectDir;
170+
}
171+
172+
/**
173+
*
174+
* @returns the list of full paths of main sources defined in the project from the ALS
175+
*/
176+
public async getMains(): Promise<string[]> {
177+
if (!this.cachedMains) {
178+
this.cachedMains = (await this.adaClient.sendRequest(ExecuteCommandRequest.type, {
179+
command: 'als-mains',
180+
})) as string[];
181+
}
182+
183+
return this.cachedMains;
184+
}
185+
186+
/**
187+
*
188+
* @returns the list of full paths of executables corresponding to main
189+
* sources defined in the project from the ALS
190+
*/
191+
public async getExecutables(): Promise<string[]> {
192+
if (!this.cachedExecutables) {
193+
this.cachedExecutables = (await this.adaClient.sendRequest(ExecuteCommandRequest.type, {
194+
command: 'als-executables',
195+
})) as string[];
196+
}
197+
198+
return this.cachedExecutables;
199+
}
124200
}

integration/vscode/ada/src/extension.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { ExtensionState } from './ExtensionState';
2626
import { ALSClientFeatures } from './alsClientFeatures';
2727
import { alsCommandExecutor } from './alsExecuteCommand';
2828
import { registerCommands } from './commands';
29-
import { initializeTestView } from './gnattest';
3029
import {
3130
TERMINAL_ENV_SETTING_NAME,
3231
assertSupportedEnvironments,
@@ -161,8 +160,6 @@ async function activateExtension(context: vscode.ExtensionContext) {
161160

162161
await vscode.commands.executeCommand('setContext', ADA_CONTEXT, true);
163162

164-
await initializeTestView(context, adaExtState);
165-
166163
/**
167164
* This can display a dialog to the User so don't wait on the result.
168165
*/

0 commit comments

Comments
 (0)