private <T extends InstructionImpl> T addNode(T instruction) {
   instruction.setNumber(myInstructionNumber++);
   myInstructions.add(instruction);
   if (myHead != null) {
     addEdge(myHead, instruction);
   }
   myHead = instruction;
   return instruction;
 }
Пример #2
0
 public static <T extends PsiElement> void setQualifier(
     @NotNull GrQualifiedReference<T> ref, @Nullable T newQualifier) {
   final T oldQualifier = ref.getQualifier();
   final ASTNode node = ref.getNode();
   final PsiElement refNameElement = ref.getReferenceNameElement();
   if (newQualifier == null) {
     if (oldQualifier != null && refNameElement != null) {
       ref.deleteChildRange(ref.getFirstChild(), refNameElement.getPrevSibling());
     }
   } else {
     if (oldQualifier == null) {
       if (refNameElement != null) {
         node.addLeaf(mDOT, ".", refNameElement.getNode());
         ref.addBefore(newQualifier, refNameElement.getPrevSibling());
       }
     } else {
       oldQualifier.replace(newQualifier);
     }
   }
 }
Пример #3
0
 public static <T extends GrCondition> T replaceBody(
     T newBody, GrStatement body, ASTNode node, Project project) {
   if (body == null || newBody == null) {
     throw new IncorrectOperationException();
   }
   ASTNode oldBodyNode = body.getNode();
   if (oldBodyNode.getTreePrev() != null
       && mNLS.equals(oldBodyNode.getTreePrev().getElementType())) {
     ASTNode whiteNode = GroovyPsiElementFactory.getInstance(project).createWhiteSpace().getNode();
     node.replaceChild(oldBodyNode.getTreePrev(), whiteNode);
   }
   node.replaceChild(oldBodyNode, newBody.getNode());
   return newBody;
 }