Skip to content

Commit d478e42

Browse files
Merge branch 'topic/problem_matchers' into 'master'
Revamp problem matchers See merge request eng/ide/ada_language_server!2142
2 parents 3b7bf1e + 634986a commit d478e42

File tree

3 files changed

+88
-36
lines changed

3 files changed

+88
-36
lines changed

integration/vscode/ada/package.json

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -761,27 +761,9 @@
761761
}
762762
],
763763
"problemMatchers": [
764-
{
765-
"name": "ada",
766-
"label": "Gnat Ada Problem Matcher (obsolete)",
767-
"fileLocation": [
768-
"autoDetect",
769-
"${workspaceRoot}"
770-
],
771-
"pattern": [
772-
{
773-
"regexp": "^([^:]:?[^:]*):(\\d+):(\\d+):\\s+(?:([a-z]+):\\s+)?(.*)$",
774-
"file": 1,
775-
"line": 2,
776-
"column": 3,
777-
"severity": 4,
778-
"message": 5
779-
}
780-
]
781-
},
782764
{
783765
"name": "ada-error",
784-
"label": "Gnat Ada Error Problem Matcher",
766+
"label": "Ada Error Problem Matcher (parentheses and semicolon format)",
785767
"fileLocation": [
786768
"autoDetect",
787769
"${workspaceRoot}"
@@ -790,17 +772,17 @@
790772
"severity": "error",
791773
"pattern": [
792774
{
793-
"regexp": "^([^:]:?[^:]*):(\\d+):(\\d+):\\s+[\\(:]?(error)[\\):]?\\s+(.*)$",
775+
"regexp": "^([^:]+):(\\d+):(\\d+):\\s+(\\((error)\\)|(error):)\\s+(.*)$",
794776
"file": 1,
795777
"line": 2,
796778
"column": 3,
797-
"message": 5
779+
"message": 7
798780
}
799781
]
800782
},
801783
{
802784
"name": "ada-warning",
803-
"label": "Gnat Ada Warning Problem Matcher",
785+
"label": "Ada Warning Problem Matcher (parentheses and semicolon format)",
804786
"fileLocation": [
805787
"autoDetect",
806788
"${workspaceRoot}"
@@ -809,17 +791,17 @@
809791
"severity": "warning",
810792
"pattern": [
811793
{
812-
"regexp": "^([^:]:?[^:]*):(\\d+):(\\d+):\\s+[\\(:]?(warning|medium|medium warning|low|low warning|style)[\\):]?\\s+(.*)$",
794+
"regexp": "^([^:]+):(\\d+):(\\d+):\\s+(\\((warning|medium|medium warning|low|low warning|style)\\)|(warning|medium|medium warning|low|low warning|style):)\\s+(.*)$",
813795
"file": 1,
814796
"line": 2,
815797
"column": 3,
816-
"message": 5
798+
"message": 7
817799
}
818800
]
819801
},
820802
{
821803
"name": "ada-info",
822-
"label": "Gnat Ada Info Problem Matcher",
804+
"label": "Ada Info Problem Matcher (parentheses and semicolon format)",
823805
"fileLocation": [
824806
"autoDetect",
825807
"${workspaceRoot}"
@@ -828,11 +810,11 @@
828810
"severity": "info",
829811
"pattern": [
830812
{
831-
"regexp": "^([^:]:?[^:]*):(\\d+):(\\d+):\\s+[\\(:]?(info|[Nn]ote|check)[\\):]?\\s+(.*)$",
813+
"regexp": "^([^:]+):(\\d+):(\\d+):\\s+(\\((info|[Nn]ote|check)\\)|(info|[Nn]ote|check):)\\s+(.*)$",
832814
"file": 1,
833815
"line": 2,
834816
"column": 3,
835-
"message": 5
817+
"message": 7
836818
}
837819
]
838820
}
@@ -1620,4 +1602,4 @@
16201602
"ws": "^8.18.0",
16211603
"yaml": "^2.8.0"
16221604
}
1623-
}
1605+
}

integration/vscode/ada/test/general/tasks.test.ts

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,23 @@ ada: Run main - src/test.adb - .${path.sep}obj${path.sep}test${exe}
274274
}
275275
});
276276

277-
test('problemMatchers severities', async () => {
277+
/**
278+
* Helper function to test problem matchers with compiler messages
279+
*/
280+
async function testProblemMatchersWithCompilerMessages(
281+
fileName: string,
282+
expectedMessages: string,
283+
) {
278284
const prov = createAdaTaskProvider();
279285
const isWindows = process.platform === 'win32';
286+
280287
/**
281-
* Run a task that dumps some compiler messages contained in the 'compiler_messages.txt' file.
288+
* Run a task that dumps some compiler messages contained in the specified file.
282289
*/
283290
const def: SimpleTaskDef = {
284291
type: 'ada',
285292
command: isWindows ? 'type' : 'cat',
286-
args: ['main_with_problem' + path.sep + 'compiler_messages.txt'],
293+
args: ['main_with_problem' + path.sep + fileName],
287294
};
288295
const task = new vscode.Task(
289296
def,
@@ -301,12 +308,23 @@ ada: Run main - src/test.adb - .${path.sep}obj${path.sep}test${exe}
301308
/**
302309
* Wait for the problemMatchers
303310
*/
304-
await new Promise((resolve) => setTimeout(resolve, 1000));
311+
await new Promise((resolve) => setTimeout(resolve, 2000));
305312
const alsDiagnostics: vscode.Diagnostic[] = vscode.languages
306313
.getDiagnostics()
307314
.flatMap(([, diagnostics]) => diagnostics)
308315
.filter((diag) => ['ada'].includes(diag.source ?? ''));
309316

317+
/**
318+
* Extract expected severities from the expected messages for Windows validation
319+
*/
320+
const expectedSeverities = expectedMessages
321+
.split('\n')
322+
.map((line) => {
323+
const match = line.match(/^(\d+):/);
324+
return match ? parseInt(match[1], 10) : null;
325+
})
326+
.filter((severity) => severity !== null);
327+
310328
/**
311329
* Check that we have the expected number of diagnostics, with the
312330
* expected severities.
@@ -316,12 +334,20 @@ ada: Run main - src/test.adb - .${path.sep}obj${path.sep}test${exe}
316334
if (isWindows) {
317335
assert.deepEqual(
318336
alsDiagnostics.map((d) => d.severity),
319-
[1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2],
337+
expectedSeverities,
320338
);
321339
} else {
322340
assert.equal(
323341
alsDiagnostics.map((d) => `${d.severity}: ${d.message}`).join('\n'),
324-
`
342+
expectedMessages,
343+
);
344+
}
345+
}
346+
347+
test('problemMatchers severities', async () => {
348+
await testProblemMatchersWithCompilerMessages(
349+
'compiler_messages.txt',
350+
`
325351
1: procedure "Hello" is not referenced [-gnatwu]
326352
1: bad casing of "Hello" declared at line 4 [-gnatyr]
327353
1: bad casing of "Hello" declared at line 4 [-gnatyr]
@@ -334,8 +360,33 @@ ada: Run main - src/test.adb - .${path.sep}obj${path.sep}test${exe}
334360
0: missing ";"
335361
2: this is an extra message
336362
2: hello world (trying: to confuse the regexp here)`.trim(),
337-
);
338-
}
363+
);
364+
});
365+
366+
test('problemMatchers severities (warnings only)', async () => {
367+
await testProblemMatchersWithCompilerMessages(
368+
'compiler_messages_warnings_only.txt',
369+
`
370+
1: no entities of "Ada.Strings.Fixed" are referenced [-gnatwu]
371+
1: use clause for package "Fixed" has no effect [-gnatwu]
372+
1: no entities of "GNAT.Strings" are referenced [-gnatwu]
373+
1: use clause for package "Strings" has no effect [-gnatwu]
374+
1: no entities of "GNATCOLL.Utils" are referenced [-gnatwu]
375+
1: use clause for package "Utils" has no effect [-gnatwu]
376+
1: no entities of "GPS.Intl" are referenced [-gnatwu]
377+
1: use clause for package "Intl" has no effect [-gnatwu]
378+
1: no entities of "GPS.Kernel.Task_Manager" are referenced [-gnatwu]
379+
1: use clause for package "Task_Manager" has no effect [-gnatwu]
380+
1: no entities of "Commands" are referenced [-gnatwu]
381+
1: use clause for package "Commands" has no effect [-gnatwu]
382+
1: use clause for package "GUI_Utils" has no effect [-gnatwu]
383+
1: no entities of "Language_Handlers" are referenced [-gnatwu]
384+
1: use clause for package "Language_Handlers" has no effect [-gnatwu]
385+
1: no entities of "String_Utils" are referenced [-gnatwu]
386+
1: use clause for package "String_Utils" has no effect [-gnatwu]
387+
1: use clause for package "Known" has no effect [-gnatwu]
388+
1: function "Get_Or_Create_Manager" is not referenced [-gnatwu]`.trim(),
389+
);
339390
});
340391
});
341392

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/home/unknown/dev/toolchains_editor.adb:20:17: warning: no entities of "Ada.Strings.Fixed" are referenced [-gnatwu]
2+
/home/unknown/dev/toolchains_editor.adb:20:32: warning: use clause for package "Fixed" has no effect [-gnatwu]
3+
/home/unknown/dev/toolchains_editor.adb:24:10: warning: no entities of "GNAT.Strings" are referenced [-gnatwu]
4+
/home/unknown/dev/toolchains_editor.adb:24:32: warning: use clause for package "Strings" has no effect [-gnatwu]
5+
/home/unknown/dev/toolchains_editor.adb:27:14: warning: no entities of "GNATCOLL.Utils" are referenced [-gnatwu]
6+
/home/unknown/dev/toolchains_editor.adb:27:32: warning: use clause for package "Utils" has no effect [-gnatwu]
7+
/home/unknown/dev/toolchains_editor.adb:33:09: warning: no entities of "GPS.Intl" are referenced [-gnatwu]
8+
/home/unknown/dev/toolchains_editor.adb:33:32: warning: use clause for package "Intl" has no effect [-gnatwu]
9+
/home/unknown/dev/toolchains_editor.adb:37:16: warning: no entities of "GPS.Kernel.Task_Manager" are referenced [-gnatwu]
10+
/home/unknown/dev/toolchains_editor.adb:37:32: warning: use clause for package "Task_Manager" has no effect [-gnatwu]
11+
/home/unknown/dev/toolchains_editor.adb:39:06: warning: no entities of "Commands" are referenced [-gnatwu]
12+
/home/unknown/dev/toolchains_editor.adb:39:32: warning: use clause for package "Commands" has no effect [-gnatwu]
13+
/home/unknown/dev/toolchains_editor.adb:40:32: warning: use clause for package "GUI_Utils" has no effect [-gnatwu]
14+
/home/unknown/dev/toolchains_editor.adb:41:06: warning: no entities of "Language_Handlers" are referenced [-gnatwu]
15+
/home/unknown/dev/toolchains_editor.adb:41:32: warning: use clause for package "Language_Handlers" has no effect [-gnatwu]
16+
/home/unknown/dev/toolchains_editor.adb:43:06: warning: no entities of "String_Utils" are referenced [-gnatwu]
17+
/home/unknown/dev/toolchains_editor.adb:43:32: warning: use clause for package "String_Utils" has no effect [-gnatwu]
18+
/home/unknown/dev/toolchains_editor.adb:45:32: warning: use clause for package "Known" has no effect [-gnatwu]
19+
/home/unknown/dev/toolchains_editor.adb:83:13: warning: function "Get_Or_Create_Manager" is not referenced [-gnatwu]

0 commit comments

Comments
 (0)