当前位置: 首页>>代码示例>>Java>>正文


Java JavaElementVisitor类代码示例

本文整理汇总了Java中com.intellij.psi.JavaElementVisitor的典型用法代码示例。如果您正苦于以下问题:Java JavaElementVisitor类的具体用法?Java JavaElementVisitor怎么用?Java JavaElementVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JavaElementVisitor类属于com.intellij.psi包,在下文中一共展示了JavaElementVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitMethod

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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;
    }

}
 
开发者ID:jessie345,项目名称:CustomLintRules,代码行数:27,代码来源:AutoPointLayoutInflaterDetector.java

示例2: visitMethod

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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()");
      }
    }
  }
}
 
开发者ID:seven332,项目名称:Stage,代码行数:20,代码来源:BackHandlerDetector.java

示例3: visitMethod

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:IlyaGulya,项目名称:rxlint,代码行数:17,代码来源:DanglingSubscriptionDetector.java

示例4: buildVisitor

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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 );
        }
      }
    }
  };
}
 
开发者ID:appetizerio,项目名称:appetizer-intellij,代码行数:21,代码来源:ReplaceInspection.java

示例5: visitMethod

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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;
    }
}
 
开发者ID:JumeiRdGroup,项目名称:Android-PLog,代码行数:19,代码来源:LoggingIssueDetector.java

示例6: value

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
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 ];
}
 
开发者ID:apache,项目名称:polygene-java,代码行数:25,代码来源:PolygeneFacetType.java

示例7: createPsiVisitor

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@Override public JavaElementVisitor createPsiVisitor(final JavaContext context) {
  return new JavaElementVisitor() {
    @Override public void visitClass(PsiClass node) {
      node.accept(new R2UsageVisitor(context));
    }
  };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:InvalidR2UsageDetector.java

示例8: visitMethod

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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;
        }
    }
}
 
开发者ID:IlyaGulya,项目名称:rxlint,代码行数:11,代码来源:SubscribeDetector.java

示例9: createPsiVisitor

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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.");
            }
        }
    };
}
 
开发者ID:technoir3,项目名称:retrofit2-lint,代码行数:12,代码来源:UnusedCallObjectDetector.java

示例10: visitMethod

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:bgogetap,项目名称:Scoper,代码行数:9,代码来源:IncorrectChildScopeBuilding.java

示例11: createPsiVisitor

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@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);
        }
    };
}
 
开发者ID:bjoernQ,项目名称:thinr,代码行数:31,代码来源:ThinrDetector.java

示例12: accept

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitDocTag(this);
  }
  else {
    visitor.visitElement(this);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ClsDocTagImpl.java

示例13: accept

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitJavaToken(this);
  }
  else {
    visitor.visitElement(this);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ClsJavaTokenImpl.java

示例14: accept

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitParameterList(this);
  }
  else {
    visitor.visitElement(this);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ClsParameterListImpl.java

示例15: accept

import com.intellij.psi.JavaElementVisitor; //导入依赖的package包/类
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
  if (visitor instanceof JavaElementVisitor) {
    ((JavaElementVisitor)visitor).visitAssertStatement(this);
  }
  else {
    visitor.visitElement(this);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:PsiAssertStatementImpl.java


注:本文中的com.intellij.psi.JavaElementVisitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。