Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address extra parens introduced by several visitors. ASTDelayedPredicate detects if a node is already delayed. #1165

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ public Object visit(ASTBitwiseComplNode node, Object data) {

@Override
public Object visit(ASTNotNode node, Object data) {

node.childrenAccept(this, data);
return data;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import datawave.query.jexl.JexlASTHelper;
import datawave.query.jexl.JexlNodeFactory;
import datawave.query.jexl.LiteralRange;
import datawave.query.jexl.nodes.BoundedRange;
import datawave.query.jexl.nodes.QueryPropertyMarker;
import org.apache.commons.jexl2.parser.ASTAndNode;
Expand All @@ -16,7 +15,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
* Pushdown negations until they are either wrapping leaf nodes or bounded ranges. The purpose of this class is to remove edge cases from evaluating
Expand All @@ -40,7 +38,7 @@ public static JexlNode pushdownNegations(JexlNode tree) {

flattened.jjtAccept(new PushdownNegationVisitor(), new NegationState(false));

// flatten the result
// flatten the result, including extra parens picked up during the pushdown
return TreeFlatteningRebuildingVisitor.flatten(flattened);
}

Expand Down Expand Up @@ -214,9 +212,9 @@ public static JexlNode applyDeMorgans(JexlNode root, boolean negateRoot) {
// flip the root operator and finish validating the root
JexlNode newRoot;
if (root instanceof ASTAndNode) {
newRoot = JexlNodeFactory.createOrNode(negatedChildren);
newRoot = JexlNodeFactory.createUnwrappedOrNode(negatedChildren);
} else if (root instanceof ASTOrNode) {
newRoot = JexlNodeFactory.createAndNode(negatedChildren);
newRoot = JexlNodeFactory.createUnwrappedAndNode(negatedChildren);
} else {
throw new IllegalArgumentException("root must be either an ASTAndNode or ASTOrNode");
}
Expand Down