package com.siyeh.ipp.increment;

import com.intellij.psi.*;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.tree.IElementType;
import com.siyeh.ipp.base.PsiElementPredicate;
import com.siyeh.ipp.psiutils.ErrorUtil;

class ExtractIncrementPredicate
        implements PsiElementPredicate{
    public boolean satisfiedBy(PsiElement element){
        if(!(element instanceof PsiPrefixExpression) &&
                !(element instanceof PsiPostfixExpression)){
            return false;
        }
        if(ErrorUtil.containsError(element)){
            return false;
        }
        final PsiJavaToken sign;
        if(element instanceof PsiPostfixExpression){
            sign = ((PsiPostfixExpression) element).getOperationSign();
        } else{
            sign = ((PsiPrefixExpression) element).getOperationSign();
        }

        final IElementType tokenType = sign.getTokenType();
        if(!JavaTokenType.PLUSPLUS.equals(tokenType) &&
                !JavaTokenType.MINUSMINUS.equals(tokenType)){
            return false;
        }
        final PsiElement parent = element.getParent();
        if(parent instanceof PsiExpressionStatement){
            return false;
        }
        final PsiStatement containingStatement = PsiTreeUtil
                .getParentOfType(element, PsiStatement.class);
        return containingStatement != null;
    }
}

@@ -1194,32 +1194,33 @@
 alse;%0A        %7D%0A
+%0A
         final Ps
@@ -1327,16 +1327,253 @@
 class);%0A
+        if((containingStatement instanceof PsiReturnStatement %7C%7C%0A                containingStatement instanceof PsiThrowStatement) &&%0A                element instanceof PsiPostfixExpression)%0A        %7B%0A            return false;%0A        %7D%0A
         

Fix for IDEADEV-1676