Skip to content

Commit e65b93a

Browse files
committed
Merge branch 'topic/fix_one_construct_per_line' into 'master'
Fix "one_construct_per_line" rule regarding accept statement bodies Closes #374 See merge request eng/libadalang/langkit-query-language!313
2 parents ef4aa57 + b378f42 commit e65b93a

File tree

3 files changed

+48
-23
lines changed

3 files changed

+48
-23
lines changed

lkql_checker/share/lkql/one_construct_per_line.lkql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fun one_construct_per_line(node) =
2626
LabelDecl | GenericSubpInternal |
2727
ConcreteFormalSubpDecl |
2828
ExtendedReturnStmtObjectDecl |
29-
NamedStmtDecl))
29+
NamedStmtDecl | AcceptStmtBody))
3030
and (node.token_end().end_line ==
3131
stdlib.next_non_blank_token_line(node.token_end())
3232
or node.token_start().start_line ==

testsuite/tests/checks/one_construct_per_line/line.adb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
package body Line is
22

3+
task type Tsk is
4+
entry Start (I : Integer; B : Boolean); -- NOFLAG
5+
end Tsk;
6+
7+
task type Other_Tsk is
8+
entry Start (I : Integer; B : Boolean); -- NOFLAG
9+
end Other_Tsk;
10+
11+
task body Tsk is
12+
begin
13+
accept Start (I : Integer; B : Boolean) do -- NOFLAG
14+
null;
15+
end Start;
16+
end Tsk;
17+
18+
task body Other_Tsk is
19+
begin
20+
accept Start (I : Integer; B : Boolean) do null; -- FLAG
21+
end Start;
22+
end Other_Tsk;
23+
324
procedure Proc (I : in out Integer) is
425
Tmp : Integer;
526

testsuite/tests/checks/one_construct_per_line/test.out

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,50 @@ line.ads:9:14: rule violation: more than one construct on the same line
1414
9 | procedure Proc (I : in out Integer); end Line; -- FLAG
1515
| ^^^^
1616

17-
line.adb:8:7: rule violation: more than one construct on the same line
18-
8 | B3 : Boolean; B4 : Boolean; -- FLAG (2)
19-
| ^^
17+
line.adb:20:50: rule violation: more than one construct on the same line
18+
20 | accept Start (I : Integer; B : Boolean) do null; -- FLAG
19+
| ^^^^^
2020

21-
line.adb:8:21: rule violation: more than one construct on the same line
22-
8 | B3 : Boolean; B4 : Boolean; -- FLAG (2)
23-
| ^^
21+
line.adb:29:7: rule violation: more than one construct on the same line
22+
29 | B3 : Boolean; B4 : Boolean; -- FLAG (2)
23+
| ^^
2424

25-
line.adb:12:10: rule violation: more than one construct on the same line
26-
12 | I := J; if I > 0 then -- FLAG (2)
25+
line.adb:29:21: rule violation: more than one construct on the same line
26+
29 | B3 : Boolean; B4 : Boolean; -- FLAG (2)
27+
| ^^
28+
29+
line.adb:33:10: rule violation: more than one construct on the same line
30+
33 | I := J; if I > 0 then -- FLAG (2)
2731
| ^^^^^^^
2832

29-
line.adb:12:18: rule violation: more than one construct on the same line
30-
12 | I := J; if I > 0 then -- FLAG (2)
33+
line.adb:33:18: rule violation: more than one construct on the same line
34+
33 | I := J; if I > 0 then -- FLAG (2)
3135
| __________________^
32-
13 || I := 0; end if; -- FLAG
36+
34 || I := 0; end if; -- FLAG
3337
||__________________________^
3438

35-
line.adb:13:12: rule violation: more than one construct on the same line
36-
13 | I := 0; end if; -- FLAG
39+
line.adb:34:12: rule violation: more than one construct on the same line
40+
34 | I := 0; end if; -- FLAG
3741
| ^^^^^^^
3842

39-
line.adb:26:18: rule violation: more than one construct on the same line
40-
26 | My_Loop_2: for I in 1 .. 2 loop -- FLAG
43+
line.adb:47:18: rule violation: more than one construct on the same line
44+
47 | My_Loop_2: for I in 1 .. 2 loop -- FLAG
4145
| __________________^
4246
||
4347
|| ~~~ 1 other lines ~~~
4448
||
45-
28 || end loop My_Loop_2;
49+
49 || end loop My_Loop_2;
4650
||_________________________^
4751

48-
line.adb:30:7: rule violation: more than one construct on the same line
49-
30 | Tmp := I; I := I + 1; -- FLAG (2)
52+
line.adb:51:7: rule violation: more than one construct on the same line
53+
51 | Tmp := I; I := I + 1; -- FLAG (2)
5054
| ^^^^^^^^^
5155

52-
line.adb:30:17: rule violation: more than one construct on the same line
53-
30 | Tmp := I; I := I + 1; -- FLAG (2)
56+
line.adb:51:17: rule violation: more than one construct on the same line
57+
51 | Tmp := I; I := I + 1; -- FLAG (2)
5458
| ^^^^^^^^^^^
5559

56-
line.adb:32:7: rule violation: more than one construct on the same line
57-
32 | I := I + 1; end Proc; -- FLAG
60+
line.adb:53:7: rule violation: more than one construct on the same line
61+
53 | I := I + 1; end Proc; -- FLAG
5862
| ^^^^^^^^^^^
5963

0 commit comments

Comments
 (0)