Skip to content

Commit a2ef2fb

Browse files
committed
Merge branch 'peron/bump-gnatformat' into 'master'
Bump gnatformat See merge request eng/ide/libadalang-tools!325
2 parents dfae3ce + 7c2ed93 commit a2ef2fb

37 files changed

+509
-394
lines changed

src/laltools-common.adb

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,12 @@ package body Laltools.Common is
7878
Case_Sensitive : Boolean := False) return Boolean
7979
is
8080
T : constant Text_Type :=
81-
(if Case_Sensitive then Text (Token)
81+
(if Case_Sensitive
82+
then Text (Token)
8283
else Ada.Wide_Wide_Characters.Handling.To_Lower (Text (Token)));
8384
Actual_Pattern : constant Wide_Wide_String :=
84-
(if Case_Sensitive then Pattern
85+
(if Case_Sensitive
86+
then Pattern
8587
else Ada.Wide_Wide_Characters.Handling.To_Lower (Pattern));
8688
Idx : constant Integer :=
8789
Ada.Strings.Wide_Wide_Fixed.Index (T, Actual_Pattern);
@@ -190,7 +192,8 @@ package body Laltools.Common is
190192
use Ada.Strings.Wide_Wide_Fixed;
191193

192194
Max_Line : constant Natural :=
193-
(if Unit.Root.Is_Null then 0
195+
(if Unit.Root.Is_Null
196+
then 0
194197
else Natural (Unit.Root.Sloc_Range.End_Line) + 1);
195198

196199
First_Line : constant Text_Type :=
@@ -207,7 +210,8 @@ package body Laltools.Common is
207210
- 1
208211
.. Last_Line'Last);
209212
First_Rest_Of_Last_Line_Non_Blank : constant Natural :=
210-
(if Rest_Of_Last_Line'Length = 0 then 0
213+
(if Rest_Of_Last_Line'Length = 0
214+
then 0
211215
else
212216
Index_Non_Blank (Rest_Of_Last_Line)
213217
+ 1
@@ -261,7 +265,8 @@ package body Laltools.Common is
261265
Next_Line : constant Text_Type :=
262266
Unit.Get_Line (Next_Line_Number);
263267
Next_Line_First_Non_Blank : constant Natural :=
264-
(if Next_Line'Length /= 0 then Index_Non_Blank (Next_Line)
268+
(if Next_Line'Length /= 0
269+
then Index_Non_Blank (Next_Line)
265270
else 0);
266271
begin
267272
exit when
@@ -402,7 +407,8 @@ package body Laltools.Common is
402407
and then Semantic_Parent.Kind in Ada_Basic_Decl
403408
and then Is_Subprogram (Semantic_Parent.As_Basic_Decl);
404409
Semantic_Parent_Subp : constant Basic_Decl :=
405-
(if Is_Semantic_Parent_Subp then Semantic_Parent.As_Basic_Decl
410+
(if Is_Semantic_Parent_Subp
411+
then Semantic_Parent.As_Basic_Decl
406412
else No_Basic_Decl);
407413

408414
Hierarchy : constant Basic_Decl_Array :=
@@ -1443,7 +1449,8 @@ package body Laltools.Common is
14431449
return Compilation_Unit_Vector
14441450
is
14451451
Root : constant Ada_Node :=
1446-
(if Analysis_Unit = No_Analysis_Unit then No_Ada_Node
1452+
(if Analysis_Unit = No_Analysis_Unit
1453+
then No_Ada_Node
14471454
else Analysis_Unit.Root);
14481455
begin
14491456
return Compilation_Units : Compilation_Unit_Vector do
@@ -2163,7 +2170,8 @@ package body Laltools.Common is
21632170
-------------------
21642171

21652172
function Get_Subp_Spec (Subp : Basic_Decl'Class) return Base_Subp_Spec
2166-
is (if Subp.Is_Null then No_Base_Subp_Spec
2173+
is (if Subp.Is_Null
2174+
then No_Base_Subp_Spec
21672175
else Subp.P_Subp_Spec_Or_Null (True));
21682176

21692177
--------------------------
@@ -2439,7 +2447,8 @@ package body Laltools.Common is
24392447
declare
24402448
Sibling : constant Ada_Node := Node.Next_Sibling;
24412449
Text : constant Wide_Wide_String :=
2442-
(if Sibling.Is_Null then ""
2450+
(if Sibling.Is_Null
2451+
then ""
24432452
else Ada.Wide_Wide_Characters.Handling.To_Lower (Sibling.Text));
24442453
begin
24452454
return
@@ -2576,7 +2585,7 @@ package body Laltools.Common is
25762585
| Ada_Null_Subp_Decl
25772586
-- This is an "is null" procedure
25782587
| Ada_Expr_Function;
2579-
-- This is an expression function
2588+
-- This is an expression function
25802589
end Is_Definition_Without_Separate_Implementation;
25812590

25822591
---------------------
@@ -2831,7 +2840,7 @@ package body Laltools.Common is
28312840
Ref_Kind := Precise;
28322841
if Name_Node.Is_Null then
28332842
return No_Defining_Name;
2834-
-- P_Failsafe_Referenced_Def_Name doesn't work on the decl itself
2843+
-- P_Failsafe_Referenced_Def_Name doesn't work on the decl itself
28352844
elsif Name_Node.P_Is_Defining then
28362845
Result := Name_Node.P_Enclosing_Defining_Name.P_Canonical_Part;
28372846
else

src/metrics-actions.adb

Lines changed: 64 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ package body METRICS.Actions is
368368

369369
function File_Name_To_Print
370370
(Cmd : Command_Line; File_Name : String) return String
371-
is (if Arg (Cmd, Short_File_Names) then Directories.Simple_Name (File_Name)
371+
is (if Arg (Cmd, Short_File_Names)
372+
then Directories.Simple_Name (File_Name)
372373
else Normalize_Pathname (File_Name));
373374

374375
function Lines_String
@@ -563,9 +564,9 @@ package body METRICS.Actions is
563564
if S = null then
564565
S := M;
565566
M.Is_Spec := True;
566-
-- ???Is_Spec could be wrong here. We need semantic
567-
-- information to know if this body is acting as a spec.
568-
-- It will be fixed up below if the spec comes along later.
567+
-- ???Is_Spec could be wrong here. We need semantic
568+
-- information to know if this body is acting as a spec.
569+
-- It will be fixed up below if the spec comes along later.
569570

570571
else
571572
B := M;
@@ -595,7 +596,8 @@ package body METRICS.Actions is
595596
Result.Node := Node;
596597
Result.Knd := Get_Fine_Kind (Node);
597598
Result.Sloc :=
598-
(if Node.Is_Null then Slocs.No_Source_Location_Range
599+
(if Node.Is_Null
600+
then Slocs.No_Source_Location_Range
599601
else Sloc_Range (Node));
600602
Result.Is_Private_Lib_Unit := Is_Private (Node);
601603
Result.Has_Complexity_Metrics :=
@@ -650,7 +652,8 @@ package body METRICS.Actions is
650652
Result.LI_Sub :=
651653
(if Length (Tool.Metrix_Stack) = 3
652654
then
653-
(if Unit_Is_Subunit (Node) then Subunit_Sym
655+
(if Unit_Is_Subunit (Node)
656+
then Subunit_Sym
654657
else Library_Item_Sym)
655658
else Name_Empty);
656659
end if;
@@ -846,7 +849,8 @@ package body METRICS.Actions is
846849
R : constant Type_Expr := F_Subp_Returns (Get_Subp_Spec (Node));
847850
begin
848851
return
849-
(if R.Is_Null then Procedure_Body_Stub_Knd
852+
(if R.Is_Null
853+
then Procedure_Body_Stub_Knd
850854
else Function_Body_Stub_Knd);
851855
end;
852856

@@ -879,7 +883,8 @@ package body METRICS.Actions is
879883
-- ???R is null here even for functions
880884
begin
881885
return
882-
(if R.Is_Null then Generic_Procedure_Knd
886+
(if R.Is_Null
887+
then Generic_Procedure_Knd
883888
else Generic_Function_Knd);
884889
end;
885890

@@ -1243,7 +1248,8 @@ package body METRICS.Actions is
12431248
then Num - 1
12441249
else 0);
12451250
Numerator_Metric : constant Metrics_Enum :=
1246-
(if Metric = Lines_Average then Lines_Code_In_Bodies
1251+
(if Metric = Lines_Average
1252+
then Lines_Code_In_Bodies
12471253
else Metric);
12481254
-- Metric whose value is used as the numerator when computing the
12491255
-- average. For complexity metrics, that is the Metric itself, but
@@ -1330,18 +1336,23 @@ package body METRICS.Actions is
13301336
then XML_Metric_Name_String (I)
13311337
else Metric_Name_String (I));
13321338
Indentation_Amount : constant Natural :=
1333-
(if I = Lines_Average then 0
1334-
elsif Depth = 1 then 2
1335-
elsif Depth = 2 and then First in Lines_Metrics then 2
1339+
(if I = Lines_Average
1340+
then 0
1341+
elsif Depth = 1
1342+
then 2
1343+
elsif Depth = 2 and then First in Lines_Metrics
1344+
then 2
13361345
elsif Name = Average_Complexity_Metrics
13371346
then 2 * Default_Indentation_Amount
13381347
else Default_Indentation_Amount);
13391348
-- Indentation_Amount, and Tab below, are
13401349
-- intended to mimic some partially arbitrary
13411350
-- behavior of gnatmetric.
13421351
Tab : constant Positive :=
1343-
(if Depth = 1 and then I in Lines_Metrics then 22
1344-
elsif Depth = 1 or else I in Lines_Metrics then 21
1352+
(if Depth = 1 and then I in Lines_Metrics
1353+
then 22
1354+
elsif Depth = 1 or else I in Lines_Metrics
1355+
then 21
13451356
else 26);
13461357
begin
13471358
Indent (Indentation_Amount);
@@ -1779,7 +1790,8 @@ package body METRICS.Actions is
17791790
("<metric name=\1>\2</metric>\n",
17801791
Q (XML_Metric_Name_String (I)),
17811792
Val_To_Print
1782-
((if I = Complexity_Average then Complexity_Cyclomatic
1793+
((if I = Complexity_Average
1794+
then Complexity_Cyclomatic
17831795
else I),
17841796
M,
17851797
XML => True));
@@ -1815,7 +1827,8 @@ package body METRICS.Actions is
18151827

18161828
To_Print_First : constant Metrics_Set :=
18171829
Metrics_To_Compute
1818-
and (if M.Kind = Ada_Compilation_Unit then not Complexity_Only
1830+
and (if M.Kind = Ada_Compilation_Unit
1831+
then not Complexity_Only
18191832
else All_Metrics_Set);
18201833
-- Set of metrics to print first, before printing subtrees. Same as
18211834
-- Metrics_To_Compute, except at the top level, we leave out complexity
@@ -1853,7 +1866,8 @@ package body METRICS.Actions is
18531866
Put
18541867
("<unit name=\1\2 line=\3 col=\4>\n",
18551868
XML (Str (M.XML_Name).S),
1856-
(if Doing_Coupling_Metrics then ""
1869+
(if Doing_Coupling_Metrics
1870+
then ""
18571871
else " kind=" & Q (Fine_Kind_String (M.Knd))),
18581872
Q (Image (Integer (M.Sloc.Start_Line))),
18591873
Q (Image (Integer (M.Sloc.Start_Column))));
@@ -1903,15 +1917,17 @@ package body METRICS.Actions is
19031917
Object_Dir : String)
19041918
is
19051919
Suffix : constant String :=
1906-
(if Arg (Cmd, Output_Suffix) = null then ".metrix"
1920+
(if Arg (Cmd, Output_Suffix) = null
1921+
then ".metrix"
19071922
else Arg (Cmd, Output_Suffix).all);
19081923
use Ada.Text_IO;
19091924
Text : File_Type;
19101925
File_Name : String renames File_M.Source_File_Name.all;
19111926
Text_File_Name : constant String :=
19121927
(if Arg (Cmd, Output_Directory) = null
19131928
then
1914-
(if Object_Dir = "" then File_Name & Suffix
1929+
(if Object_Dir = ""
1930+
then File_Name & Suffix
19151931
else
19161932
Directories.Compose
19171933
(Object_Dir, Directories.Simple_Name (File_Name) & Suffix))
@@ -2307,9 +2323,9 @@ package body METRICS.Actions is
23072323
end if;
23082324

23092325
return (if Parent_Body = null then M else Get_Spec (Parent_Body));
2310-
-- This recursion will climb up a chain of nested subunits until
2311-
-- it reaches a library unit, and then we'll get the spec of that
2312-
-- library unit.
2326+
-- This recursion will climb up a chain of nested subunits until
2327+
-- it reaches a library unit, and then we'll get the spec of that
2328+
-- library unit.
23132329
end;
23142330
end if;
23152331
end Get_Spec;
@@ -2599,7 +2615,8 @@ package body METRICS.Actions is
25992615
Object_Dir : constant String := Get_Object_Dir;
26002616

26012617
Xml_F_Name : constant String :=
2602-
(if Arg (Cmd, Xml_File_Name) = null then "metrix.xml"
2618+
(if Arg (Cmd, Xml_File_Name) = null
2619+
then "metrix.xml"
26032620
else Arg (Cmd, Xml_File_Name).all);
26042621
-- ASIS-based gnatmetric ignores Output_Dir for the xml.
26052622

@@ -2608,7 +2625,8 @@ package body METRICS.Actions is
26082625
-- True if Xml_F_Name contains directory information
26092626

26102627
Xml_FD_Name : constant String :=
2611-
(if Object_Dir = "" or else Has_Dir then Xml_F_Name
2628+
(if Object_Dir = "" or else Has_Dir
2629+
then Xml_F_Name
26122630
else Directories.Compose (Object_Dir, Xml_F_Name));
26132631

26142632
XML_File : Text_IO.File_Type;
@@ -3203,7 +3221,7 @@ package body METRICS.Actions is
32033221
-- end if;
32043222
--
32053223
Inc_Cyc (Complexity_Statement);
3206-
-- <<Ignore_Static_Loop>>
3224+
-- <<Ignore_Static_Loop>>
32073225

32083226
end if;
32093227

@@ -3223,7 +3241,8 @@ package body METRICS.Actions is
32233241
Num_Alts : constant Metric_Nat :=
32243242
Children_Count (F_Guards (S));
32253243
Num_Else : constant Metric_Nat :=
3226-
(if Children_Count (F_Stmts (F_Else_Part (S))) = 0 then 0
3244+
(if Children_Count (F_Stmts (F_Else_Part (S))) = 0
3245+
then 0
32273246
else 1);
32283247
Num_Abort : constant Metric_Nat :=
32293248
(if Children_Count (F_Stmts (F_Then_Abort_Part (S))) = 0
@@ -3323,8 +3342,8 @@ package body METRICS.Actions is
33233342
| Ada_Select_Stmt
33243343
then
33253344
Push (EC_Stack, EC_Rec'(Node, Counted => False));
3326-
-- (The corresponding Pop is at the end of
3327-
-- Gather_Metrics_And_Walk_Children.)
3345+
-- (The corresponding Pop is at the end of
3346+
-- Gather_Metrics_And_Walk_Children.)
33283347

33293348
end if;
33303349

@@ -3523,9 +3542,9 @@ package body METRICS.Actions is
35233542

35243543
Lines_Count := Metric_Nat (Stop - Start + 1);
35253544

3526-
-- If this is a compilation unit but not the only one in the
3527-
-- analysis unit, then Line_Count must be computed
3528-
-- accordingly.
3545+
-- If this is a compilation unit but not the only one in the
3546+
-- analysis unit, then Line_Count must be computed
3547+
-- accordingly.
35293548

35303549
elsif M.Node.Kind = Ada_Compilation_Unit
35313550
and then not M.Node.Parent.Is_Null
@@ -3552,10 +3571,10 @@ package body METRICS.Actions is
35523571

35533572
Lines_Count := Metric_Nat (Stop - Start + 1);
35543573

3555-
-- If this is the last compilation unit of the
3556-
-- analysis unit then, we want to include all the
3557-
-- comments and blank lines following the compilation
3558-
-- unit until the end of the analysis unit.
3574+
-- If this is the last compilation unit of the
3575+
-- analysis unit then, we want to include all the
3576+
-- comments and blank lines following the compilation
3577+
-- unit until the end of the analysis unit.
35593578

35603579
elsif M.Node = Comp_Units (Comp_Units'Last) then
35613580
Start := M.Node.Sloc_Range.Start_Line;
@@ -3564,10 +3583,10 @@ package body METRICS.Actions is
35643583

35653584
Lines_Count := Metric_Nat (Stop - Start + 1);
35663585

3567-
-- If this compilation unit is in the middle of the
3568-
-- compilation unit list of this analysis unit, then
3569-
-- we want to include all the comments and blank lines
3570-
-- following the compilation unit until the next one.
3586+
-- If this compilation unit is in the middle of the
3587+
-- compilation unit list of this analysis unit, then
3588+
-- we want to include all the comments and blank lines
3589+
-- following the compilation unit until the next one.
35713590

35723591
else
35733592
for Idx in Comp_Units'First .. Comp_Units'Length loop
@@ -3997,8 +4016,8 @@ package body METRICS.Actions is
39974016
end;
39984017
end;
39994018

4000-
-- For a subprogram instantiation, we have to find the generic
4001-
-- subprogram, and call Count_Params on that spec.
4019+
-- For a subprogram instantiation, we have to find the generic
4020+
-- subprogram, and call Count_Params on that spec.
40024021

40034022
elsif Kind (Node) = Ada_Generic_Subp_Instantiation then
40044023
begin
@@ -4240,8 +4259,8 @@ package body METRICS.Actions is
42404259
begin
42414260
Set_Flags (Ada_Node (Node));
42424261
return Into;
4243-
-- ???This could be more efficient if we return Over in cases
4244-
-- where we know there are no interesting subnodes.
4262+
-- ???This could be more efficient if we return Over in cases
4263+
-- where we know there are no interesting subnodes.
42454264
end Visit;
42464265

42474266
procedure Set_Flags (Node : Ada_Node) is
@@ -4253,8 +4272,8 @@ package body METRICS.Actions is
42534272
(P_Designated_Generic_Decl
42544273
(Node.As_Generic_Instantiation),
42554274
Visit'Access);
4256-
-- Set one or both flags according to whether the generic
4257-
-- package contains tagged types or subprograms.
4275+
-- Set one or both flags according to whether the generic
4276+
-- package contains tagged types or subprograms.
42584277
exception
42594278
when Property_Error =>
42604279
null;

0 commit comments

Comments
 (0)