本文整理汇总了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;
}
}
示例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()");
}
}
}
}
示例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);
}
}
}
示例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 );
}
}
}
};
}
示例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;
}
}
示例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 ];
}
示例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));
}
};
}
示例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;
}
}
}
示例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.");
}
}
};
}
示例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");
}
}
示例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);
}
};
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}