PsiClass (@NotNull PsiExpression initializerExpression) { final PsiType type = initializerExpression.getType(); if (PsiUtil.isConstantExpression(initializerExpression) && (type instanceof PsiPrimitiveType || type != null && type.equalsToText(CommonClassNames.JAVA_LANG_STRING))) { return super.getParentClass(initializerExpression); } PsiElement parent = initializerExpression.getUserData(ElementToWorkOn.PARENT); if (parent == null) parent = initializerExpression; PsiClass aClass = PsiTreeUtil.getParentOfType(parent, PsiClass.class); while (aClass != null) { if (LocalToFieldHandler.mayContainConstants(aClass)) return aClass; aClass = PsiTreeUtil.getParentOfType(aClass, PsiClass.class); } return null; }