Skip to content

Commit e33192f

Browse files
committed
Merge branch 'topic/gnatcheck/format_sources' into 'master'
Format GNATcheck sources following changes in GNATformat See merge request eng/libadalang/langkit-query-language!424
2 parents 6973073 + f551919 commit e33192f

10 files changed

+116
-72
lines changed

lkql_checker/src/gnatcheck-compiler.adb

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,15 +157,17 @@ package body Gnatcheck.Compiler is
157157
(declare
158158
Idx : constant Natural := Index (Diag, "warning: ");
159159
begin
160-
(if Idx = 0 then Diag
160+
(if Idx = 0
161+
then Diag
161162
else
162163
Diag (Diag'First .. Idx - 1)
163164
& Diag (Idx + 9 .. Diag'Last))),
164165
when Style =>
165166
(declare
166167
Idx : constant Natural := Index (Diag, "(style) ");
167168
begin
168-
(if Idx = 0 then Diag
169+
(if Idx = 0
170+
then Diag
169171
else
170172
Diag (Diag'First .. Idx - 1)
171173
& Diag (Idx + 8 .. Diag'Last))),
@@ -349,11 +351,14 @@ package body Gnatcheck.Compiler is
349351
Index (Source => Msg (Last + 1 .. Msg_End), Pattern => "|");
350352

351353
Rule_Name : constant String :=
352-
(if Name_Split /= 0 then Msg (Name_Split + 1 .. Msg_End - 1)
353-
elsif Last /= 0 then Msg (Last + 1 .. Msg_End - 1)
354+
(if Name_Split /= 0
355+
then Msg (Name_Split + 1 .. Msg_End - 1)
356+
elsif Last /= 0
357+
then Msg (Last + 1 .. Msg_End - 1)
354358
else "");
355359
Instance_Name : constant String :=
356-
(if Name_Split /= 0 then Msg (Last + 1 .. Name_Split - 1)
360+
(if Name_Split /= 0
361+
then Msg (Last + 1 .. Name_Split - 1)
357362
else "");
358363

359364
Instance : Rule_Instance_Access := null;
@@ -364,7 +369,8 @@ package body Gnatcheck.Compiler is
364369
end if;
365370
Instance :=
366371
Get_Instance
367-
(if Instance_Name = "" then To_Lower (Rule_Name)
372+
(if Instance_Name = ""
373+
then To_Lower (Rule_Name)
368374
else To_Lower (Instance_Name));
369375
Store_Diagnosis
370376
(Full_File_Name => Gnatcheck.Source_Table.File_Name (SF),
@@ -378,7 +384,7 @@ package body Gnatcheck.Compiler is
378384
return;
379385
end;
380386

381-
-- An error message has been emitted
387+
-- An error message has been emitted
382388
elsif Msg (Msg_Start .. Msg_Start + 6) = "error: " then
383389
Message_Kind := Error;
384390

@@ -392,7 +398,7 @@ package body Gnatcheck.Compiler is
392398

393399
Errors := True;
394400

395-
-- A warning has been emitted by gprbuild
401+
-- A warning has been emitted by gprbuild
396402
elsif Msg (Msg_Start .. Msg_Start + 8) = "warning: " then
397403
if Index (Msg (Msg_Start .. Msg_End), ": violation of restriction")
398404
/= 0
@@ -410,11 +416,11 @@ package body Gnatcheck.Compiler is
410416
Message_Kind := Warning;
411417
end if;
412418

413-
-- A style check violation has been emitted
419+
-- A style check violation has been emitted
414420
elsif Msg (Msg_Start .. Msg_Start + 6) = "(style)" then
415421
Message_Kind := Style;
416422

417-
-- Ignore anything else
423+
-- Ignore anything else
418424
else
419425
return;
420426
end if;
@@ -436,7 +442,8 @@ package body Gnatcheck.Compiler is
436442
Diagnosis_Kind => Kind,
437443
SF => SF,
438444
Rule =>
439-
(if Message_Kind = Error then No_Rule_Id
445+
(if Message_Kind = Error
446+
then No_Rule_Id
440447
else Get_Rule_Id (Message_Kind)));
441448
end Analyze_Line;
442449

@@ -1323,7 +1330,7 @@ package body Gnatcheck.Compiler is
13231330
Style_To_Instance.Include ([C], Name);
13241331
end loop;
13251332

1326-
-- Else, process the argument as a sequence of "gnaty" parameters.
1333+
-- Else, process the argument as a sequence of "gnaty" parameters.
13271334

13281335
else
13291336
I := Param'First;
@@ -1936,7 +1943,8 @@ package body Gnatcheck.Compiler is
19361943
else
19371944
First_Idx := First_Idx + String_To_Search'Length;
19381945
Last_Idx :=
1939-
(if Diag (First_Idx) in '.' | '_' then First_Idx + 1
1946+
(if Diag (First_Idx) in '.' | '_'
1947+
then First_Idx + 1
19401948
else First_Idx);
19411949
end if;
19421950

lkql_checker/src/gnatcheck-diagnoses.adb

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,15 @@ package body Gnatcheck.Diagnoses is
541541

542542
function Auxiliary_List_File_Name (S : String) return String is
543543
Prj_Out_File : constant String :=
544-
(if Text_Report_ON then Base_Name (Get_Report_File_Name)
544+
(if Text_Report_ON
545+
then Base_Name (Get_Report_File_Name)
545546
else Base_Name (Get_XML_Report_File_Name));
546547
Prj_Out_First : constant Natural := Prj_Out_File'First;
547548
Prj_Out_Last : constant Natural := Prj_Out_File'Last;
548549
Prj_Out_Dot : Natural := Index (Prj_Out_File, ".", Backward);
549550
Prj_Out_Suffix : constant String :=
550-
(if Prj_Out_Dot = 0 then ""
551+
(if Prj_Out_Dot = 0
552+
then ""
551553
else Prj_Out_File (Prj_Out_Dot .. Prj_Out_Last));
552554

553555
Suff_Start : Natural;
@@ -839,7 +841,8 @@ package body Gnatcheck.Diagnoses is
839841
if Gnatcheck_Prj.Is_Specified then
840842
XML_Report
841843
(" project="""
842-
& (if Arg.Aggregated_Project then Get_Aggregated_Project
844+
& (if Arg.Aggregated_Project
845+
then Get_Aggregated_Project
843846
else Gnatcheck_Prj.Source_Prj)
844847
& """>");
845848
else
@@ -1261,7 +1264,8 @@ package body Gnatcheck.Diagnoses is
12611264

12621265
Append
12631266
(Res,
1264-
(if Rule in Warnings_Id | Style_Checks_Id then El
1267+
(if Rule in Warnings_Id | Style_Checks_Id
1268+
then El
12651269
else GNAT.Case_Util.To_Mixed (El)));
12661270

12671271
Count := Count + 1;
@@ -2060,7 +2064,8 @@ package body Gnatcheck.Diagnoses is
20602064
declare
20612065
Sep_Idx : constant Natural := Index (Param, "=");
20622066
Restriction_Name : constant String :=
2063-
(if Sep_Idx = 0 then Param
2067+
(if Sep_Idx = 0
2068+
then Param
20642069
else Param (Param'First .. Sep_Idx - 1));
20652070
begin
20662071
if Is_Restriction_Active (Restriction_Name) then
@@ -2137,7 +2142,7 @@ package body Gnatcheck.Diagnoses is
21372142
Exempted_Name => To_Unbounded_String (Exempted_Name),
21382143
Detected => 0));
21392144

2140-
-- Else, some actuals parameters has been provided
2145+
-- Else, some actuals parameters has been provided
21412146

21422147
else
21432148
-- Check that the object is not exempted with the same params
@@ -2301,7 +2306,8 @@ package body Gnatcheck.Diagnoses is
23012306
.To_String;
23022307

23032308
Just : constant String :=
2304-
(if Matches (4) = No_Match then ""
2309+
(if Matches (4) = No_Match
2310+
then ""
23052311
else
23062312
To_XString (Text (Matches (4).First .. Matches (4).Last))
23072313
.Trim
@@ -2342,8 +2348,10 @@ package body Gnatcheck.Diagnoses is
23422348
end;
23432349
else
23442350
Process_Exempt_Action
2345-
(((if State = "on" then Exempt_Off
2346-
elsif State = "off" then Exempt_On
2351+
(((if State = "on"
2352+
then Exempt_Off
2353+
elsif State = "off"
2354+
then Exempt_On
23472355
else raise Constraint_Error with "should not happen"),
23482356
To_Unbounded_String (Rule),
23492357
Params => <>,
@@ -2503,7 +2511,8 @@ package body Gnatcheck.Diagnoses is
25032511
Diag_Column : constant Positive := Positive (Diag.Sloc.Column);
25042512
SF : constant SF_Id := Diag.SF;
25052513
R_Name : constant String :=
2506-
(if Diag.Diagnosis_Kind = Rule_Violation then Rule_Name (Diag.Rule)
2514+
(if Diag.Diagnosis_Kind = Rule_Violation
2515+
then Rule_Name (Diag.Rule)
25072516
else "");
25082517
I_Name : constant String :=
25092518
(if Diag.Instance /= null and then Diag.Instance.Is_Alias
@@ -2882,7 +2891,8 @@ package body Gnatcheck.Diagnoses is
28822891
use Ada.Directories;
28832892
File_Name : constant Unbounded_String :=
28842893
To_Unbounded_String
2885-
(if Arg.Full_Source_Locations.Get then Full_File_Name
2894+
(if Arg.Full_Source_Locations.Get
2895+
then Full_File_Name
28862896
else Simple_Name (Full_File_Name));
28872897
Tmp : Diag_Message :=
28882898
(Text => To_Unbounded_String (Message),
@@ -2992,10 +3002,14 @@ package body Gnatcheck.Diagnoses is
29923002
M_Start : Natural := Message'First;
29933003
begin
29943004
XML_Report_No_EOL
2995-
((if Diag.Diagnosis_Kind = Exemption_Warning then "<exemption-problem"
2996-
elsif Diag.Diagnosis_Kind = Compiler_Error then "<compiler-error"
2997-
elsif Diag.Diagnosis_Kind = Internal_Error then "<internal-error"
2998-
elsif Exempted then "<exempted-violation"
3005+
((if Diag.Diagnosis_Kind = Exemption_Warning
3006+
then "<exemption-problem"
3007+
elsif Diag.Diagnosis_Kind = Compiler_Error
3008+
then "<compiler-error"
3009+
elsif Diag.Diagnosis_Kind = Internal_Error
3010+
then "<internal-error"
3011+
elsif Exempted
3012+
then "<exempted-violation"
29993013
else "<violation"),
30003014
Indent_Level => Indentation);
30013015

@@ -3047,9 +3061,12 @@ package body Gnatcheck.Diagnoses is
30473061
XML_Report
30483062
((if Diag.Diagnosis_Kind = Exemption_Warning
30493063
then "</exemption-problem>"
3050-
elsif Diag.Diagnosis_Kind = Compiler_Error then "</compiler-error>"
3051-
elsif Diag.Diagnosis_Kind = Internal_Error then "</internal-error>"
3052-
elsif Exempted then "</exempted-violation>"
3064+
elsif Diag.Diagnosis_Kind = Compiler_Error
3065+
then "</compiler-error>"
3066+
elsif Diag.Diagnosis_Kind = Internal_Error
3067+
then "</internal-error>"
3068+
elsif Exempted
3069+
then "</exempted-violation>"
30533070
else "</violation>"),
30543071
Indent_Level => Indentation);
30553072
end XML_Report_Diagnosis;

lkql_checker/src/gnatcheck-output.adb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ package body Gnatcheck.Output is
159159

160160
function Get_Number return String is
161161
Report_File_Name : constant String :=
162-
(if Text_Report_ON then Get_Report_File_Name
162+
(if Text_Report_ON
163+
then Get_Report_File_Name
163164
else Get_XML_Report_File_Name);
164165

165166
Idx_1, Idx_2 : Natural;
@@ -446,13 +447,14 @@ package body Gnatcheck.Output is
446447
new String'
447448
(Normalize_Pathname
448449
(Global_Report_Dir.all
449-
& (if Report_File_Name = null then Executable & ".out"
450+
& (if Report_File_Name = null
451+
then Executable & ".out"
450452
else Report_File_Name.all)));
451453
end if;
452454

453-
-- And in case of Aggregated_Project we already have in
454-
-- Report_File_Name the needed name with full path in absolute
455-
-- form
455+
-- And in case of Aggregated_Project we already have in
456+
-- Report_File_Name the needed name with full path in absolute
457+
-- form
456458

457459
end if;
458460

@@ -492,13 +494,14 @@ package body Gnatcheck.Output is
492494
new String'
493495
(Normalize_Pathname
494496
(Global_Report_Dir.all
495-
& (if XML_Report_File_Name = null then Executable & ".xml"
497+
& (if XML_Report_File_Name = null
498+
then Executable & ".xml"
496499
else XML_Report_File_Name.all)));
497500
end if;
498501

499-
-- And in case of Aggregated_Project we already have in
500-
-- Report_File_Name the needed name with full path in absolute
501-
-- form
502+
-- And in case of Aggregated_Project we already have in
503+
-- Report_File_Name the needed name with full path in absolute
504+
-- form
502505

503506
end if;
504507

lkql_checker/src/gnatcheck-projects-aggregate.adb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,17 @@ package body Gnatcheck.Projects.Aggregate is
172172
Prj_Out_Last : constant Natural := Prj_Out_File'Last;
173173
Prj_Out_Dot : Natural := Index (Prj_Out_File, ".", Backward);
174174
Prj_Out_Suffix : constant String :=
175-
(if Prj_Out_Dot = 0 then ""
175+
(if Prj_Out_Dot = 0
176+
then ""
176177
else Prj_Out_File (Prj_Out_Dot .. Prj_Out_Last));
177178

178179
Prj_XML_File : constant String := XML_Report_File_Name;
179180
Prj_XML_First : constant Natural := Prj_XML_File'First;
180181
Prj_XML_Last : constant Natural := Prj_XML_File'Last;
181182
Prj_XML_Dot : Natural := Index (Prj_XML_File, ".", Backward);
182183
Prj_XML_Suffix : constant String :=
183-
(if Prj_XML_Dot = 0 then ""
184+
(if Prj_XML_Dot = 0
185+
then ""
184186
else Prj_XML_File (Prj_XML_Dot .. Prj_XML_Last));
185187

186188
Prj_Args : Argument_List (1 .. 2);
@@ -290,7 +292,8 @@ package body Gnatcheck.Projects.Aggregate is
290292
Expected_XML_Out_File =>
291293
(if XML_Report_ON
292294
then
293-
(if Out_Args_Count = 2 then Out_Args (2).all
295+
(if Out_Args_Count = 2
296+
then Out_Args (2).all
294297
else Out_Args (4).all)
295298
else ""));
296299

lkql_checker/src/gnatcheck-projects.adb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ package body Gnatcheck.Projects is
213213
return GNAT.OS_Lib.Argument_List_Access
214214
is
215215
Attr : constant GPR2.Project.Attribute.Object :=
216-
(if Indexed then Proj.Attribute (Attr_Id, Ada_Idx)
216+
(if Indexed
217+
then Proj.Attribute (Attr_Id, Ada_Idx)
217218
else Proj.Attribute (Attr_Id));
218219
Res : GNAT.OS_Lib.Argument_List_Access;
219220
begin
@@ -929,7 +930,8 @@ package body Gnatcheck.Projects is
929930
(My_Project : in out Arg_Project_Type; Project_File_Name : String)
930931
is
931932
Ext : constant String :=
932-
(if Has_Suffix (Project_File_Name, Suffix => ".gpr") then ""
933+
(if Has_Suffix (Project_File_Name, Suffix => ".gpr")
934+
then ""
933935
else ".gpr");
934936

935937
begin
@@ -1102,7 +1104,8 @@ package body Gnatcheck.Projects is
11021104
use Ada.Strings.Unbounded;
11031105

11041106
Resolved_File : constant String :=
1105-
(if Is_Absolute_Path (File) then File
1107+
(if Is_Absolute_Path (File)
1108+
then File
11061109
else
11071110
(if Project_Relative
11081111
then Gnatcheck_Prj.Get_Project_Relative_File (File)

0 commit comments

Comments
 (0)