@Override public void visitReferenceExpression(GrReferenceExpression expression) { super.visitReferenceExpression(expression); if (org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isSuperReference(expression)) { final GrExpression qualifier = expression.getQualifier(); if (qualifier instanceof GrReferenceExpression && ((GrReferenceExpression) qualifier).isReferenceTo(mySourceClass)) { try { expression.putCopyableUserData(SUPER_REF, Boolean.TRUE); } catch (IncorrectOperationException e) { LOG.error(e); } } } else if (org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isThisReference(expression)) { final GrExpression qualifier = expression.getQualifier(); if (qualifier instanceof GrReferenceExpression && ((GrReferenceExpression) qualifier).isReferenceTo(mySourceClass)) { try { expression.putCopyableUserData(THIS_REF, Boolean.TRUE); } catch (IncorrectOperationException e) { LOG.error(e); } } } }
private static void deleteOverrideAnnotationIfFound(PsiMethod oMethod) { final PsiAnnotation annotation = AnnotationUtil.findAnnotation(oMethod, CommonClassNames.JAVA_LANG_OVERRIDE); if (annotation != null) { PsiElement prev = annotation.getPrevSibling(); PsiElement next = annotation.getNextSibling(); if ((prev == null || org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isLineFeed(prev)) && org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isLineFeed(next)) { next.delete(); } annotation.delete(); } }
@Override public void visitReferenceExpression(GrReferenceExpression expression) { super.visitReferenceExpression(expression); if (org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isSuperReference( expression.getQualifierExpression())) { PsiElement resolved = expression.resolve(); if (resolved == null || resolved instanceof PsiMethod && shouldFixSuper((PsiMethod) resolved)) { mySupersToDelete.add(expression.getQualifierExpression()); } } else if (org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isSuperReference(expression)) { mySupersToChangeToThis.add(expression); } }
public void visitStatementOwner(GrStatementOwner owner, boolean shouldInsertReturnNull) { boolean hasLineFeed = false; for (PsiElement e = owner.getFirstChild(); e != null; e = e.getNextSibling()) { if (e instanceof GrStatement) { ((GrStatement) e).accept(this); hasLineFeed = false; } else if (TokenSets.COMMENT_SET.contains(e.getNode().getElementType())) { builder.append(e.getText()); } else if (org.jetbrains.plugins.groovy.lang.psi.util.PsiUtil.isLineFeed(e)) { hasLineFeed = true; if (IN_TEST) { builder.append(genSameLineFeed(e.getText())); } else { builder.append(e.getText()); } } } if (shouldInsertReturnNull) { if (!hasLineFeed) { builder.append('\n'); } builder.append("return null;\n"); } }