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


Java PsiMethodCallExpression.getArgumentList方法代码示例

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


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

示例1: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  if (!MethodCallUtils.isEqualsCall(expression)) {
    return;
  }
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  final PsiExpression qualifier = methodExpression.getQualifierExpression();
  if (qualifier == null) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  if (arguments.length != 1) {
    return;
  }
  final PsiExpression argument = arguments[0];
  if (!EquivalenceChecker.expressionsAreEquivalent(qualifier, argument) ||
      SideEffectChecker.mayHaveSideEffects(qualifier)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:EqualsWithItselfInspection.java

示例2: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final String methodName = MethodCallUtils.getMethodName(expression);
  if (!HardcodedMethodConstants.TO_STRING.equals(methodName)) {
    return;
  }
  final PsiType targetType = MethodCallUtils.getTargetType(expression);
  if (!TypeUtils.typeEquals(CommonClassNames.JAVA_UTIL_DATE,
                            targetType)) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (argumentList.getExpressions().length != 0) {
    return;
  }
  if (NonNlsUtils.isNonNlsAnnotatedUse(expression)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DateToStringInspection.java

示例3: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  final String name = methodExpression.getReferenceName();
  if (!"setScale".equals(name) && !"divide".equals(name)) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (PsiUtilCore.hasErrorElementChild(argumentList)) {
    return;
  }
  final PsiExpression[] arguments = argumentList.getExpressions();
  if (arguments.length != 1) {
    return;
  }
  if (!TypeUtils.expressionHasTypeOrSubtype(expression, "java.math.BigDecimal")) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:BigDecimalMethodWithoutRoundingCalledInspection.java

示例4: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
/**
 * Check MethodCallExpressions for calls for default (argument less) constructor
 * Produce an error if resolved constructor method is build by lombok and contains some arguments
 */
@Override
public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
  super.visitMethodCallExpression(methodCall);

  PsiExpressionList list = methodCall.getArgumentList();
  PsiReferenceExpression referenceToMethod = methodCall.getMethodExpression();

  boolean isThisOrSuper = referenceToMethod.getReferenceNameElement() instanceof PsiKeyword;
  final int parameterCount = list.getExpressions().length;
  if (isThisOrSuper && parameterCount == 0) {

    JavaResolveResult[] results = referenceToMethod.multiResolve(true);
    JavaResolveResult resolveResult = results.length == 1 ? results[0] : JavaResolveResult.EMPTY;
    PsiElement resolved = resolveResult.getElement();

    if (resolved instanceof LombokLightMethodBuilder && ((LombokLightMethodBuilder) resolved).getParameterList().getParameters().length != 0) {
      holder.registerProblem(methodCall, "Default constructor doesn't exist", ProblemHighlightType.ERROR);
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:25,代码来源:LombokInspection.java

示例5: applyFix

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor)
{
	final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethodCallExpression.class);
	if(methodCallExpression != null)
	{
		ExpressionUtils.bindCallTo(methodCallExpression, myTargetMethodName);
		if(myClearArguments)
		{
			PsiExpressionList argList = methodCallExpression.getArgumentList();
			PsiExpression[] args = argList.getExpressions();
			if(args.length > 0)
			{
				argList.deleteChildRange(args[0], args[args.length - 1]);
			}
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:DfaOptionalSupport.java

示例6: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
  if (passed) {
    return;
  }
  super.visitMethodCallExpression(call);
  final PsiExpressionList argumentList = call.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  for (PsiExpression argument : arguments) {
    if (!VariableAccessUtils.mayEvaluateToVariable(argument, variable, myBuilderPattern)) {
      continue;
    }
    final PsiMethod method = call.resolveMethod();
    if (method != null) {
      final PsiClass aClass = method.getContainingClass();
      if (aClass != null) {
        final String name = aClass.getQualifiedName();
        if (excludes.contains(name)) {
          continue;
        }
      }
    }
    passed = true;
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:VariablePassedAsArgumentExcludedVisitor.java

示例7: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  @NonNls final String methodName = methodExpression.getReferenceName();
  if (methodName == null) {
    return;
  }
  final boolean resultSet;
  if (methodName.startsWith("get") || methodName.startsWith("update")) {
    resultSet = true;
  } else if (methodName.startsWith("set")) {
    resultSet = false;
  } else {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  if (arguments.length == 0) {
    return;
  }
  final PsiExpression argument = arguments[0];
  final Object val = ExpressionUtils.computeConstantExpression(argument);
  if (!(val instanceof Integer) || ((Integer)val).intValue() != 0) {
    return;
  }
  final PsiExpression qualifier = methodExpression.getQualifierExpression();
  if (resultSet) {
    if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.ResultSet")) {
      registerError(argument, Boolean.TRUE);
    }
  } else if (arguments.length > 1) {
    if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.PreparedStatement")) {
      registerError(argument, Boolean.FALSE);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:ResultSetIndexZeroInspection.java

示例8: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression call) {
  super.visitMethodCallExpression(call);
  if (!MethodCallUtils.isEqualsCall(call)) {
    return;
  }
  final PsiExpressionList argumentList = call.getArgumentList();
  final PsiExpression[] args = argumentList.getExpressions();
  if (args.length == 0 || !ExpressionUtils.isNullLiteral(args[0])) {
    return;
  }
  registerError(args[0]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:ObjectEqualsNullInspection.java

示例9: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  @NonNls final String methodName = methodExpression.getReferenceName();
  if (methodName == null) {
    return;
  }
  final boolean resultSet;
  if (methodName.startsWith("get") || methodName.startsWith("update")) {
    resultSet = true;
  } else if (methodName.startsWith("set")) {
    resultSet = false;
  } else {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  if (arguments.length == 0) {
    return;
  }
  final PsiExpression argument = arguments[0];
  final Object val = ExpressionUtils.computeConstantExpression(argument);
  if (!(val instanceof Integer) || ((Integer)val).intValue() != 0) {
    return;
  }
  final PsiExpression qualifier = methodExpression.getQualifierExpression();
  if (resultSet) {
    if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.ResultSet")) {
      registerError(argument, Boolean.valueOf(resultSet));
    }
  } else {
    if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.PreparedStatement")) {
      registerError(argument, Boolean.valueOf(resultSet));
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:38,代码来源:ResultSetIndexZeroInspection.java

示例10: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final String methodName = MethodCallUtils.getMethodName(expression);
  if (!HardcodedMethodConstants.PRINT_STACK_TRACE.equals(
    methodName)) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (argumentList.getExpressions().length != 0) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:ThrowablePrintStackTraceInspection.java

示例11: visitMethodCallExpression

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
  if (passed) {
    return;
  }
  super.visitMethodCallExpression(call);
  final PsiExpressionList argumentList = call.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  for (PsiExpression argument : arguments) {
    if (VariableAccessUtils.mayEvaluateToVariable(argument, variable)) {
      passed = true;
      break;
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:16,代码来源:VariablePassedAsArgumentVisitor.java

示例12: processIntention

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
public void processIntention(PsiElement element)
  throws IncorrectOperationException {
  final PsiMethodCallExpression call =
    (PsiMethodCallExpression)element;
  final PsiReferenceExpression methodExpression =
    call.getMethodExpression();
  final String methodName = methodExpression.getReferenceName();
  final PsiExpression target = methodExpression.getQualifierExpression();
  if (target == null) {
    return;
  }
  final PsiExpressionList argumentList = call.getArgumentList();
  final PsiExpression arg = argumentList.getExpressions()[0];
  final PsiExpression strippedTarget =
    ParenthesesUtils.stripParentheses(target);
  if (strippedTarget == null) {
    return;
  }
  final PsiExpression strippedArg =
    ParenthesesUtils.stripParentheses(arg);
  if (strippedArg == null) {
    return;
  }
  final String callString;
  if (ParenthesesUtils.getPrecedence(strippedArg) >
      ParenthesesUtils.METHOD_CALL_PRECEDENCE) {
    callString = '(' + strippedArg.getText() + ")." + methodName + '(' +
                 strippedTarget.getText() + ')';
  }
  else {
    callString = strippedArg.getText() + '.' + methodName + '(' +
                 strippedTarget.getText() + ')';
  }
  replaceExpression(callString, call);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:36,代码来源:FlipCommutativeMethodCallIntention.java

示例13: MethodResolverProcessor

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
public MethodResolverProcessor(@NotNull PsiMethodCallExpression place, @NotNull PsiFile placeFile)
{
	this(place, place.getArgumentList(), placeFile);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:5,代码来源:MethodResolverProcessor.java

示例14: processIntention

import com.intellij.psi.PsiMethodCallExpression; //导入方法依赖的package包/类
public void processIntention(PsiElement element)
  throws IncorrectOperationException {
  final PsiMethodCallExpression call =
    (PsiMethodCallExpression)element;
  if (call == null) {
    return;
  }
  final PsiReferenceExpression methodExpression =
    call.getMethodExpression();
  final PsiExpression target = methodExpression.getQualifierExpression();
  if (target == null) {
    return;
  }
  final PsiExpressionList argumentList = call.getArgumentList();
  final PsiExpression arg = argumentList.getExpressions()[0];
  final PsiExpression strippedTarget =
    ParenthesesUtils.stripParentheses(target);
  if (strippedTarget == null) {
    return;
  }
  final PsiExpression strippedArg =
    ParenthesesUtils.stripParentheses(arg);
  if (strippedArg == null) {
    return;
  }
  final String strippedArgText;
  if (ParenthesesUtils.getPrecedence(strippedArg) >
      ParenthesesUtils.EQUALITY_PRECEDENCE) {
    strippedArgText = '(' + strippedArg.getText() + ')';
  }
  else {
    strippedArgText = strippedArg.getText();
  }
  final String strippedTargetText;
  if (ParenthesesUtils.getPrecedence(strippedTarget) >
      ParenthesesUtils.EQUALITY_PRECEDENCE) {
    strippedTargetText = '(' + strippedTarget.getText() + ')';
  }
  else {
    strippedTargetText = strippedTarget.getText();
  }
  replaceExpression(strippedTargetText + "==" + strippedArgText, call);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:44,代码来源:ReplaceEqualsWithEqualityIntention.java


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