@Override public TreeElement addInternal(TreeElement first, ASTNode last, ASTNode anchor, Boolean before) { if (first.getElementType() == NAME_VALUE_PAIR && last.getElementType() == NAME_VALUE_PAIR) { final CharTable treeCharTab = SharedImplUtil.findCharTableByTree(this); ASTNode lparenth = findChildByRole(ChildRole.LPARENTH); if (lparenth == null) { LeafElement created = Factory.createSingleLeafElement(LPARENTH, "(", 0, 1, treeCharTab, getManager()); super.addInternal(created, created, getFirstChildNode(), true); } ASTNode rparenth = findChildByRole(ChildRole.RPARENTH); if (rparenth == null) { LeafElement created = Factory.createSingleLeafElement(RPARENTH, ")", 0, 1, treeCharTab, getManager()); super.addInternal(created, created, getLastChildNode(), false); } final ASTNode[] nodes = getChildren(NAME_VALUE_PAIR_BIT_SET); if (nodes.length == 1) { final ASTNode node = nodes[0]; if (node instanceof PsiNameValuePair) { final PsiNameValuePair pair = (PsiNameValuePair) node; if (pair.getName() == null) { final String text = pair.getValue().getText(); try { final PsiAnnotation annotation = JavaPsiFacade.getInstance(getProject()) .getElementFactory() .createAnnotationFromText("@AAA(value = " + text + ")", null); replaceChild(node, annotation.getParameterList().getAttributes()[0].getNode()); } catch (IncorrectOperationException e) { LOG.error(e); } } } } if (anchor == null && before != null) { anchor = findChildByRole(before.booleanValue() ? ChildRole.RPARENTH : ChildRole.LPARENTH); } } return super.addInternal(first, last, anchor, before); }
@Override public void clearCaches() { super.clearCaches(); myCachedMembers = null; }