Skip to content

Commit a91772a

Browse files
committed
Move obsolete code and add comments
1 parent bb1804b commit a91772a

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

integration/vscode/ada/src/gnatTaskProvider.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
-- of the license. --
1616
----------------------------------------------------------------------------*/
1717

18+
import commandExists from 'command-exists';
1819
import * as vscode from 'vscode';
1920
import { getProjectFromConfigOrALS, sparkLimitRegionArg, sparkLimitSubpArg } from './commands';
20-
import { DEFAULT_PROBLEM_MATCHER, WarningMessageExecution, alire } from './taskProviders';
21+
import { DEFAULT_PROBLEM_MATCHER, WarningMessageExecution } from './taskProviders';
2122

2223
/**
2324
* Callback to provide an extra argument for a tool
@@ -343,3 +344,15 @@ export function getScenarioArgs() {
343344
// for each scenarioVariables put `-Xname=value` option
344345
return vars.reduce(fold, []);
345346
}
347+
// Alire `exec` command if we have `alr` installed and `alire.toml`
348+
349+
export async function alire(): Promise<string[]> {
350+
return vscode.workspace.findFiles('alire.toml').then((found) =>
351+
found.length == 0
352+
? [] // not alire.toml found, return no command
353+
: // if alire.toml found, search for `alr`
354+
commandExists('alr')
355+
.then(() => ['alr', 'exec', '--'])
356+
.catch(() => [])
357+
);
358+
}

integration/vscode/ada/src/taskProviders.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
----------------------------------------------------------------------------*/
1717

1818
import assert from 'assert';
19-
import commandExists from 'command-exists';
2019
import * as vscode from 'vscode';
2120
import { CMD_GPR_PROJECT_ARGS } from './commands';
2221
import { adaExtState } from './extension';
@@ -545,6 +544,11 @@ export class SimpleTaskProvider implements vscode.TaskProvider {
545544
}
546545
}
547546

547+
/**
548+
*
549+
* @returns true if ALIRE should be used for task execution, i.e. when the
550+
* workspace contains a `alire.toml` file.
551+
*/
548552
async function useAlire() {
549553
return (await adaExtState.getAlireTomls()).length > 0;
550554
}
@@ -643,18 +647,6 @@ function isEmptyArray(obj: unknown): boolean {
643647
return false;
644648
}
645649

646-
// Alire `exec` command if we have `alr` installed and `alire.toml`
647-
export async function alire(): Promise<string[]> {
648-
return vscode.workspace.findFiles('alire.toml').then((found) =>
649-
found.length == 0
650-
? [] // not alire.toml found, return no command
651-
: // if alire.toml found, search for `alr`
652-
commandExists('alr')
653-
.then(() => ['alr', 'exec', '--'])
654-
.catch(() => [])
655-
);
656-
}
657-
658650
export function registerTaskProviders() {
659651
return [
660652
vscode.tasks.registerTaskProvider(TASK_TYPE_ADA, createAdaTaskProvider()),
@@ -1004,6 +996,17 @@ export async function findBuildMainTask(adaMain: AdaMain): Promise<vscode.Task |
1004996
);
1005997
}
1006998

999+
/**
1000+
* Create an updated task that uses the `alr` executable.
1001+
*
1002+
* If the task matches the pre-defined tasks for building and cleaning the project,
1003+
* then the commands used will be respectively `alr build` and `alr clean`.
1004+
*
1005+
* Otherwise `alr exec -- ...` is used.
1006+
*
1007+
* @param taskDef - a task definition to update to ALIRE
1008+
* @returns a copy of the given task where the `alr` executable is used.
1009+
*/
10071010
function updateToAlire(taskDef: SimpleTaskDef): SimpleTaskDef {
10081011
/**
10091012
* Only process shell command tasks, if they are not already using ALIRE

0 commit comments

Comments
 (0)