/*
 * Copyright 2003-2007 Dave Griffith, Bas Leijdekkers
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.siyeh.ipp.constant;

import com.intellij.psi.*;
import com.intellij.psi.util.PsiUtil;
import com.siyeh.ipp.base.PsiElementPredicate;

class ConstantExpressionPredicate implements PsiElementPredicate{

    public boolean satisfiedBy(PsiElement element){
        if(!(element instanceof PsiBinaryExpression)){
            return false;
        }
        if(element instanceof PsiLiteralExpression ||
                element instanceof PsiClassObjectAccessExpression){
	        return false;
        }
	    final PsiBinaryExpression expression = (PsiBinaryExpression) element;
        final PsiExpression rhs = expression.getROperand();
        if (rhs == null) {
            return false;
        }
        final PsiType type = rhs.getType();
	    if (type == null || type.equalsToText("java.lang.String")){
		    return false;
	    }
        if(!PsiUtil.isConstantExpression(expression)){
            return false;
        }
        final PsiManager manager= element.getManager();
      final PsiConstantEvaluationHelper helper = JavaPsiFacade.getInstance(manager.getProject()).getConstantEvaluationHelper();
        final Object value = helper.computeConstantExpression(expression);
        if(value == null){
	        return false;
        }
        final PsiElement parent = element.getParent();
	    return !(parent instanceof PsiExpression &&
			    PsiUtil.isConstantExpression((PsiExpression)parent));
    }
}
@@ -21,9 +21,9 @@
 -200
-7
+8
  Dav
@@ -697,23 +697,134 @@
 si.util.
-PsiUtil
+ConstantEvaluationOverflowException;%0Aimport com.intellij.psi.util.PsiUtil;%0Aimport com.intellij.openapi.project.Project
 ;%0Aimport
@@ -1721,98 +1721,202 @@
     
+  
 final P
-siConstantEvaluationHelper helper = JavaPsiFacade.getInstance(manager.getProject())
+roject project = manager.getProject();%0A        final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);%0A        final PsiConstantEvaluationHelper helper =%0A                facade
 .get
@@ -1939,24 +1939,41 @@
 onHelper();%0A
+        try%7B%0A    
         fina
@@ -1988,16 +1988,36 @@
  value =
+%0A                   
  helper.
@@ -2052,27 +2052,36 @@
 pression
-);%0A
+, true);%0A   
         
 if(value
@@ -2072,16 +2072,17 @@
         
+ 
 if(value
@@ -2092,17 +2092,126 @@
  null)%7B%0A
-%09
+                return false;%0A            %7D%0A        %7D catch (ConstantEvaluationOverflowException ignore)%7B%0A    
         

integrate IDEADEV-24846