@Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression) {
    PsiExpression qualifierExpression = expression.getQualifierExpression();
    while (qualifierExpression != null) {
      if (!(qualifierExpression instanceof PsiReferenceExpression)) {
        myResult = null;
        return;
      }

      PsiReferenceExpression qualifier = (PsiReferenceExpression) qualifierExpression;
      final PsiElement resolved = qualifier.resolve();
      if (resolved instanceof PsiPackage) break;
      if (!(resolved instanceof PsiClass)) {
        myResult = null;
        return;
      }
      qualifierExpression = ((PsiReferenceExpression) qualifierExpression).getQualifierExpression();
    }

    PsiElement resolvedExpression = expression.resolve();
    if (resolvedExpression instanceof PsiEnumConstant) {
      String constant = ((PsiEnumConstant)resolvedExpression).getName();
      PsiReferenceExpression qualifier = (PsiReferenceExpression)expression.getQualifier();
      if (qualifier == null) return;
      PsiElement element = qualifier.resolve();
      if (!(element instanceof PsiClass)) return;
      String name = ClassUtil.getJVMClassName((PsiClass)element);
      try {
        Class aClass = Class.forName(name);
        //noinspection unchecked
        myResult = Enum.valueOf(aClass, constant);
      }
      catch (Throwable ignore) { }
      return;
    }
    if (resolvedExpression instanceof PsiVariable) {
      PsiVariable variable = (PsiVariable) resolvedExpression;
      // avoid cycles
      if (myVisitedVars != null && myVisitedVars.contains(variable)) {
        myResult = null;
        return;
      }

      Set<PsiVariable> oldVisitedVars = myVisitedVars;
      if (myVisitedVars == null) {
        myVisitedVars = new HashSet<>();
      }

      myVisitedVars.add(variable);
      try {
        myResult = variable instanceof PsiVariableEx? ((PsiVariableEx) variable).computeConstantValue(myVisitedVars) : null;
        if (myResult == null && myAuxEvaluator != null) myResult = myAuxEvaluator.computeExpression(expression, this);
        return;
      }
      finally {
        myVisitedVars.remove(variable);
        myVisitedVars = oldVisitedVars;
      }
    }

    myResult = null;
  }
@Override public void visitReferenceExpression(@NotNull PsiReferenceExpression expression)