public JavaCompletionProcessor(
      PsiElement element,
      ElementFilter filter,
      final boolean checkAccess,
      boolean checkInitialized,
      boolean filterStaticAfterInstance,
      @Nullable Condition<String> nameCondition) {
    myCheckAccess = checkAccess;
    myResults = new ArrayList<CompletionElement>();
    myElement = element;
    myMatcher = nameCondition;
    myFilter = filter;
    PsiElement scope = element;
    if (JavaResolveUtil.isInJavaDoc(myElement)) myMembersFlag = true;
    while (scope != null && !(scope instanceof PsiFile) && !(scope instanceof PsiClass)) {
      scope = scope.getContext();
    }
    myScope = scope;
    if (!(element.getContainingFile() instanceof PsiJavaFile)) {
      myMembersFlag = true;
    }

    PsiElement elementParent = element.getContext();
    if (elementParent instanceof PsiReferenceExpression) {
      PsiExpression qualifier = ((PsiReferenceExpression) elementParent).getQualifierExpression();
      if (qualifier instanceof PsiSuperExpression) {
        final PsiJavaCodeReferenceElement qSuper = ((PsiSuperExpression) qualifier).getQualifier();
        if (qSuper == null) {
          myQualifierClass = JavaResolveUtil.getContextClass(myElement);
        } else {
          final PsiElement target = qSuper.resolve();
          myQualifierClass = target instanceof PsiClass ? (PsiClass) target : null;
        }
        if (myQualifierClass != null) {
          myQualifierType =
              JavaPsiFacade.getInstance(element.getProject())
                  .getElementFactory()
                  .createType(myQualifierClass);
        }
      } else if (qualifier != null) {
        myQualifierType = qualifier.getType();
        myQualifierClass = PsiUtil.resolveClassInType(myQualifierType);
        if (myQualifierType == null && qualifier instanceof PsiJavaCodeReferenceElement) {
          final PsiElement target = ((PsiJavaCodeReferenceElement) qualifier).resolve();
          if (target instanceof PsiClass) {
            myQualifierClass = (PsiClass) target;
          }
        }
      }
    }

    if (checkInitialized) {
      myNonInitializedFields.addAll(getNonInitializedFields(element));
    }

    myAllowStaticWithInstanceQualifier =
        !filterStaticAfterInstance
            || CodeInsightSettings.getInstance().SHOW_STATIC_AFTER_INSTANCE
            || SuppressManager.getInstance()
                .isSuppressedFor(element, AccessStaticViaInstance.ACCESS_STATIC_VIA_INSTANCE);
  }
Ejemplo n.º 2
0
 protected boolean use15Suppressions(final PsiDocCommentOwner container) {
   return SuppressManager.getInstance().canHave15Suppressions(container)
       && !SuppressManager.getInstance().alreadyHas14Suppressions(container);
 }