Skip to content

Commit f3e2a07

Browse files
committed
Fix the 'one_construct_per_line' rule to not flag generic formal packages
1 parent 2e6931b commit f3e2a07

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

lkql_checker/share/lkql/one_construct_per_line.lkql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ fun one_construct_per_line(node) =
5353
| ExtendedReturnStmtObjectDecl
5454
| NamedStmtDecl
5555
| AcceptStmtBody
56+
# Ignore generic package instantiations when they are in a generic formal
57+
| GenericPackageInstantiation(parent: GenericFormal)
5658
) and (
5759
node.token_end().end_line == stdlib.next_non_blank_token_line(node.token_end())
5860
or node.token_start().start_line == stdlib.previous_non_blank_token_line(node.token_start())

testsuite/tests/checks/one_construct_per_line/line.ads

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ package Line is I : Integer; -- FLAG
44
F2 : Float; C : -- FLAG (2)
55
Character;
66

7+
generic
8+
type Data_Type is private;
9+
package Pkg_A is
10+
end Pkg_A;
11+
12+
generic
13+
with package Data_Pkg is new Pkg_A (<>); -- NOFLAG
14+
with procedure Test (X : Integer) is <>; -- NOFLAG
15+
package Pkg_B is
16+
end Pkg_B;
17+
718
type T (A : Integer; B : Integer) is null record; -- NOFLAG
819

920
procedure Proc (I : in out Integer); end Line; -- FLAG

testsuite/tests/checks/one_construct_per_line/test.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ line.ads:4:16: rule violation: more than one construct on the same line
1010
4 | F2 : Float; C : -- FLAG (2)
1111
| ^
1212

13-
line.ads:9:14: rule violation: more than one construct on the same line
14-
9 | procedure Proc (I : in out Integer); end Line; -- FLAG
15-
| ^^^^
13+
line.ads:20:14: rule violation: more than one construct on the same line
14+
20 | procedure Proc (I : in out Integer); end Line; -- FLAG
15+
| ^^^^
1616

1717
line.adb:20:50: rule violation: more than one construct on the same line
1818
20 | accept Start (I : Integer; B : Boolean) do null; -- FLAG

0 commit comments

Comments
 (0)