mirror of
https://github.com/github/codeql.git
synced 2026-04-21 15:05:56 +02:00
add consistency test that parents are unique (and fix non-unique parents)
This commit is contained in:
@@ -162,6 +162,8 @@ class QLDoc extends TQLDoc, AstNode {
|
||||
string getContents() { result = qldoc.getValue() }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "QLDoc" }
|
||||
|
||||
override AstNode getParent() { result.getQLDoc() = this }
|
||||
}
|
||||
|
||||
class BlockComment extends TBlockComment, AstNode {
|
||||
@@ -2313,7 +2315,7 @@ class Annotation extends TAnnotation, AstNode {
|
||||
/** Gets the node corresponding to the field `name`. */
|
||||
string getName() { result = annot.getName().getValue() }
|
||||
|
||||
override AstNode getParent() { result = AstNode.super.getParent() }
|
||||
override AstNode getParent() { result.getAnAnnotation() = this }
|
||||
|
||||
override AstNode getAChild(string pred) {
|
||||
result = super.getAChild(pred)
|
||||
|
||||
@@ -231,4 +231,6 @@ module AstConsistency {
|
||||
not node instanceof YAML::YAMLNode and // parents for YAML doens't work
|
||||
not (node instanceof QLDoc and node.getLocation().getFile().getExtension() = "dbscheme") // qldoc in dbschemes are not hooked up
|
||||
}
|
||||
|
||||
query predicate nonUniqueParent(AstNode node) { count(node.getParent()) >= 2 }
|
||||
}
|
||||
|
||||
@@ -31,7 +31,9 @@ where
|
||||
TypeConsistency::multiplePrimitivesExpr(node, _, _) and
|
||||
msg = "TypeConsistency::multiplePrimitivesExpr"
|
||||
or
|
||||
AstConsistency::nonTotalGetParent(node) and msg = "AstConsistency::nonTotalGetParent" // TODO: unique parent
|
||||
AstConsistency::nonTotalGetParent(node) and msg = "AstConsistency::nonTotalGetParent"
|
||||
or
|
||||
AstConsistency::nonUniqueParent(node) and msg = "AstConsistency::nonUniqueParent"
|
||||
or
|
||||
TypeConsistency::noResolve(node) and msg = "TypeConsistency::noResolve"
|
||||
or
|
||||
@@ -47,4 +49,3 @@ where
|
||||
or
|
||||
VarConsistency::noVarDef(node) and msg = "VarConsistency::noVarDef"
|
||||
select node, msg
|
||||
// TODO: vardef consistency.
|
||||
|
||||
Reference in New Issue
Block a user