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


Java PsiMethodCallExpression类代码示例

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


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

示例1: visitMethod

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的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.PsiMethodCallExpression; //导入依赖的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.PsiMethodCallExpression; //导入依赖的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: findArgPos

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
private int findArgPos( PsiMethodCallExpression methodCall, PsiElement firstElem )
{
  PsiExpression[] args = methodCall.getArgumentList().getExpressions();
  for( int i = 0; i < args.length; i++ )
  {
    PsiExpression arg = args[i];
    PsiElement csr = firstElem;
    while( csr != null && csr != firstElem )
    {
      csr = csr.getParent();
    }
    if( csr == firstElem )
    {
      return i;
    }
  }
  throw new IllegalStateException();
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:19,代码来源:ManHighlightInfoFilter.java

示例5: isBuildingChildScope

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
private PsiElement isBuildingChildScope(PsiMethodCallExpression call) {
    try {
        // Dot
        PsiElement nextSibling = call.getNextSibling();
        // Parenthesis
        nextSibling = nextSibling.getNextSibling();
        // Chained method name
        nextSibling = nextSibling.getParent();
        // Chained method
        PsiElement chainedMethod = nextSibling.getParent();
        if (chainedMethod instanceof PsiMethodCallExpression) {
            PsiExpressionList list = ((PsiMethodCallExpression) chainedMethod).getArgumentList();
            // If chained method is taking an argument that returns an instance of something
            // (such as a new Module), it is probably safe to assume that the user is building a
            // child scope
            if (list.getFirstChild() != null
                    && list.getFirstChild().getNextSibling() instanceof PsiNewExpression) {
                return chainedMethod;
            }
        }
    } catch (Exception e) {
        // A for effort
    }
    return null;
}
 
开发者ID:bgogetap,项目名称:Scoper,代码行数:26,代码来源:IncorrectChildScopeBuilding.java

示例6: checkNestedStringFormat

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
/**
 * Reports issue if this call is inside PLog.x().
 * Calling this method assumes actual calling method is 'String#format'.
 *
 * @see #ISSUE_NESTED_FORMAT
 */
private static void checkNestedStringFormat(JavaContext context, PsiMethodCallExpression call) {
    PsiElement current = call;
    while (true) {
        current = LintUtils.skipParentheses(current.getParent());
        if (current == null || current instanceof PsiCodeBlock) {
            // Reached AST root or code block node; String.format not inside PLog.X(..).
            return;
        }
        if (current instanceof PsiMethodCallExpression) {
            PsiMethodCallExpression expression = (PsiMethodCallExpression) current;
            if (Pattern.matches("org\\.mym\\.plog\\.PLog\\.(v|d|i|w|e)",
                    expression.getMethodExpression().getQualifiedName())) {
                sHelper.reportIssue(context, ISSUE_NESTED_FORMAT, call);
                return;
            }
        }
    }
}
 
开发者ID:JumeiRdGroup,项目名称:Android-PLog,代码行数:25,代码来源:LoggingIssueDetector.java

示例7: visitMethod

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的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

示例8: findJavaElement

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
/**
 * Further refine search in order to match the exact Java Camel route.
 * Checks if the given {@link PsiElement} contains a 'to' method that points to the give route.
 *
 * @param route      the complete Camel route to search for
 * @param psiElement the {@link PsiElement} that might contain the complete route definition
 * @return the {@link PsiElement} that contains the exact match of the Camel route, null if there is no exact match
 */
private PsiElement findJavaElement(String route, PsiElement psiElement) {
    Object value;
    if (psiElement instanceof PsiLiteralValue) {
        value = ((PsiLiteralValue) psiElement).getValue();
    } else {
        value = psiElement.getText();
    }
    if (route.equals(value)) {
        //the method 'to' is a PsiIdentifier not a PsiMethodCallExpression because it's part of method invocation chain
        PsiMethodCallExpression methodCall = PsiTreeUtil.getParentOfType(psiElement, PsiMethodCallExpression.class);
        if (methodCall != null) {
            if (Arrays.stream(JAVA_ROUTE_CALL).anyMatch(s -> s.equals(methodCall.getMethodExpression().getReferenceName()))) {
                return psiElement;
            }
        }
    }
    return null;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:27,代码来源:CamelRouteLineMarkerProvider.java

示例9: withArguments

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
public PsiMethodCallPattern withArguments(final ElementPattern<? extends PsiExpression>... arguments) {
  return with(new PatternCondition<PsiMethodCallExpression>("withArguments") {
    @Override
    public boolean accepts(@NotNull PsiMethodCallExpression callExpression, ProcessingContext context) {
      final PsiExpression[] actualArguments = callExpression.getArgumentList().getExpressions();
      if (arguments.length != actualArguments.length) {
        return false;
      }
      for (int i = 0; i < actualArguments.length; i++) {
        if (!arguments[i].accepts(actualArguments[i], context)) {
          return false;
        }
      }
      return true;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiMethodCallPattern.java

示例10: getElement

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
protected PsiElement getElement() {
  if (!myReferenceExpression.isValid() || !myReferenceExpression.getManager().isInProject(myReferenceExpression)) return null;

  PsiElement parent = myReferenceExpression.getParent();

  if (parent instanceof PsiMethodCallExpression) return null;

  if (myReferenceExpression.getReferenceNameElement() != null) {
    if (!CreateFromUsageUtils.isValidReference(myReferenceExpression, false)) {
      return myReferenceExpression;
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:CreateVarFromUsageFix.java

示例11: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  if (!MethodCallUtils.isCallToMethod(expression, null, PsiType.VOID,
                                      HardcodedMethodConstants.FINALIZE)) {
    return;
  }
  final PsiMethod containingMethod =
    PsiTreeUtil.getParentOfType(expression, PsiMethod.class);
  if (containingMethod == null) {
    return;
  }
  if (MethodUtils.methodMatches(containingMethod, null, PsiType.VOID,
                                HardcodedMethodConstants.FINALIZE)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:NoExplicitFinalizeCallsInspection.java

示例12: isSetSecurityManager

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
private static boolean isSetSecurityManager(
  PsiMethodCallExpression expression) {
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  @NonNls final String methodName =
    methodExpression.getReferenceName();
  if (!"setSecurityManager".equals(methodName)) {
    return false;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return false;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return false;
  }
  final String className = aClass.getQualifiedName();
  if (className == null) {
    return false;
  }
  return "java.lang.System".equals(className);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:SystemSetSecurityManagerInspection.java

示例13: isDriverManagerGetConnection

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
private static boolean isDriverManagerGetConnection(
  PsiMethodCallExpression expression) {
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();

  final String methodName = methodExpression.getReferenceName();
  if (!HardcodedMethodConstants.GET_CONNECTION.equals(methodName)) {
    return false;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return false;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return false;
  }
  final String className = aClass.getQualifiedName();
  if (className == null) {
    return false;
  }
  return "java.sql.DriverManager".equals(className);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DriverManagerGetConnectionInspection.java

示例14: isResourceCreation

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
protected boolean isResourceCreation(PsiExpression expression) {
  if (expression instanceof PsiMethodCallExpression) {
    final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
    final PsiReferenceExpression methodExpression = methodCallExpression.getMethodExpression();
    @NonNls final String methodName = methodExpression.getReferenceName();
    if (!"accept".equals(methodName)) {
      return false;
    }
    final PsiExpression qualifier = methodExpression.getQualifierExpression();
    if (qualifier == null || !TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.net.ServerSocket")) {
      return false;
    }
    return TypeUtils.expressionHasTypeOrSubtype(methodCallExpression, "java.net.Socket");
  }
  else if (expression instanceof PsiNewExpression) {
    return TypeUtils.expressionHasTypeOrSubtype(expression, "java.net.Socket", "java.net.DatagramSocket", "java.net.ServerSocket") != null;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:SocketResourceInspection.java

示例15: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  final String methodName = methodExpression.getReferenceName();
  @NonNls final String exec = "exec";
  if (!exec.equals(methodName)) {
    return;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  final String className = aClass.getQualifiedName();
  if (!"java.lang.Runtime".equals(className)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:RuntimeExecInspection.java


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