private static boolean isExpressionContext(PsiElement element) {
      final PsiElement parent = element.getParent();
      if (!(parent instanceof PsiJavaCodeReferenceElement)) {
        return false;
      }
      if (((PsiJavaCodeReferenceElement)parent).isQualified()) {
        return false;
      }
      PsiElement grandParent = parent.getParent();
      if (grandParent instanceof PsiMethodCallExpression || grandParent instanceof PsiReferenceList) {
        return false;
      }

      if (grandParent instanceof PsiTypeElement) {
        PsiElement greatGrandParent = grandParent.getParent();
        if (greatGrandParent instanceof PsiMember ||
            greatGrandParent instanceof PsiReferenceParameterList ||
            greatGrandParent instanceof PsiRecordHeader ||
            greatGrandParent instanceof PsiJavaFile) {
          return false;
        }
      }

      if (JavaKeywordCompletion.isInsideParameterList(element)) {
        return false;
      }

      return !isAfterExpression(element);
    }
private static boolean isExpressionContext(PsiElement element)