From a2453e4f5f719a0dbc4543fb4759a495c4dcb42a Mon Sep 17 00:00:00 2001 From: Elie Richa Date: Mon, 27 May 2024 14:50:35 +0000 Subject: [PATCH 1/3] Add a task for compiling the current file --- integration/vscode/ada/src/taskProviders.ts | 18 ++++++++++++++++++ .../ada/test/suite/general/tasks.test.ts | 16 +++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/integration/vscode/ada/src/taskProviders.ts b/integration/vscode/ada/src/taskProviders.ts index 2d015d310..06e47acd8 100644 --- a/integration/vscode/ada/src/taskProviders.ts +++ b/integration/vscode/ada/src/taskProviders.ts @@ -114,6 +114,24 @@ const predefinedTasks: PredefinedTask[] = [ }, problemMatchers: DEFAULT_PROBLEM_MATCHER, }, + { + label: 'Compile current file', + taskDef: { + type: TASK_TYPE_ADA, + command: 'gprbuild', + args: [ + '-q', + '-f', + '-c', + '-u', + '${command:ada.gprProjectArgs}', + '${fileBasename}', + '-cargs:ada', + '-gnatef', + ], + }, + problemMatchers: DEFAULT_PROBLEM_MATCHER, + }, { label: 'Analyze the project with GNAT SAS', taskDef: { diff --git a/integration/vscode/ada/test/suite/general/tasks.test.ts b/integration/vscode/ada/test/suite/general/tasks.test.ts index 76218a08b..fb669f5d1 100644 --- a/integration/vscode/ada/test/suite/general/tasks.test.ts +++ b/integration/vscode/ada/test/suite/general/tasks.test.ts @@ -9,7 +9,14 @@ import { createAdaTaskProvider, getConventionalTaskLabel, } from '../../../src/taskProviders'; -import { activate, getCmdLine, getCommandLines, runTaskAndGetResult, testTask } from '../utils'; +import { + activate, + closeAllEditors, + getCmdLine, + getCommandLines, + runTaskAndGetResult, + testTask, +} from '../utils'; suite('Task Providers', function () { let projectPath: string; @@ -31,6 +38,7 @@ suite('Task Providers', function () { ada: Clean current project ada: Build current project ada: Check current file +ada: Compile current file ada: Analyze the project with GNAT SAS ada: Analyze the current file with GNAT SAS ada: Create a report after a GNAT SAS analysis @@ -54,6 +62,7 @@ ada: Build and run main - src/test.adb ada: Clean current project - gprclean -P ${projectPath} ada: Build current project - gprbuild -P ${projectPath} -cargs:ada -gnatef ada: Check current file - gprbuild -q -f -c -u -gnatc -P ${projectPath} \${fileBasename} -cargs:ada -gnatef +ada: Compile current file - gprbuild -q -f -c -u -P ${projectPath} \${fileBasename} -cargs:ada -gnatef ada: Analyze the project with GNAT SAS - gnatsas analyze -P ${projectPath} ada: Analyze the current file with GNAT SAS - gnatsas analyze -P ${projectPath} --file=\${fileBasename} ada: Create a report after a GNAT SAS analysis - gnatsas report sarif -P ${projectPath} -o report.sarif @@ -212,10 +221,15 @@ suite('Task Execution', function () { allProvidedTasks.push(...(await createAdaTaskProvider().provideTasks())); }); + this.beforeEach(async function () { + await closeAllEditors(); + }); + declTaskTest('ada: Build current project'); declTaskTest('ada: Run main - src/main1.adb'); declTaskTest('ada: Run main - src/test.adb'); declTaskTest('ada: Check current file', openSrcFile); + declTaskTest('ada: Compile current file', openSrcFile); declTaskTest('ada: Clean current project'); declTaskTest('ada: Build main - src/main1.adb'); declTaskTest('ada: Build main - src/test.adb'); From 8aa8c1949070bd71039272f5f2600975ca397c8c Mon Sep 17 00:00:00 2001 From: Anthony Leonardo Gracio Date: Wed, 26 Jun 2024 12:20:14 +0000 Subject: [PATCH 2/3] Fix npm warning about unused function (no-issue-check) --- integration/vscode/ada/test/suite/general/codelens.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/integration/vscode/ada/test/suite/general/codelens.test.ts b/integration/vscode/ada/test/suite/general/codelens.test.ts index f57f24b48..b2b6c34d8 100644 --- a/integration/vscode/ada/test/suite/general/codelens.test.ts +++ b/integration/vscode/ada/test/suite/general/codelens.test.ts @@ -72,6 +72,7 @@ suite('CodeLens', function () { }); }); +// eslint-disable-next-line @typescript-eslint/no-unused-vars function toString(codelenses: import('vscode').CodeLens[] | null | undefined): unknown { return JSON.stringify( codelenses?.map((cl) => ({ From 84400cfd4a63215631274f2c9d028f306e48f438 Mon Sep 17 00:00:00 2001 From: Elie Richa Date: Wed, 26 Jun 2024 11:50:42 +0000 Subject: [PATCH 3/3] Create a GNAT SAS task to analyse and report the current file For eng/ide/ada_language_server#1365 --- integration/vscode/ada/src/taskProviders.ts | 15 +++++++++++++++ .../vscode/ada/test/suite/general/tasks.test.ts | 2 ++ 2 files changed, 17 insertions(+) diff --git a/integration/vscode/ada/src/taskProviders.ts b/integration/vscode/ada/src/taskProviders.ts index 06e47acd8..5768bf2db 100644 --- a/integration/vscode/ada/src/taskProviders.ts +++ b/integration/vscode/ada/src/taskProviders.ts @@ -188,6 +188,21 @@ const predefinedTasks: PredefinedTask[] = [ */ problemMatchers: '', }, + { + label: 'Analyze the current file with GNAT SAS and produce a report', + taskDef: { + type: TASK_TYPE_ADA, + compound: [ + 'Analyze the current file with GNAT SAS', + 'Create a report after a GNAT SAS analysis', + ], + }, + /** + * Analysis results are not printed on stdio so no need to parse them + * with a problem matcher. + */ + problemMatchers: '', + }, { label: 'Generate documentation from the project', taskDef: { diff --git a/integration/vscode/ada/test/suite/general/tasks.test.ts b/integration/vscode/ada/test/suite/general/tasks.test.ts index fb669f5d1..9af87ce1b 100644 --- a/integration/vscode/ada/test/suite/general/tasks.test.ts +++ b/integration/vscode/ada/test/suite/general/tasks.test.ts @@ -43,6 +43,7 @@ ada: Analyze the project with GNAT SAS ada: Analyze the current file with GNAT SAS ada: Create a report after a GNAT SAS analysis ada: Analyze the project with GNAT SAS and produce a report +ada: Analyze the current file with GNAT SAS and produce a report ada: Generate documentation from the project ada: Create/update test skeletons for the project ada: Build main - src/main1.adb @@ -238,6 +239,7 @@ suite('Task Execution', function () { declTaskTest('ada: Analyze the project with GNAT SAS'); declTaskTest('ada: Create a report after a GNAT SAS analysis'); declTaskTest('ada: Analyze the project with GNAT SAS and produce a report'); + declTaskTest('ada: Analyze the current file with GNAT SAS and produce a report', openSrcFile); declTaskTest('ada: Analyze the current file with GNAT SAS', openSrcFile); declTaskTest('ada: Generate documentation from the project'); declTaskTest('ada: Create/update test skeletons for the project');