Skip to content

Commit 33344aa

Browse files
Merge branch 'topic/gs.266.message_secondary_with_higher_importance' into 'master'
Avoid creating a secondary message of higher importance See merge request eng/ide/gnatstudio!486
2 parents 0c3586a + 26d15d7 commit 33344aa

File tree

7 files changed

+86
-0
lines changed

7 files changed

+86
-0
lines changed

kernel/src/gps-kernel-messages-tools_output.adb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ package body GPS.Kernel.Messages.Tools_Output is
218218
GPS.Kernel.Messages.Legacy.Get_Message_At
219219
(Container, Category, File, Line, Column);
220220

221+
if Primary /= null and then Primary.Get_Importance < Importance then
222+
-- The previous message in the same line is of lower Importance:
223+
-- Create a new Primary message for higher visibility.
224+
Primary := null;
225+
end if;
226+
221227
if Primary = null then
222228
Primary :=
223229
Message_Access
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
project Obsolescent is
2+
3+
for Source_Dirs use ("src");
4+
5+
package Builder is
6+
for Default_Switches ("Ada") use ("-gnatwj", "-f");
7+
end Builder;
8+
end Obsolescent;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
with Pack;
2+
3+
procedure Foo is
4+
begin
5+
Pack.Obs (1, 2, 3);
6+
end Foo;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
with Ada.Text_IO;
2+
3+
package body Pack is
4+
5+
---------
6+
-- Obs --
7+
---------
8+
9+
procedure Obs (I, J, K, L : Integer) is
10+
pragma Unreferenced (L);
11+
begin
12+
Real (I, J, K);
13+
end Obs;
14+
15+
----------
16+
-- Real --
17+
----------
18+
19+
procedure Real (I, J, K : Integer) is
20+
begin
21+
if I = J and then K = I + J then
22+
Ada.Text_IO.Put_Line ("Hello World");
23+
end if;
24+
end Real;
25+
26+
end Pack;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package Pack is
2+
3+
procedure Obs (I, J, K, L : Integer);
4+
pragma Obsolescent (Obs, "Use Real");
5+
6+
procedure Real (I, J, K : Integer);
7+
8+
end Pack;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Verify that when multiple messages are located in the same location,
3+
the highest message will be a primary.
4+
"""
5+
import GPS
6+
from gs_utils.internal.utils import *
7+
8+
EXPECTED = ['Builder results (2 items in 1 file)',
9+
['foo.adb (2 items)',
10+
['<b>5:8</b> warning: call to obsolescent procedure' +
11+
' &quot;Obs&quot; declared at pack.ads:3 [enabled by default]',
12+
[' warning: call to obsolescent procedure' +
13+
' &quot;Obs&quot; declared at <span color="#729FCF">' +
14+
'<u>pack.ads:3</u></span> [enabled by default]',
15+
' warning: Use Real [enabled by default]'],
16+
'<b>5:8</b> error: missing argument for parameter' +
17+
' &quot;L&quot; in call to &quot;Obs&quot;' +
18+
' declared at pack.ads:3',
19+
[' error: missing argument for parameter &quot;' +
20+
'L&quot; in call to &quot;Obs&quot; declared at' +
21+
' <span color="#729FCF"><u>pack.ads:3</u></span>']]]]
22+
23+
24+
@run_test_driver
25+
def driver():
26+
GPS.BuildTarget("Build All").execute(force=True)
27+
yield wait_tasks()
28+
29+
gps_assert(dump_locations_tree(),
30+
EXPECTED,
31+
"Missing error for first renaming")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'gs.266.message_secondary_with_higher_importance'

0 commit comments

Comments
 (0)