@Override public PsiElement add(@NotNull PsiElement element) throws IncorrectOperationException { CheckUtil.checkWritable(this); TreeElement elementCopy = ChangeUtil.copyToElement(element); calcTreeElement().addInternal(elementCopy, elementCopy, null, null); elementCopy = ChangeUtil.decodeInformation(elementCopy); return SourceTreeToPsiMap.treeElementToPsi(elementCopy); }
@Override public PsiElement addAfter(@NotNull PsiElement element, PsiElement anchor) throws IncorrectOperationException { CheckUtil.checkWritable(this); TreeElement elementCopy = ChangeUtil.copyToElement(element); calcTreeElement() .addInternal( elementCopy, elementCopy, SourceTreeToPsiMap.psiElementToTree(anchor), Boolean.FALSE); elementCopy = ChangeUtil.decodeInformation(elementCopy); return SourceTreeToPsiMap.treeElementToPsi(elementCopy); }
@Override public PsiElement replace(@NotNull PsiElement newElement) throws IncorrectOperationException { LOG.assertTrue(getTreeParent() != null); CheckUtil.checkWritable(this); TreeElement elementCopy = ChangeUtil.copyToElement(newElement); getTreeParent().replaceChildInternal(this, elementCopy); elementCopy = ChangeUtil.decodeInformation(elementCopy); final PsiElement result = SourceTreeToPsiMap.treeElementToPsi(elementCopy); this.invalidate(); return result; }