Skip to content

Commit de08226

Browse files
committed
QL: fixup getQLDoc()
1 parent 7d4ea47 commit de08226

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

ql/ql/src/codeql_ql/ast/Ast.qll

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,15 @@ class TopLevel extends TTopLevel, AstNode {
156156
}
157157

158158
QLDoc getQLDocFor(ModuleMember m) {
159-
exists(int i | i > 0 and result = this.getMember(i) and m = this.getMember(i + 1))
159+
exists(int i | result = this.getMember(i) and m = this.getMember(i + 1))
160160
}
161161

162162
override string getAPrimaryQlClass() { result = "TopLevel" }
163163

164-
override QLDoc getQLDoc() { result = this.getMember(0) }
164+
override QLDoc getQLDoc() {
165+
result = this.getMember(0) and
166+
result.getLocation().getStartLine() = 1 // this might not hold if there is a block comment above, and that's the point.
167+
}
165168
}
166169

167170
abstract class Comment extends AstNode, TComment {
@@ -536,6 +539,12 @@ class ClasslessPredicate extends TClasslessPredicate, Predicate, ModuleDeclarati
536539

537540
/** Holds if this classless predicate is a signature predicate with no body. */
538541
predicate isSignature() { not exists(this.getBody()) }
542+
543+
override QLDoc getQLDoc() {
544+
result = any(TopLevel m).getQLDocFor(this)
545+
or
546+
result = any(Module m).getQLDocFor(this)
547+
}
539548
}
540549

541550
/**

0 commit comments

Comments
 (0)