Search in sources :

Example 11 with GrClosureType

use of org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType in project intellij-community by JetBrains.

the class GroovyParameterInfoHandler method showParameterInfo.

@Override
@SuppressWarnings("unchecked")
public void showParameterInfo(@NotNull GroovyPsiElement place, @NotNull CreateParameterInfoContext context) {
    GroovyResolveResult[] variants = ResolveUtil.getCallVariants(place);
    final List elementToShow = new ArrayList();
    final PsiElement parent = place.getParent();
    if (parent instanceof GrMethodCall) {
        final GrExpression invoked = ((GrMethodCall) parent).getInvokedExpression();
        if (isPropertyOrVariableInvoked(invoked)) {
            final PsiType type = invoked.getType();
            if (type instanceof GrClosureType) {
                addSignatureVariant(elementToShow, (GrClosureType) type);
            } else if (type != null) {
                addMethodAndClosureVariants(elementToShow, ResolveUtil.getMethodCandidates(type, "call", invoked, PsiUtil.getArgumentTypes(place, true)));
            }
        } else {
            addMethodAndClosureVariants(elementToShow, variants);
        }
    } else {
        elementToShow.addAll(Arrays.asList(variants));
    }
    filterOutReflectedMethods(elementToShow);
    context.setItemsToShow(ArrayUtil.toObjectArray(elementToShow));
    context.showHint(place, place.getTextRange().getStartOffset(), this);
}
Also used : GroovyResolveResult(org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult) GrMethodCall(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall) GrArgumentList(org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList) GrExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression) GroovyPsiElement(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement) GrClosureType(org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType)

Aggregations

GrClosureType (org.jetbrains.plugins.groovy.lang.psi.impl.GrClosureType)11 Nullable (org.jetbrains.annotations.Nullable)6 GrSignature (org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrSignature)6 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)6 GroovyPsiElement (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement)4 GroovyResolveResult (org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult)4 MethodSignature (com.intellij.psi.util.MethodSignature)3 GrClosureSignature (org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrClosureSignature)2 GrArgumentList (org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList)2 GrMethodCall (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall)2 GrReferenceExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression)2 GrAccessorMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrAccessorMethod)2 PsiElement (com.intellij.psi.PsiElement)1 ConflictsDialog (com.intellij.refactoring.ui.ConflictsDialog)1 HashSet (com.intellij.util.containers.HashSet)1 MultiMap (com.intellij.util.containers.MultiMap)1 NotNull (org.jetbrains.annotations.NotNull)1 GroovyPsiElementFactory (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory)1 GrRecursiveSignatureVisitor (org.jetbrains.plugins.groovy.lang.psi.api.signatures.GrRecursiveSignatureVisitor)1 GrField (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrField)1