@@ -30,23 +30,43 @@ int getLineAboveNodeThatCouldHaveDoc(File file) {
30
30
pragma [ noinline]
31
31
BlockComment getACommentThatCouldBeQLDoc ( File file ) {
32
32
file = result .getLocation ( ) .getFile ( ) and
33
- result .getLocation ( ) .getEndLine ( ) = getLineAboveNodeThatCouldHaveDoc ( file ) and
34
33
result .getLocation ( ) .getFile ( ) .getExtension ( ) = "qll" and
35
- not result .getContents ( ) .matches ( "/**%" )
34
+ not result .getContents ( ) .matches ( "/**%" ) and
35
+ (
36
+ // above something that can be commented.
37
+ result .getLocation ( ) .getEndLine ( ) = getLineAboveNodeThatCouldHaveDoc ( file )
38
+ or
39
+ // toplevel in file.
40
+ result .getLocation ( ) .getStartLine ( ) = 1 and
41
+ result .getLocation ( ) .getStartColumn ( ) = 1
42
+ )
36
43
}
37
44
38
45
pragma [ noinline]
39
- BlockComment getCommentAt ( File file , int endLine ) {
46
+ BlockComment getCommentAtEnd ( File file , int endLine ) {
40
47
result = getACommentThatCouldBeQLDoc ( file ) and
41
48
result .getLocation ( ) .getEndLine ( ) = endLine
42
49
}
43
50
44
- from AstNode node , BlockComment comment
51
+ pragma [ noinline]
52
+ BlockComment getCommentAtStart ( File file , int startLine ) {
53
+ result = getACommentThatCouldBeQLDoc ( file ) and
54
+ result .getLocation ( ) .getStartLine ( ) = startLine
55
+ }
56
+
57
+ from AstNode node , BlockComment comment , string nodeDescrip
45
58
where
46
- canHaveQLDoc ( node ) and
59
+ (
60
+ canHaveQLDoc ( node ) and
61
+ comment = getCommentAtEnd ( node .getLocation ( ) .getFile ( ) , node .getLocation ( ) .getStartLine ( ) - 1 ) and
62
+ nodeDescrip = "the below code"
63
+ or
64
+ node instanceof TopLevel and
65
+ comment = getCommentAtStart ( node .getLocation ( ) .getFile ( ) , 1 ) and
66
+ nodeDescrip = "the file"
67
+ ) and
47
68
not exists ( node .getQLDoc ( ) ) and
48
69
not node .( ClassPredicate ) .isOverride ( ) and // ignore override predicates
49
70
not node .hasAnnotation ( "deprecated" ) and // ignore deprecated
50
- not node .hasAnnotation ( "private" ) and // ignore private
51
- comment = getCommentAt ( node .getLocation ( ) .getFile ( ) , node .getLocation ( ) .getStartLine ( ) - 1 )
52
- select comment , "Block comment could be QLDoc for $@." , node , "the below code"
71
+ not node .hasAnnotation ( "private" ) // ignore private
72
+ select comment , "Block comment could be QLDoc for $@." , node , nodeDescrip
0 commit comments