Search in sources :

Example 6 with GrLightParameter

use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightParameter in project android by JetBrains.

the class AndroidDslContributor method findAndProcessContributingMethod.

@Nullable
private static PsiMethod findAndProcessContributingMethod(String symbol, PsiScopeProcessor processor, ResolveState state, PsiElement place, PsiClass contributorClass) {
    PsiMethod method = getContributingMethod(place, contributorClass, symbol);
    if (method == null) {
        return null;
    }
    ParametrizedTypeExtractor typeExtractor = getTypeExtractor(method);
    if (typeExtractor != null && !typeExtractor.hasNamedDomainObjectContainer() && typeExtractor.isClosure()) {
        // method takes a closure argument
        String clz = typeExtractor.getClosureType();
        if (clz == null) {
            clz = CommonClassNames.JAVA_LANG_OBJECT;
        }
        if (ourDslForClassMap.containsKey(clz)) {
            clz = ourDslForClassMap.get(clz);
        }
        resolveToMethodWithClosure(place, method, clz, processor, state);
    } else {
        GrLightMethodBuilder builder = new GrLightMethodBuilder(place.getManager(), method.getName());
        PsiElementFactory factory = JavaPsiFacade.getElementFactory(place.getManager().getProject());
        PsiType type = new PsiArrayType(factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_OBJECT, place.getResolveScope()));
        builder.addParameter(new GrLightParameter("param", type, builder));
        PsiClassType retType = factory.createTypeByFQClassName(CommonClassNames.JAVA_LANG_OBJECT, place.getResolveScope());
        builder.setReturnType(retType);
        processor.execute(builder, state);
        builder.setNavigationElement(method);
    }
    return method;
}
Also used : GrLightParameter(org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightParameter) GrLightMethodBuilder(org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

GrLightParameter (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightParameter)6 GrParameter (org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameter)3 Nullable (org.jetbrains.annotations.Nullable)2 GrLightMethodBuilder (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder)2 NotNull (org.jetbrains.annotations.NotNull)1 GroovyFile (org.jetbrains.plugins.groovy.lang.psi.GroovyFile)1 GroovyPsiElement (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement)1 GrClosableBlock (org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrClosableBlock)1 GrMethod (org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod)1 GrScriptField (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrScriptField)1 GroovyScriptClass (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GroovyScriptClass)1