Java 类com.intellij.psi.PsiCallExpression 实例源码

项目:AutoFillingCallArguments    文件:AutoFillCallArguments.java   
@Override
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement psiElement) throws IncorrectOperationException {
    if(psiElement == null) {
        return;
    }
    final PsiCallExpression call = findParent(PsiCallExpression.class, psiElement);
    if(call == null) {
        return;
    }

    final PsiMethod psiMethod = call.resolveMethod();
    if(psiMethod == null) {
        return;
    }
    final PsiParameterList parameterList = psiMethod.getParameterList();
    if(parameterList == null) {
        return;
    }
    final PsiParameter[] params = parameterList.getParameters();
    if(params == null) {
        return;
    }
    String prefix = "";
    int offset = editor.getCaretModel().getOffset();
    final Document doc = editor.getDocument();
    for(final PsiParameter p : params) {
        doc.insertString(offset, prefix+p.getName());
        offset += p.getName().length() + prefix.length();
        prefix = ", ";
    }
    editor.getCaretModel().moveToOffset(offset + 1);
}
项目:intellij-ce-playground    文件:InlineParameterDialog.java   
public InlineParameterDialog(PsiCallExpression methodCall, PsiMethod method, PsiParameter psiParameter, PsiExpression initializer,
                             boolean createLocal) {
  super(method.getProject(), true);
  myMethodCall = methodCall;
  myMethod = method;
  myParameter = psiParameter;
  myInitializer = initializer;
  init();
  myCreateLocalCheckbox.setSelected(createLocal);
  setTitle(InlineParameterHandler.REFACTORING_NAME);
}
项目:tools-idea    文件:InlineParameterDialog.java   
public InlineParameterDialog(PsiCallExpression methodCall, PsiMethod method, PsiParameter psiParameter, PsiExpression initializer,
                             boolean createLocal) {
  super(method.getProject(), true);
  myMethodCall = methodCall;
  myMethod = method;
  myParameter = psiParameter;
  myInitializer = initializer;
  init();
  myCreateLocalCheckbox.setSelected(createLocal);
  setTitle(InlineParameterHandler.REFACTORING_NAME);
}
项目:consulo-java    文件:MethodsProcessor.java   
public void obtainTypeArguments(@NotNull PsiCallExpression callExpression)
{
    final PsiType[] typeArguments = callExpression.getTypeArguments();
    if(typeArguments.length > 0)
    {
        setTypeArguments(typeArguments);
    }
}
项目:consulo-java    文件:JavaInlayParameterHintsProvider.java   
@NotNull
@Override
public List<InlayInfo> getParameterHints(@NotNull PsiElement element)
{
    if(element instanceof PsiCallExpression)
    {
        return ContainerUtil.newArrayList(JavaInlayHintsProvider.createHints((PsiCallExpression) element));
    }
    return Collections.emptyList();
}
项目:consulo-java    文件:JavaInlayParameterHintsProvider.java   
@Nullable
@Override
public MethodInfo getMethodInfo(@NotNull PsiElement element)
{
    if(element instanceof PsiCallExpression)
    {
        PsiElement resolvedElement = ((PsiCallExpression) element).resolveMethodGenerics().getElement();
        if(resolvedElement instanceof PsiMethod)
        {
            return getMethodInfo(resolvedElement);
        }
    }
    return null;
}
项目:consulo-java    文件:MethodCallFixer.java   
@Nullable
private static Integer getUnambiguousParameterCount(PsiCallExpression call)
{
    int argCount = -1;
    for(CandidateInfo candidate : PsiResolveHelper.SERVICE.getInstance(call.getProject()).getReferencedMethodCandidates(call, false))
    {
        PsiElement element = candidate.getElement();
        if(!(element instanceof PsiMethod))
        {
            return null;
        }
        if(((PsiMethod) element).isVarArgs())
        {
            return null;
        }

        int count = ((PsiMethod) element).getParameterList().getParametersCount();
        if(argCount == -1)
        {
            argCount = count;
        }
        else if(argCount != count)
        {
            return null;
        }
    }
    return argCount;
}
项目:consulo-java    文件:VcsContentAnnotationExceptionFilter.java   
@Nullable
private static List<PsiMethod> selectMethod(final PsiMethod[] methods, final Trinity<PsiClass, PsiFile, String> previousLineResult)
{
    if(previousLineResult == null || previousLineResult.getThird() == null)
    {
        return null;
    }

    final List<PsiMethod> result = new SmartList<PsiMethod>();
    for(final PsiMethod method : methods)
    {
        method.accept(new JavaRecursiveElementVisitor()
        {
            @Override
            public void visitCallExpression(PsiCallExpression callExpression)
            {
                final PsiMethod resolved = callExpression.resolveMethod();
                if(resolved != null)
                {
                    if(resolved.getName().equals(previousLineResult.getThird()))
                    {
                        result.add(method);
                    }
                }
            }
        });
    }

    return result;
}
项目:consulo-java    文件:CompletionParameterTypeInferencePolicy.java   
@Override
public PsiType getDefaultExpectedType(PsiCallExpression methodCall)
{
    ExpectedTypeInfo[] expectedTypes = ExpectedTypesProvider.getExpectedTypes(methodCall, true);
    if(expectedTypes.length > 0)
    {
        return expectedTypes[0].getType();
    }
    return PsiType.NULL;
}
项目:consulo-java    文件:InlineParameterDialog.java   
public InlineParameterDialog(PsiCallExpression methodCall, PsiMethod method, PsiParameter psiParameter, PsiExpression initializer,
                             boolean createLocal) {
  super(method.getProject(), true);
  myMethodCall = methodCall;
  myMethod = method;
  myParameter = psiParameter;
  myInitializer = initializer;
  init();
  myCreateLocalCheckbox.setSelected(createLocal);
  setTitle(InlineParameterHandler.REFACTORING_NAME);
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitCallExpression(PsiCallExpression callExpression) {
    mVisitor.report("PsiCallExpression", callExpression.getText(), callExpression);
    super.visitExpression(callExpression);
}
项目:AutoFillingCallArguments    文件:AutoFillCallArguments.java   
@Override
public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement psiElement) {
    PsiCallExpression psiCallExpression = findParent(PsiCallExpression.class, psiElement);
    return psiCallExpression != null && psiCallExpression.resolveMethod() != null;
}
项目:intellij-ce-playground    文件:UnwrapCall.java   
public UnwrapCall(@NotNull PsiCallExpression call, @NotNull String unwrapMethod) {
  super(call);
  myCall = call;
  myUnwrapMethod = unwrapMethod;
}
项目:tools-idea    文件:UnwrapCall.java   
public UnwrapCall(@NotNull PsiCallExpression call, @NotNull String unwrapMethod) {
    super(call);
    this.call =call;
    this.unwrapMethod = unwrapMethod;
}
项目:consulo-java    文件:MethodResolverProcessor.java   
public MethodResolverProcessor(@NotNull PsiCallExpression place, @NotNull PsiExpressionList argumentList, @NotNull PsiFile placeFile)
{
    this(place, placeFile, new PsiConflictResolver[]{new JavaMethodsConflictResolver(argumentList, PsiUtil.getLanguageLevel(placeFile))});
    setArgumentList(argumentList);
    obtainTypeArguments(place);
}
项目:consulo-java    文件:DefaultParameterTypeInferencePolicy.java   
@Nullable
@Override
public Pair<PsiType, ConstraintType> inferTypeConstraintFromCallContext(PsiExpression innerMethodCall, PsiExpressionList parent, PsiCallExpression contextCall, PsiTypeParameter typeParameter)
{
    return null;
}
项目:consulo-java    文件:DefaultParameterTypeInferencePolicy.java   
@Override
public PsiType getDefaultExpectedType(PsiCallExpression methodCall)
{
    return PsiType.getJavaLangObject(methodCall.getManager(), methodCall.getResolveScope());
}
项目:consulo-java    文件:ParameterTypeInferencePolicy.java   
@Nullable
public abstract Pair<PsiType, ConstraintType> inferTypeConstraintFromCallContext(PsiExpression innerMethodCall,
        PsiExpressionList parent,
        PsiCallExpression contextCall,
        PsiTypeParameter typeParameter);
项目:consulo-java    文件:MethodCallFixer.java   
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException
{
    PsiExpressionList args = null;
    if(psiElement instanceof PsiMethodCallExpression/* && !(psiElement instanceof JspMethodCall)*/)
    {
        args = ((PsiMethodCallExpression) psiElement).getArgumentList();
    }
    else if(psiElement instanceof PsiNewExpression)
    {
        args = ((PsiNewExpression) psiElement).getArgumentList();
    }

    if(args != null && !hasRParenth(args))
    {
        int caret = editor.getCaretModel().getOffset();
        PsiCallExpression innermostCall = PsiTreeUtil.findElementOfClassAtOffset(psiElement.getContainingFile(), caret - 1, PsiCallExpression.class, false);
        if(innermostCall == null)
        {
            return;
        }

        args = innermostCall.getArgumentList();
        if(args == null)
        {
            return;
        }

        int endOffset = -1;
        PsiElement child = args.getFirstChild();
        while(child != null)
        {
            if(child instanceof PsiErrorElement)
            {
                final PsiErrorElement errorElement = (PsiErrorElement) child;
                if(errorElement.getErrorDescription().contains("')'"))
                {
                    endOffset = errorElement.getTextRange().getStartOffset();
                    break;
                }
            }
            child = child.getNextSibling();
        }

        if(endOffset == -1)
        {
            endOffset = args.getTextRange().getEndOffset();
        }

        final PsiExpression[] params = args.getExpressions();
        if(params.length > 0 && startLine(editor, args) != startLine(editor, params[0]) && caret < params[0].getTextRange().getStartOffset())
        {
            endOffset = args.getTextRange().getStartOffset() + 1;
        }

        if(!DumbService.isDumb(args.getProject()))
        {
            Integer argCount = getUnambiguousParameterCount(innermostCall);
            if(argCount != null && argCount > 0 && argCount < params.length)
            {
                endOffset = Math.min(endOffset, params[argCount - 1].getTextRange().getEndOffset());
            }
        }

        endOffset = CharArrayUtil.shiftBackward(editor.getDocument().getCharsSequence(), endOffset - 1, " \t\n") + 1;
        editor.getDocument().insertString(endOffset, ")");
    }
}
项目:consulo-java    文件:UnwrapCall.java   
public UnwrapCall(@NotNull PsiCallExpression call, @NotNull String unwrapMethod) {
    super(call);
    this.call =call;
    this.unwrapMethod = unwrapMethod;
}
项目:consulo-java    文件:ParameterTypeInferencePolicy.java   
public abstract PsiType getDefaultExpectedType(PsiCallExpression methodCall);