Java 类com.intellij.psi.JavaElementVisitor 实例源码

项目:CustomLintRules    文件:AutoPointLayoutInflaterDetector.java   
@Override
public void visitMethod(@NonNull JavaContext context, @Nullable JavaElementVisitor visitor,
                        @NonNull PsiMethodCallExpression node, @NonNull PsiMethod method) {

    boolean isLayoutInflaterCall = isLayoutInflaterCall(context, node, method);
    boolean isViewInflateCall = isInViewCall(context, node, method);

    String name = method.getName();
    boolean fromMethod = LAYOUTINFLATER_FROM.equals(name);
    boolean viewInflateMethod = VIEW_INFLATE.equals(name);

    if (isLayoutInflaterCall && fromMethod) {

        context.report(ISSUE_LAYOUTINFLATER, node, context.getLocation(node),
                "error use system LayoutInflater,should use LayoutInflaterWrapper.");
        return;
    }

    if (viewInflateMethod && isViewInflateCall) {

        context.report(ISSUE_VIEW_INFLATE, node, context.getLocation(node),
                "error use View.inflate(),should use LayoutInflaterWrapper.inflate.");
        return;
    }

}
项目:Stage    文件:BackHandlerDetector.java   
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor,
    PsiMethodCallExpression call, PsiMethod method) {
  JavaEvaluator evaluator = context.getEvaluator();
  if (evaluator.getParameterCount(method) == 0) {
    PsiMethod parent = PsiTreeUtil.getParentOfType(call, PsiMethod.class);
    if (parent != null) {
      if (evaluator.isMemberInClass(method, CLASS_DIRECTOR) &&
          evaluator.isMemberInSubClassOf(parent, CLASS_DIRECTOR_BACK_HANDLER, false)) {
        context.report(ISSUE, call, context.getLocation(call),
            "Can't call Stage.handleBack() in Stage.BackHandler.handleBack()");
      } else if (evaluator.isMemberInClass(method, CLASS_STAGE) &&
          evaluator.isMemberInSubClassOf(parent, CLASS_STAGE_BACK_HANDLER, false)) {
        context.report(ISSUE, call, context.getLocation(call),
            "Can't call Director.handleBack() in Director.BackHandler.handleBack()");
      }
    }
  }
}
项目:rxlint    文件:DanglingSubscriptionDetector.java   
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor, PsiMethodCallExpression call, PsiMethod method) {
    super.visitMethod(context, visitor, call, method);
    if (isRxSubscribeableClass(method.getContainingClass()) && !PsiType.VOID.equals(method.getReturnType())) {
        PsiElement element = LintUtils.skipParentheses(call.getParent());
        if (element instanceof PsiExpressionStatement) {
            String message;
            if (isRx2(method.getContainingClass())) {
                message = "No reference to the disposable is kept";
            } else {
                message = "No reference to the subscription is kept";
            }
            context.report(ISSUE, call, context.getLocation(call), message);
        }
    }
}
项目:appetizer-intellij    文件:ReplaceInspection.java   
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
  return new JavaElementVisitor() {
    @Override
    public void visitReferenceExpression(PsiReferenceExpression psiReferenceExpression) {
    }

    @Override
    public void visitLocalVariable(PsiLocalVariable variable) {
      super.visitLocalVariable(variable);
      if (VariantPool.isJump()) {
        if (isFindYYY(variable.toString())) {
          holder.registerProblem(variable, DESCRIPTION_TEMPLATE, myQuickFix);
          log.info("isFindYYY" + variable );
        }
      }
    }
  };
}
项目:Android-PLog    文件:LoggingIssueDetector.java   
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor,
                        PsiMethodCallExpression call, PsiMethod method) {
    PsiReferenceExpression methodExpression = call.getMethodExpression();
    String fullyQualifiedMethodName = methodExpression.getQualifiedName();

    if (fullyQualifiedMethodName.startsWith("android.util.Log")
            //Handle multiple overloaded out.print(and println, etc) methods.
            || fullyQualifiedMethodName.startsWith("java.lang.System.out.print")) {
        sHelper.reportIssue(context, ISSUE_LOG_CLASS, methodExpression);
        return;
    }

    if (fullyQualifiedMethodName.equals("java.lang.String.format")) {
        checkNestedStringFormat(context, call);
        return;
    }
}
项目:polygene-java    文件:PolygeneFacetType.java   
public final boolean value( PsiFile psiFile )
{
    final boolean[] hasPolygeneImportPackage = new boolean[]{ false };

    psiFile.accept( new JavaElementVisitor()
    {
        @Override
        public final void visitImportStatement( PsiImportStatement statement )
        {
            String packageName = statement.getQualifiedName();
            if( packageName != null && packageName.startsWith( "org.apache.polygene" ) )
            {
                hasPolygeneImportPackage[ 0 ] = true;
            }
        }

        @Override
        public void visitReferenceExpression( PsiReferenceExpression expression )
        {
            // Ignore
        }
    } );
    return hasPolygeneImportPackage[ 0 ];
}
项目:GitHub    文件:InvalidR2UsageDetector.java   
@Override public JavaElementVisitor createPsiVisitor(final JavaContext context) {
  return new JavaElementVisitor() {
    @Override public void visitClass(PsiClass node) {
      node.accept(new R2UsageVisitor(context));
    }
  };
}
项目:rxlint    文件:SubscribeDetector.java   
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor, PsiMethodCallExpression call, PsiMethod method) {
    super.visitMethod(context, visitor, call, method);
    for (SubscriberCheck check : CHECKS) {
        if (check.isMissingOnError(method)) {
            context.report(ISSUE, call, context.getLocation(call), "Subscriber is missing onError");
            return;
        }
    }
}
项目:retrofit2-lint    文件:UnusedCallObjectDetector.java   
@Override
public JavaElementVisitor createPsiVisitor(JavaContext context) {
    return new JavaElementVisitor() {
        @Override
        public void visitMethodCallExpression(PsiMethodCallExpression node) {
            if (isRetrofitEndpoint(node.resolveMethod()) && !isCallResultUsed(node)) {
                context.report(ISSUE, context.getLocation(node), "Call object was created but never used.");
            }
        }
    };
}
项目:Scoper    文件:IncorrectChildScopeBuilding.java   
@Override
public void visitMethod(JavaContext context, JavaElementVisitor visitor, PsiMethodCallExpression call, PsiMethod method) {
    super.visitMethod(context, visitor, call, method);
    PsiElement errorLocation = isBuildingChildScope(call);
    if (errorLocation != null) {
        context.report(INCORRECT_CHILD_SCOPE_BUILDING, context.getLocation(errorLocation), "Scoper pattern error");
    }
}
项目:thinr    文件:ThinrDetector.java   
@Override
public JavaElementVisitor createPsiVisitor(@NonNull final JavaContext context) {
    return new JavaElementVisitor() {
        @Override
        public void visitLambdaExpression(PsiLambdaExpression expression) {

            if (!(expression.getParent() instanceof PsiExpressionList)) {
                return;
            }

            PsiExpressionList exprList = (PsiExpressionList) expression.getParent();
            if (!(exprList.getParent() instanceof PsiMethodCallExpression)) {
                return;
            }
            PsiMethodCallExpression call = (PsiMethodCallExpression) exprList.getParent();

            if (call.getType() == null) {
                return;
            }

            String callType = call.getType().getCanonicalText();

            if (!callType.startsWith("de.mobilej.thinr.Thinr")) {
                return;
            }

            markLeakSuspects(expression, expression, context);
        }
    };
}
项目:intellij-ce-playground    文件:ClsDocTagImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitDocTag(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:ClsJavaTokenImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitJavaToken(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:ClsParameterListImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitParameterList(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiAssertStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitAssertStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiReturnStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitReturnStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiBlockStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitBlockStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiEmptyStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor){
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitEmptyStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiEmptyExpressionImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitExpression(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiAnnotationParamListImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitAnnotationParameterList(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiExpressionListStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitExpressionListStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiJavaTokenImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitJavaToken(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiKeywordImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor){
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitKeyword(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiThrowStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitThrowStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiInlineDocTagImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitInlineDocTag(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiDocTokenImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitDocToken(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:CorePsiDocTagValueImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitDocTagValue(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:PsiParameterListImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor){
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitParameterList(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:intellij-ce-playground    文件:EmptyIntentionInspectionQuickFixTest.java   
@NotNull
@Override
protected LocalInspectionTool[] configureLocalInspectionTools() {
  return new LocalInspectionTool[]{new DefUseInspection(), new LocalInspectionTool() {
    @Override
    @Nls
    @NotNull
    public String getGroupDisplayName() {
      return "MyGroup";
    }

    @Override
    @Nls
    @NotNull
    public String getDisplayName() {
      return "My";
    }

    @Override
    @NonNls
    @NotNull
    public String getShortName() {
      return getDisplayName();
    }

    @Override
    @NotNull
    public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
      return new JavaElementVisitor() {
        @Override public void visitLiteralExpression(PsiLiteralExpression expression) {
          final String s = (String)expression.getValue();
          if (s.contains("a")) holder.registerProblem(expression, "Look ma! This String contains 'a'");
          if (s.contains("b")) holder.registerProblem(expression, "Look ma! This String contains 'b'");
        }
      };
    }
  }};
}
项目:mparticle-android-sdk    文件:MpApiDetector.java   
public JavaElementVisitor createPsiVisitor(final JavaContext context) {
    return new JavaElementVisitor() {
        public void visitMethod(PsiMethod method) {
            visitMethodDefinition(context, method);
        }
    };
}
项目:tools-idea    文件:ClsDocTagImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitDocTag(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:ClsParameterListImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitParameterList(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:PsiAssertStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitAssertStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:PsiReturnStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitReturnStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:PsiBlockStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitBlockStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:PsiEmptyStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor){
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitEmptyStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:PsiEmptyExpressionImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitExpression(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:PsiExpressionListStatementImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitExpressionListStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:PsiArrayInitializerMemberValueImpl.java   
@Override
public final void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitAnnotationArrayInitializer(this);
  }
  else {
    visitor.visitElement(this);
  }
}
项目:tools-idea    文件:PsiJavaTokenImpl.java   
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitJavaToken(this);
  }
  else {
    visitor.visitElement(this);
  }
}