QL: Hide parentheses in AST

Joint work with erik-krogh
This commit is contained in:
Taus
2021-05-27 12:17:40 +00:00
committed by GitHub
parent aa23ec0714
commit b4f67c9d5f
2 changed files with 12 additions and 2 deletions

View File

@@ -6,9 +6,17 @@ private import codeql_ql.ast.internal.Module
class AstNode extends TAstNode {
string toString() { result = getAPrimaryQlClass() }
Location getLocation() { result = toGenerated(this).getLocation() }
Location getLocation() {
exists(Generated::AstNode node | not node instanceof Generated::ParExpr |
node = toGenerated(this) and
result = node.getLocation()
)
}
AstNode getParent() { toGenerated(result) = toGenerated(this).getParent() }
AstNode getParent() {
toGenerated(result) = toGenerated(this).getParent() and
not result = this
}
string getAPrimaryQlClass() { result = "???" }
}

View File

@@ -92,6 +92,8 @@ Generated::AstNode toGenerated(AST::AstNode n) {
or
result = toGeneratedFormula(n)
or
result.(Generated::ParExpr).getChild() = toGenerated(n)
or
n = TClasslessPredicate(_, result)
or
n = TVarDecl(result)