Skip to content

Commit ef4aa57

Browse files
committed
Merge branch 'topic/fix_uncommented_begin' into 'master'
Fix the 'Uncommented_BEGIN' rule Closes #373 See merge request eng/libadalang/langkit-query-language!312
2 parents fc10f98 + 0b6f0e5 commit ef4aa57

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

lkql_checker/share/lkql/stdlib.lkql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ fun sloc_image(node) =
446446

447447
fun find_comment(token, name) =
448448
|" Return true if a comment token immediately following the previous
449-
|" "begin" keyword is found and containing only the package name.
449+
|" "begin" keyword is found and contains only the provided name.
450450

451451
if token.kind == "comment" and
452452
token.previous().previous().kind == "begin"

lkql_checker/share/lkql/uncommented_begin.lkql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ fun uncommented_begin(unit) = [
1414
select node@HandledStmts(parent: p@(PackageBody | SubpBody |
1515
EntryBody | ProtectedBody |
1616
TaskBody))
17-
when p.f_decls is *(f_decls: l)
17+
when p.f_decls.f_decls is l
1818
when l[1]
19-
and not stdlib.find_comment(node.token_start().previous(exclude_trivia=true),
19+
and not stdlib.find_comment(node.token_start().previous(),
2020
p.p_defining_name().text)
2121
]
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
uncommented.adb:4:4: rule violation: mark BEGIN with -- Proc
2-
4 | begin -- FLAG
2+
4 | begin -- FLAG
33
| ^^^^^
44

5-
uncommented.adb:8:1: rule violation: mark BEGIN with -- Uncommented
6-
8 | begin -- FLAG
7-
| ^^^^^
5+
uncommented.adb:21:1: rule violation: mark BEGIN with -- Uncommented
6+
21 | begin -- FLAG
7+
| ^^^^^
88

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
package body Uncommented is
22
procedure Proc (I : out Integer) is
33
J : Integer;
4-
begin -- FLAG
4+
begin -- FLAG
55
I := Var;
66
end Proc;
77

8-
begin -- FLAG
8+
procedure Proc_2 is
9+
I : Integer;
10+
S : String := "Hello";
11+
begin -- Proc_2
12+
-- A comment
13+
null;
14+
end Name;
15+
16+
procedure Proc_3 is
17+
begin -- NOFLAG
18+
null;
19+
end Proc_3;
20+
21+
begin -- FLAG
922
Var := Inner.Inner_Var + 1;
1023
end;

0 commit comments

Comments
 (0)