mirror of
https://github.com/github/codeql.git
synced 2026-04-29 02:35:15 +02:00
QL: Hide parentheses in AST
Joint work with erik-krogh
This commit is contained in:
@@ -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 = "???" }
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user