Skip to content

Commit 16592e6

Browse files
committed
Merge branch 'topic/gnattest' into 'master'
Only cache project attributes in case of successful retrieval See merge request eng/ide/ada_language_server!1975
2 parents 1724a5d + 75cb60d commit 16592e6

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

integration/vscode/ada/src/ExtensionState.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,12 +411,15 @@ export class ExtensionState {
411411
arguments: [queryArgs],
412412
};
413413

414-
const queryPromise = this.adaClient.sendRequest(
415-
ExecuteCommandRequest.type,
416-
params,
417-
) as Promise<string | string[]>;
418-
419-
this.projectAttributeCache.set(mapKey, queryPromise);
414+
const queryPromise = this.adaClient
415+
.sendRequest(ExecuteCommandRequest.type, params)
416+
.then((value) => {
417+
/**
418+
* Only cache the promise if it was fulfilled.
419+
*/
420+
this.projectAttributeCache.set(mapKey, queryPromise);
421+
return value as string | string[];
422+
});
420423

421424
return queryPromise;
422425
} else {

integration/vscode/ada/src/gnattest.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,15 @@ export async function getHarnessDir() {
171171
/**
172172
* default to gnattest/harness if Harness_Dir is unspecified
173173
*/
174-
() => path.join('gnattest', 'harness'),
174+
(err) => {
175+
if (err instanceof Error && err.message == 'The queried attribute is not known') {
176+
return path.join('gnattest', 'harness');
177+
} else {
178+
// Reject the promise with the same error.
179+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
180+
return Promise.reject(err);
181+
}
182+
},
175183
)
176184
.then(async (value) => path.join(await adaExtState.getObjectDir(), value as string));
177185
}
@@ -878,7 +886,7 @@ async function buildTestDriverAndReportErrors(
878886

879887
buildTasks.push(instTask, buildTask);
880888
} else {
881-
const task = await findTaskByName(`${TASK_BUILD_TEST_DRIVER}`);
889+
const task = await findTaskByName(`${TASK_TYPE_ADA}: ${TASK_BUILD_TEST_DRIVER}`);
882890
buildTasks.push(task);
883891
}
884892

integration/vscode/ada/src/taskProviders.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,14 @@ export class SimpleTaskProvider implements vscode.TaskProvider {
404404
}
405405

406406
const result: vscode.Task[] = [];
407-
const targetPrefix = await adaExtState.getTargetPrefix();
408-
const isNativeProject = await adaExtState.isNativeProject();
407+
const targetPrefix = await adaExtState.getTargetPrefix().catch((err) => {
408+
logger.error('Error in task provider:\n' + err);
409+
return '';
410+
});
411+
const isNativeProject = await adaExtState.isNativeProject().catch((err) => {
412+
logger.error('Error in task provider:\n' + err);
413+
return true;
414+
});
409415

410416
/**
411417
* Start with the list of predefined tasks.
@@ -417,7 +423,12 @@ export class SimpleTaskProvider implements vscode.TaskProvider {
417423
* Add tasks based on the Mains of the project.
418424
*/
419425
taskDeclsToOffer.push(
420-
...(await getAdaMains()).flatMap((main) => {
426+
...(
427+
await getAdaMains().catch((err) => {
428+
logger.error('Error in task provider:\n' + err);
429+
return [];
430+
})
431+
).flatMap((main) => {
421432
if (token?.isCancellationRequested) {
422433
throw new vscode.CancellationError();
423434
}

0 commit comments

Comments
 (0)