void (@NotNull PsiMethodCallExpression expression) { if (LOG.isDebugEnabled()) { LOG.debug("visitMethodCallExpression " + expression); } final PsiExpressionList argumentList = expression.getArgumentList(); final PsiExpression[] argExpressions = argumentList.getExpressions(); Evaluator[] argumentEvaluators = new Evaluator[argExpressions.length]; // evaluate arguments for (int idx = 0; idx < argExpressions.length; idx++) { final PsiExpression psiExpression = argExpressions[idx]; psiExpression.accept(this); if (myResult == null) { // cannot build evaluator throw expressionInvalid(psiExpression); } argumentEvaluators[idx] = DisableGC.create(myResult); } PsiReferenceExpression methodExpr = expression.getMethodExpression(); final JavaResolveResult resolveResult = methodExpr.advancedResolve(false); final PsiMethod psiMethod = CompilingEvaluatorTypesUtil.getReferencedMethod(resolveResult); PsiExpression qualifier = methodExpr.getQualifierExpression(); Evaluator objectEvaluator; JVMName contextClass = null; if (psiMethod != null) { PsiClass methodPsiClass = psiMethod.getContainingClass(); contextClass = JVMNameUtil.getJVMQualifiedName(methodPsiClass); if (psiMethod.hasModifierProperty(PsiModifier.STATIC)) { objectEvaluator = new TypeEvaluator(contextClass); } else if (qualifier != null) { qualifier.accept(this); objectEvaluator = myResult; } else { CaptureTraverser traverser = CaptureTraverser.direct(); PsiElement currentFileResolveScope = resolveResult.getCurrentFileResolveScope(); if (currentFileResolveScope instanceof PsiClass) { traverser = createTraverser(currentFileResolveScope, ((PsiClass)currentFileResolveScope).getName(), false); } objectEvaluator = new ThisEvaluator(traverser); } } else { //trying to guess if (qualifier != null) { PsiType type = qualifier.getType(); if (type != null) { contextClass = JVMNameUtil.getJVMQualifiedName(type); } if (qualifier instanceof PsiReferenceExpression && ((PsiReferenceExpression)qualifier).resolve() instanceof PsiClass) { // this is a call to a 'static' method but class is not available, try to evaluate by qname if (contextClass == null) { contextClass = JVMNameUtil.getJVMRawText(((PsiReferenceExpression)qualifier).getQualifiedName()); } objectEvaluator = new TypeEvaluator(contextClass); } else { qualifier.accept(this); objectEvaluator = myResult; } } else { objectEvaluator = new ThisEvaluator(); PsiClass positionClass = getPositionClass(); if (positionClass != null) { contextClass = JVMNameUtil.getJVMQualifiedName(positionClass); } //else { // throw new EvaluateRuntimeException(EvaluateExceptionUtil.createEvaluateException( // JavaDebuggerBundle.message("evaluation.error.method.not.found", methodExpr.getReferenceName())) // ); //} } } if (objectEvaluator == null) { throw expressionInvalid(expression); } if (psiMethod != null && !psiMethod.isConstructor()) { if (psiMethod.getReturnType() == null) { throw evaluateException(JavaDebuggerBundle.message("evaluation.error.unknown.method.return.type", psiMethod.getText())); } } boolean mustBeVararg = false; if (psiMethod != null) { processBoxingConversions(psiMethod.getParameterList().getParameters(), argExpressions, resolveResult.getSubstitutor(), argumentEvaluators); mustBeVararg = psiMethod.isVarArgs(); } myResult = new MethodEvaluator(objectEvaluator, contextClass, methodExpr.getReferenceName(), psiMethod != null ? JVMNameUtil.getJVMSignature(psiMethod) : null, argumentEvaluators, mustBeVararg); }