Ejemplo n.º 1
0
 /**
  * Returns a copy of the provided nodes list.
  *
  * @param <T> the actual nodes's type
  * @param nodes the nodes list to copy
  * @return a single node, representing a copy of the nodes list
  */
 public <T extends ASTNode> T copyRange(List<T> nodes) {
   if (nodes.isEmpty()) {
     return null;
   }
   if (!isValidForRangeCopy(nodes)) {
     throw new IllegalArgumentException(
         nodes.get(0), "The provided nodes are not valid for doing a range copy: " + nodes);
   }
   return refactorings.createCopyTarget(nodes.get(0), nodes.get(nodes.size() - 1));
 }
Ejemplo n.º 2
0
 /**
  * Returns a placeholder where to move the provided {@link ASTNode}.
  *
  * @param <T> the actual node type
  * @param nodeToMove the node to move
  * @return a placeholder for the moved node
  */
 public <T extends ASTNode> T move(T nodeToMove) {
   return refactorings.createMoveTarget(nodeToMove);
 }
Ejemplo n.º 3
0
 private boolean isValidForRangeCopy(List<? extends ASTNode> nodes) {
   return nodesHaveSameParentAndLocation(nodes) && refactorings.isValidRange(nodes);
 }
Ejemplo n.º 4
0
 /**
  * Returns a copy of the provided {@link ASTNode}.
  *
  * @param <T> the actual node type
  * @param nodeToCopy the node to copy
  * @return a copy of the node
  */
 public <T extends ASTNode> T copy(T nodeToCopy) {
   if (isValidInCurrentAST(nodeToCopy)) {
     return refactorings.createCopyTarget(nodeToCopy);
   }
   return copySubtree(nodeToCopy);
 }
Ejemplo n.º 5
0
 /**
  * Class constructor.
  *
  * @param refactorings the refactorings
  */
 public ASTBuilder(final Refactorings refactorings) {
   this.refactorings = refactorings;
   this.ast = refactorings.getAST();
 }