use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder 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;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightMethodBuilder in project android by JetBrains.
the class AndroidDslContributor method resolveToMethodWithClosure.
private static void resolveToMethodWithClosure(PsiElement place, PsiElement resolveToElement, String closureTypeFqcn, PsiScopeProcessor processor, ResolveState state) {
if (place.getParent() instanceof GrMethodCallExpression) {
GrLightMethodBuilder methodWithClosure = GradleResolverUtil.createMethodWithClosure(place.getText(), closureTypeFqcn, null, place);
if (methodWithClosure != null) {
processor.execute(methodWithClosure, state);
methodWithClosure.setNavigationElement(resolveToElement);
}
} else if (place.getParent() instanceof GrReferenceExpression) {
GrLightVariable variable = new GrLightVariable(place.getManager(), place.getText(), closureTypeFqcn, place);
processor.execute(variable, state);
}
}
Aggregations