Merge PR #312 (https://github.com/JetBrains/intellij-community/pull/312)
authorDaniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Thu, 24 Mar 2016 16:16:05 +0000 (19:16 +0300)
committerDaniil Ovchinnikov <daniil.ovchinnikov@jetbrains.com>
Thu, 24 Mar 2016 16:16:05 +0000 (19:16 +0300)
1  2 
plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/psi/util/PsiUtil.java

index 4d212ee498699725b298b05b7328b500bd3883cd,6a3262ef3adf90ad06f88c041388f5b3d0665e45..15e7087baa5d35ae99bd66f08357e85004e55d95
@@@ -1171,23 -1170,17 +1172,30 @@@ public class PsiUtil 
          parent instanceof GrAssertStatement ||
          parent instanceof GrThrowStatement ||
          parent instanceof GrSwitchStatement ||
-         parent instanceof GrVariable) {
+         parent instanceof GrVariable ||
 -        parent instanceof GrReferenceExpression ||
+         parent instanceof GrWhileStatement) {
        return true;
      }
  
 -    
 +    if (parent instanceof GrReferenceExpression) {
 +      if (ResolveUtil.isClassReference(parent)) {
 +        parent = parent.getParent();
 +      }
 +      if (parent instanceof GrReferenceExpression) {
 +        PsiElement resolved = ((GrReferenceExpression)parent).resolve();
 +        if (resolved instanceof PsiMember) {
 +          PsiClass containingClass = ((PsiMember)resolved).getContainingClass();
 +          return containingClass != null && CommonClassNames.JAVA_LANG_CLASS.equals(containingClass.getQualifiedName());
 +        }
 +      }
 +      return true;
 +    }
++
+     if (parent instanceof GrTraditionalForClause) {
+       GrTraditionalForClause forClause = (GrTraditionalForClause)parent;
+       return expr == forClause.getCondition();
+     }
++
      return isReturnStatement(expr);
    }