Skip to content

Commit 0a75d7c

Browse files
committed
Provide 'ada' and 'spark' tasks and make 'gnat' and 'gpr' obsolete
1 parent 1c01465 commit 0a75d7c

File tree

9 files changed

+908
-365
lines changed

9 files changed

+908
-365
lines changed

integration/vscode/ada/package.json

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -479,31 +479,65 @@
479479
"description": "Extra command line arguments"
480480
}
481481
},
482-
"additionalProperties": false,
483482
"oneOf": [
484483
{
484+
"$comment": "Each oneOf is evaluated regardless of the parent schema. That's why valid properties of the parent must be repeated here in order to be allowed.",
485485
"properties": {
486486
"kind": {
487487
"enum": [
488488
"buildProject",
489489
"checkFile",
490490
"cleanProject"
491491
]
492+
},
493+
"projectFile": true,
494+
"args": true
495+
},
496+
"additionalProperties": false
497+
},
498+
{
499+
"required": [
500+
"main"
501+
],
502+
"$comment": "Each oneOf is evaluated regardless of the parent schema. That's why valid properties of the parent must be repeated here in order to be allowed.",
503+
"properties": {
504+
"kind": {
505+
"enum": [
506+
"buildMain"
507+
]
508+
},
509+
"projectFile": true,
510+
"args": true,
511+
"main": {
512+
"type": "string",
513+
"description": "Path to main source file"
492514
}
493-
}
515+
},
516+
"additionalProperties": false
494517
},
495518
{
519+
"required": [
520+
"main"
521+
],
522+
"$comment": "Each oneOf is evaluated regardless of the parent schema. That's why valid properties of the parent must be repeated here in order to be allowed.",
496523
"properties": {
497524
"kind": {
498525
"enum": [
499-
"buildMain",
500526
"buildAndRunMain"
501527
]
502528
},
529+
"projectFile": true,
530+
"args": true,
503531
"main": {
504-
"type": "string"
532+
"type": "string",
533+
"description": "Path to main source file"
534+
},
535+
"executable": {
536+
"type": "string",
537+
"description": "Path to main executable file (if it cannot be computed automatically)"
505538
}
506-
}
539+
},
540+
"additionalProperties": false
507541
}
508542
]
509543
}
@@ -553,19 +587,15 @@
553587
"taskKind"
554588
],
555589
"properties": {
556-
"type": {
557-
"type": "string",
558-
"$comment": "This pattern is intended to always fail in order to display the obsoletion message",
559-
"pattern": "^$",
560-
"patternErrorMessage": "This task type is deprecated. Use task type \"ada\" or \"spark\" instead."
561-
},
562590
"taskKind": {
563591
"type": "string",
564-
"description": "Tool and action kind"
592+
"description": "Tool and action kind",
593+
"deprecationMessage": "The task type \"gnat\" is deprecated. Use task type \"ada\" or \"spark\" instead."
565594
},
566595
"args": {
567596
"type": "array",
568-
"description": "Extra command line arguments"
597+
"description": "Extra command line arguments",
598+
"deprecationMessage": "The task type \"gnat\" is deprecated. Use task type \"ada\" or \"spark\" instead."
569599
}
570600
}
571601
},
@@ -575,23 +605,20 @@
575605
"main"
576606
],
577607
"properties": {
578-
"type": {
579-
"type": "string",
580-
"$comment": "This pattern is intended to always fail in order to display the obsoletion message",
581-
"pattern": "^$",
582-
"patternErrorMessage": "This task type is deprecated. Use task type \"ada\" or \"spark\" instead."
583-
},
584608
"projectFile": {
585609
"type": "string",
586-
"description": "The project file"
610+
"description": "The project file",
611+
"deprecationMessage": "The task type \"gpr\" is deprecated. Use task type \"ada\" instead."
587612
},
588613
"main": {
589614
"type": "string",
590-
"description": "The main file targeted"
615+
"description": "The main file targeted",
616+
"deprecationMessage": "The task type \"gpr\" is deprecated. Use task type \"ada\" instead."
591617
},
592618
"executable": {
593619
"type": "string",
594-
"description": "The related executable"
620+
"description": "The related executable",
621+
"deprecationMessage": "The task type \"gpr\" is deprecated. Use task type \"ada\" instead."
595622
}
596623
}
597624
}

integration/vscode/ada/src/clients.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { mainLogChannel } from './extension';
1111
import GnatTaskProvider from './gnatTaskProvider';
1212
import GprTaskProvider from './gprTaskProvider';
1313
import { logErrorAndThrow } from './helpers';
14+
import { registerTaskProviders } from './taskProviders';
1415

1516
export class ContextClients {
1617
public readonly gprClient: LanguageClient;
@@ -57,7 +58,7 @@ export class ContextClients {
5758
GprTaskProvider.gprTaskType,
5859
new GprTaskProvider(this.adaClient)
5960
),
60-
];
61+
].concat(registerTaskProviders());
6162
};
6263

6364
public unregisterTaskProviders = (): void => {

integration/vscode/ada/src/commands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { SymbolKind } from 'vscode';
33
import { ContextClients } from './clients';
44
import { getOrAskForProgram } from './debugConfigProvider';
55
import { mainLogChannel } from './extension';
6-
import { getEnclosingSymbol } from './gnatTaskProvider';
6+
import { getEnclosingSymbol } from './taskProviders';
77

88
export function registerCommands(context: vscode.ExtensionContext, clients: ContextClients) {
99
context.subscriptions.push(

integration/vscode/ada/src/debugConfigProvider.ts

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'assert';
22
import * as vscode from 'vscode';
33
import { contextClients } from './extension';
4-
import { getExecutables, getMains, getProjectFile } from './helpers';
4+
import { AdaMain, getAdaMains, getProjectFile } from './helpers';
55

66
/**
77
* Ada Configuration for a debug session
@@ -244,54 +244,6 @@ const setupCmd = [
244244
},
245245
];
246246

247-
/**
248-
* A class that represents an Ada main entry point. It encapsulate both the
249-
* source file path and the executable file path.
250-
*/
251-
class AdaMain {
252-
mainFullPath: string;
253-
execFullPath: string;
254-
constructor(mainFullPath: string, execFullPath: string) {
255-
this.mainFullPath = mainFullPath;
256-
this.execFullPath = execFullPath;
257-
}
258-
259-
/**
260-
* @returns path of the main source file relative to the workspace
261-
*/
262-
mainRelPath(): string {
263-
return vscode.workspace.asRelativePath(this.mainFullPath);
264-
}
265-
266-
/**
267-
* @returns path of the executable file relative to the workspace
268-
*/
269-
execRelPath(): string {
270-
return vscode.workspace.asRelativePath(this.execFullPath);
271-
}
272-
}
273-
274-
/**
275-
* @returns The list of Mains defined for the current project as an array of AdaMains.
276-
*/
277-
async function getAdaMains(): Promise<AdaMain[]> {
278-
const mains = await getMains(contextClients.adaClient);
279-
const execs = await getExecutables(contextClients.adaClient);
280-
assert(
281-
execs.length == mains.length,
282-
`The ALS returned mains.length = ${mains.length} and ` +
283-
`execs.length = ${execs.length}` +
284-
`when they should be equal`
285-
);
286-
287-
const result: AdaMain[] = [];
288-
for (let i = 0; i < mains.length; i++) {
289-
result.push(new AdaMain(mains[i], execs[i]));
290-
}
291-
292-
return result;
293-
}
294-
295247
type QuickPickAdaMain = {
296248
label: string;
297249
description: string;

0 commit comments

Comments
 (0)