@Override public void renameVariableIn(PathNode node) { node.renameVariableTo(entityVariableName); }
public void replaceSelectedEntityVariable(String newVariableName, PathNode pathNode) { if (pathNode != null) { pathNode.renameVariableTo(newVariableName); //remove path elements while (pathNode.getChildCount() > 0) { pathNode.deleteChild(0); } } }
@Override public void renameVariableIn(PathNode node) { node.renameVariableTo(pathNode.getEntityVariableName()); List newChildren = new ArrayList(pathNode.dupNode().getChildren()); while (node.getChildCount() > 0) { newChildren.add(node.deleteChild(0)); } node.addChildren(newChildren); }
public void mixinJoinIntoTree(CommonTree joinClause, EntityReference entityReference, boolean renameVariable) { CommonTree from = queryTree.getAstFromNode(); for (int i = 0; i < from.getChildCount(); i++) { SelectionSourceNode selectionSource = (SelectionSourceNode) from.getChild(i); if (selectionSource.getChild(0) instanceof IdentificationVariableNode) { IdentificationVariableNode identificationVariable = (IdentificationVariableNode) selectionSource.getChild(0); if (entityReference.supportsJoinTo(identificationVariable)) { String variableName = identificationVariable.getVariableName(); JoinVariableNode joinNode = (JoinVariableNode) joinClause; if (hasJoinNode(joinNode, selectionSource)) { return; } if (renameVariable) { PathNode path = joinNode.findPathNode(); if (path != null) { path.renameVariableTo(variableName); } } selectionSource.addChild(joinClause); from.freshenParentAndChildIndexes(); return; } } } throw new RuntimeException("Join mixing failed. Cannot find selected entity with name " + entityReference); }