Skip to content

Commit

Permalink
Address comment
Browse files Browse the repository at this point in the history
  • Loading branch information
aibaars committed Dec 16, 2021
1 parent cdbd8b2 commit 3ef707e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions ruby/ql/lib/codeql/ruby/ast/Erb.qll
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private class ErbDirectiveFile extends File {

/** Gets a statement in this file. */
pragma[nomagic]
Stmt getAStmt(int startLine, int startColumn) {
AstNode getAnAstNode(int startLine, int startColumn) {
exists(Location loc |
result.getLocation() = loc and
loc.getFile() = this and
Expand All @@ -142,13 +142,13 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
)
}

private predicate containsStmtStart(Stmt s) {
private predicate containsAstNodeStart(AstNode s) {
// `Toplevel` statements are not contained within individual directives,
// though their start location may appear within a directive location
not s instanceof Toplevel and
exists(ErbDirectiveFile file, int startLine, int startColumn |
this.spans(file, startLine) and
s = file.getAStmt(startLine, startColumn) and
s = file.getAnAstNode(startLine, startColumn) and
locationIncludesPosition(this.getLocation(), startLine, startColumn)
)
}
Expand All @@ -158,8 +158,8 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
* statement starting in this directive.
*/
Stmt getAChildStmt() {
this.containsStmtStart(result) and
not this.containsStmtStart(parent*(result).getParent())
this.containsAstNodeStart(result) and
not this.containsAstNodeStart(result.getParent())
}

/**
Expand All @@ -183,11 +183,6 @@ class ErbDirective extends TDirectiveNode, ErbAstNode {
override string getAPrimaryQlClass() { result = "ErbDirective" }
}

private AstNode parent(AstNode n) {
result = n.getParent() and
not result instanceof Stmt
}

/**
* A comment directive in an ERB template.
* ```erb
Expand Down

0 comments on commit 3ef707e

Please sign in to comment.