Skip to content

Commit

Permalink
Merge branch 'topic/gs.266.message_secondary_with_higher_importance' …
Browse files Browse the repository at this point in the history
…into 'master'

Avoid creating a secondary message of higher importance

See merge request eng/ide/gnatstudio!486
  • Loading branch information
AdrienBoulanger committed May 6, 2024
2 parents 0c3586a + 26d15d7 commit 33344aa
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kernel/src/gps-kernel-messages-tools_output.adb
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ package body GPS.Kernel.Messages.Tools_Output is
GPS.Kernel.Messages.Legacy.Get_Message_At
(Container, Category, File, Line, Column);

if Primary /= null and then Primary.Get_Importance < Importance then
-- The previous message in the same line is of lower Importance:
-- Create a new Primary message for higher visibility.
Primary := null;
end if;

if Primary = null then
Primary :=
Message_Access
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project Obsolescent is

for Source_Dirs use ("src");

package Builder is
for Default_Switches ("Ada") use ("-gnatwj", "-f");
end Builder;
end Obsolescent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
with Pack;

procedure Foo is
begin
Pack.Obs (1, 2, 3);
end Foo;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
with Ada.Text_IO;

package body Pack is

---------
-- Obs --
---------

procedure Obs (I, J, K, L : Integer) is
pragma Unreferenced (L);
begin
Real (I, J, K);
end Obs;

----------
-- Real --
----------

procedure Real (I, J, K : Integer) is
begin
if I = J and then K = I + J then
Ada.Text_IO.Put_Line ("Hello World");
end if;
end Real;

end Pack;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package Pack is

procedure Obs (I, J, K, L : Integer);
pragma Obsolescent (Obs, "Use Real");

procedure Real (I, J, K : Integer);

end Pack;
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
Verify that when multiple messages are located in the same location,
the highest message will be a primary.
"""
import GPS
from gs_utils.internal.utils import *

EXPECTED = ['Builder results (2 items in 1 file)',
['foo.adb (2 items)',
['<b>5:8</b> warning: call to obsolescent procedure' +
' &quot;Obs&quot; declared at pack.ads:3 [enabled by default]',
[' warning: call to obsolescent procedure' +
' &quot;Obs&quot; declared at <span color="#729FCF">' +
'<u>pack.ads:3</u></span> [enabled by default]',
' warning: Use Real [enabled by default]'],
'<b>5:8</b> error: missing argument for parameter' +
' &quot;L&quot; in call to &quot;Obs&quot;' +
' declared at pack.ads:3',
[' error: missing argument for parameter &quot;' +
'L&quot; in call to &quot;Obs&quot; declared at' +
' <span color="#729FCF"><u>pack.ads:3</u></span>']]]]


@run_test_driver
def driver():
GPS.BuildTarget("Build All").execute(force=True)
yield wait_tasks()

gps_assert(dump_locations_tree(),
EXPECTED,
"Missing error for first renaming")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
title: 'gs.266.message_secondary_with_higher_importance'

0 comments on commit 33344aa

Please sign in to comment.