@Override public Tree dupNode() { SelectionSourceNode result = new SelectionSourceNode(token); dupChildren(result); return result; }
protected boolean hasJoinNode(JoinVariableNode joinNode, SelectionSourceNode selectionSource) { JoinVariableNode existingJoinNode = selectionSource.getChildren().stream() .filter(e -> e instanceof JoinVariableNode) .map(e -> (JoinVariableNode) e) .filter(e -> Objects.equals(e.getVariableName(), joinNode.getVariableName())) .findFirst().orElse(null); if (existingJoinNode != null) { PathNode existingPathNode = existingJoinNode.findPathNode(); PathNode pathNode = joinNode.findPathNode(); if (existingPathNode != null && pathNode != null) { if (Objects.equals(existingPathNode.asPathString(), pathNode.asPathString())) { return true; } } } return false; }
@Override public CommonTree treeToQueryPre(QueryBuilder sb, List<ErrorRec> invalidNodes) { CommonTree prevNode = getPrevNode(); if (prevNode != null && prevNode instanceof SelectionSourceNode) { sb.appendString(", "); } else { sb.appendSpace(); } return super.treeToQueryPre(sb, invalidNodes); }
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); }
root_1 = (Object)adaptor.becomeRoot(new SelectionSourceNode(T_SOURCE), root_1); adaptor.addChild(root_1, stream_collection_member_declaration.nextTree()); adaptor.addChild(root_0, root_1);
root_1 = (Object)adaptor.becomeRoot(new SelectionSourceNode(T_SOURCE), root_1); adaptor.addChild(root_1, stream_range_variable_declaration.nextTree());
root_2 = (Object)adaptor.becomeRoot(new SelectionSourceNode(T_SOURCE), root_2); adaptor.addChild(root_2, stream_subselect_identification_variable_declaration.nextTree()); adaptor.addChild(root_1, root_2);
root_1 = (Object)adaptor.becomeRoot(new SelectionSourceNode(T_SOURCES), root_1); adaptor.addChild(root_1, stream_identification_variable_declaration.nextTree()); adaptor.addChild(root_1, new UpdateSetNode(stream_SET.nextToken()));