private void buildSourceStructures(org.parboiled.Node<Node> pNode, Node owner, ListMultimap<Node, SourceStructure> map) { Node target = registeredStructures.remove(pNode); if (target != null || pNode.getChildren().isEmpty()) { int start = pNode.getStartIndex(); int end = pNode.getEndIndex(); String text = preprocessed.substring(start, end); SourceStructure structure = new SourceStructure(new Position(start, end), text); if (target != null) addSourceStructure(map, target, structure); else if (pNode.getValue() != null && !(pNode.getValue() instanceof TemporaryNode)) addSourceStructure(map, pNode.getValue(), structure); else if (owner != null) addSourceStructure(map, owner, structure); } else { Node possibleOwner = pNode.getValue(); if (possibleOwner instanceof TemporaryNode) possibleOwner = null; for (org.parboiled.Node<Node> child : pNode.getChildren()) { if (child.getValue() == null || child.getValue() instanceof TemporaryNode) continue; /* If the next if holds true, then we aren't the true generator; the child generated the node and this pNode adopted it */ if (child.getValue() == possibleOwner) possibleOwner = null; } if (possibleOwner != null) owner = possibleOwner; for (org.parboiled.Node<Node> child : pNode.getChildren()) { buildSourceStructures(child, owner, map); } } }
private void buildSourceStructures(org.parboiled.Node<Node> pNode, Node owner, ListMultimap<Node, SourceStructure> map) { Node target = registeredStructures.remove(pNode); if (target != null || pNode.getChildren().isEmpty()) { int start = pNode.getStartIndex(); int end = pNode.getEndIndex(); String text = preprocessed.substring(start, end); SourceStructure structure = new SourceStructure(new Position(start, end), text); if (target != null) addSourceStructure(map, target, structure); else if (pNode.getValue() != null && !(pNode.getValue() instanceof TemporaryNode)) addSourceStructure(map, pNode.getValue(), structure); else if (owner != null) addSourceStructure(map, owner, structure); } else { Node possibleOwner = pNode.getValue(); if (possibleOwner instanceof TemporaryNode) possibleOwner = null; for (org.parboiled.Node<Node> child : pNode.getChildren()) { if (child.getValue() == null || child.getValue() instanceof TemporaryNode) continue; /* If the next if holds true, then we aren't the true generator; the child generated the node and this pNode adopted it */ if (child.getValue() == possibleOwner) possibleOwner = null; } if (possibleOwner != null) owner = possibleOwner; for (org.parboiled.Node<Node> child : pNode.getChildren()) { buildSourceStructures(child, owner, map); } } }
private void buildSourceStructures(org.parboiled.Node<Node> pNode, Node owner, ListMultimap<Node, SourceStructure> map) { Node target = registeredStructures.remove(pNode); if (target != null || pNode.getChildren().isEmpty()) { int start = pNode.getStartIndex(); int end = pNode.getEndIndex(); String text = preprocessed.substring(start, end); SourceStructure structure = new SourceStructure(new Position(start, end), text); if (target != null) addSourceStructure(map, target, structure); else if (pNode.getValue() != null && !(pNode.getValue() instanceof TemporaryNode)) addSourceStructure(map, pNode.getValue(), structure); else if (owner != null) addSourceStructure(map, owner, structure); } else { Node possibleOwner = pNode.getValue(); if (possibleOwner instanceof TemporaryNode) possibleOwner = null; for (org.parboiled.Node<Node> child : pNode.getChildren()) { if (child.getValue() == null || child.getValue() instanceof TemporaryNode) continue; /* If the next if holds true, then we aren't the true generator; the child generated the node and this pNode adopted it */ if (child.getValue() == possibleOwner) possibleOwner = null; } if (possibleOwner != null) owner = possibleOwner; for (org.parboiled.Node<Node> child : pNode.getChildren()) { buildSourceStructures(child, owner, map); } } }