private void addSourceStructure(ListMultimap<Node, SourceStructure> map, Node node, SourceStructure structure) { if (structure.getPosition().size() > 0 && structure.getContent().trim().length() > 0 && !structure.getPosition().equals(node.getPosition())) { map.put(node, structure); } }
public Map<Node, Collection<SourceStructure>> getSourceStructures() { if (cachedSourceStructures != null) return cachedSourceStructures; parseCompilationUnit(); ListMultimap<Node, SourceStructure> map = LinkedListMultimap.create(); org.parboiled.Node<Node> pNode = parsingResult.parseTreeRoot; buildSourceStructures(pNode, null, map); Map<Node, Collection<SourceStructure>> result = map.asMap(); for (Collection<SourceStructure> structures : result.values()) { for (SourceStructure structure : structures) { structure.setPosition(new Position( mapPosition(structure.getPosition().getStart()), mapPosition(structure.getPosition().getEnd()))); } } return cachedSourceStructures = result; }
private int countStructure(lombok.ast.Node node, String structure) { int result = 0; if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) result++; } } return result; }
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); } } }
public Map<Node, Collection<SourceStructure>> getSourceStructures() { if (cachedSourceStructures != null) return cachedSourceStructures; parseCompilationUnit(); ListMultimap<Node, SourceStructure> map = LinkedListMultimap.create(); org.parboiled.Node<Node> pNode = parsingResult.parseTreeRoot; buildSourceStructures(pNode, null, map); Map<Node, Collection<SourceStructure>> result = map.asMap(); for (Collection<SourceStructure> structures : result.values()) { for (SourceStructure structure : structures) { structure.setPosition(new Position( mapPosition(structure.getPosition().getStart()), mapPosition(structure.getPosition().getEnd()))); } } return cachedSourceStructures = result; }
private int countStructure(lombok.ast.Node node, String structure) { int result = 0; if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) result++; } } return result; }
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 addSourceStructure(ListMultimap<Node, SourceStructure> map, Node node, SourceStructure structure) { if (structure.getPosition().size() > 0 && structure.getContent().trim().length() > 0 && !structure.getPosition().equals(node.getPosition())) { map.put(node, structure); } }
public Map<Node, Collection<SourceStructure>> getSourceStructures() { if (cachedSourceStructures != null) return cachedSourceStructures; parseCompilationUnit(); ListMultimap<Node, SourceStructure> map = LinkedListMultimap.create(); org.parboiled.Node<Node> pNode = parsingResult.parseTreeRoot; buildSourceStructures(pNode, null, map); Map<Node, Collection<SourceStructure>> result = map.asMap(); for (Collection<SourceStructure> structures : result.values()) { for (SourceStructure structure : structures) { structure.setPosition(new Position( mapPosition(structure.getPosition().getStart()), mapPosition(structure.getPosition().getEnd()))); } } return cachedSourceStructures = result; }
private int countStructure(lombok.ast.Node node, String structure) { int result = 0; if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) result++; } } return result; }
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 int posOfStructure(Node node, String structure, int idx, boolean atStart) { int start = node.getPosition().getStart(); if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) { start = atStart ? struct.getPosition().getStart() : struct.getPosition().getEnd(); if (idx-- <= 0) break; } } } return start; }
private int posOfStructure(Node node, String structure, int idx, boolean atStart) { int start = node.getPosition().getStart(); if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) { start = atStart ? struct.getPosition().getStart() : struct.getPosition().getEnd(); if (idx-- <= 0) break; } } } return start; }
private int posOfStructure(Node node, String structure, int idx, boolean atStart) { int start = node.getPosition().getStart(); if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) { start = atStart ? struct.getPosition().getStart() : struct.getPosition().getEnd(); if (idx-- <= 0) break; } } } return start; }
private void addSourceStructure(ListMultimap<Node, SourceStructure> map, Node node, SourceStructure structure) { if (structure.getPosition().size() > 0 && structure.getContent().trim().length() > 0 && !structure.getPosition().equals(node.getPosition())) { map.put(node, structure); } }
private int posOfStructure(lombok.ast.Node node, String structure, int idx, boolean atStart) { int start = node.getPosition().getStart(); int end = node.getPosition().getEnd(); Integer result = null; if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) { result = atStart ? struct.getPosition().getStart() : struct.getPosition().getEnd(); if (idx-- <= 0) break; } } } if (result != null) return result; return atStart ? start : end; }
private int posOfStructure(lombok.ast.Node node, String structure, int idx, boolean atStart) { int start = node.getPosition().getStart(); int end = node.getPosition().getEnd(); Integer result = null; if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) { result = atStart ? struct.getPosition().getStart() : struct.getPosition().getEnd(); if (idx-- <= 0) break; } } } if (result != null) return result; return atStart ? start : end; }
private int posOfStructure(lombok.ast.Node node, String structure, int idx, boolean atStart) { int start = node.getPosition().getStart(); int end = node.getPosition().getEnd(); Integer result = null; if (sourceStructures != null && sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { if (structure.equals(struct.getContent())) { result = atStart ? struct.getPosition().getStart() : struct.getPosition().getEnd(); if (idx-- <= 0) break; } } } if (result != null) return result; return atStart ? start : end; }
private void buildNode(String type, Node node) { if (node == null) { indent++; return; } String name = node.getClass().getSimpleName(); currentType = name; String description = ""; if (node instanceof DescribedNode) description = " " + ((DescribedNode)node).getDescription(); a(nodeFormatString, type, name, description, node.getPosition().getStart(), node.getPosition().getEnd()); indent++; if (sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { a("STRUCT: %s (%d-%d)\n", struct.getContent(), struct.getPosition().getStart(), struct.getPosition().getEnd()); } } }
private void buildNode(String type, Node node) { if (node == null) { indent++; return; } String name = node.getClass().getSimpleName(); currentType = name; String description = ""; if (node instanceof DescribedNode) description = " " + ((DescribedNode)node).getDescription(); a(nodeFormatString, type, name, description, node.getPosition().getStart(), node.getPosition().getEnd()); indent++; if (sourceStructures.containsKey(node)) { for (SourceStructure struct : sourceStructures.get(node)) { a("STRUCT: %s (%d-%d)\n", struct.getContent(), struct.getPosition().getStart(), struct.getPosition().getEnd()); } } }