Search in sources :

Example 1 with GroovyMethodInfo

use of org.jetbrains.plugins.groovy.extensions.GroovyMethodInfo in project intellij-community by JetBrains.

the class PluginXmlClosureMemberContributor method processMembers.

@Override
public boolean processMembers(GrClosableBlock closure, PsiScopeProcessor processor, GrReferenceExpression refExpr, ResolveState state) {
    PsiElement parent = closure.getParent();
    if (parent instanceof GrArgumentList)
        parent = parent.getParent();
    if (!(parent instanceof GrMethodCall))
        return true;
    PsiMethod psiMethod = ((GrMethodCall) parent).resolveMethod();
    if (psiMethod == null)
        return true;
    List<GroovyMethodInfo> infos = GroovyMethodInfo.getInfos(psiMethod);
    if (infos.isEmpty())
        return true;
    int index = PsiUtil.getArgumentIndex((GrMethodCall) parent, closure);
    if (index == -1)
        return true;
    for (GroovyMethodInfo info : infos) {
        GroovyMethodDescriptor.ClosureArgument[] closureArguments = info.getDescriptor().myClosureArguments;
        if (closureArguments != null) {
            for (GroovyMethodDescriptor.ClosureArgument argument : closureArguments) {
                if (argument.index == index && argument.methodContributor != null) {
                    ClosureMissingMethodContributor instance = SingletonInstancesCache.getInstance(argument.methodContributor, info.getPluginClassLoader());
                    if (!instance.processMembers(closure, processor, refExpr, state))
                        return false;
                }
            }
        }
    }
    return true;
}
Also used : GrMethodCall(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall) GrArgumentList(org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList) PsiMethod(com.intellij.psi.PsiMethod) GroovyMethodDescriptor(org.jetbrains.plugins.groovy.extensions.GroovyMethodDescriptor) PsiElement(com.intellij.psi.PsiElement) GroovyMethodInfo(org.jetbrains.plugins.groovy.extensions.GroovyMethodInfo)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 PsiMethod (com.intellij.psi.PsiMethod)1 GroovyMethodDescriptor (org.jetbrains.plugins.groovy.extensions.GroovyMethodDescriptor)1 GroovyMethodInfo (org.jetbrains.plugins.groovy.extensions.GroovyMethodInfo)1 GrArgumentList (org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList)1 GrMethodCall (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrMethodCall)1