Search in sources :

Example 1 with AccessorResolverProcessor

use of org.jetbrains.plugins.groovy.lang.resolve.processors.AccessorResolverProcessor in project intellij-community by JetBrains.

the class GroovyPropertyUtils method findPropertySetter.

@Nullable
public static PsiMethod findPropertySetter(@Nullable PsiType type, String propertyName, @NotNull GroovyPsiElement context) {
    final String setterName = getSetterName(propertyName);
    if (type == null) {
        final GrExpression fromText = GroovyPsiElementFactory.getInstance(context.getProject()).createExpressionFromText("this", context);
        return findPropertySetter(fromText.getType(), propertyName, context);
    }
    final AccessorResolverProcessor processor = new AccessorResolverProcessor(setterName, propertyName, context, false);
    ResolveUtil.processAllDeclarations(type, processor, ResolveState.initial(), context);
    final GroovyResolveResult[] setterCandidates = processor.getCandidates();
    return PsiImplUtil.extractUniqueElement(setterCandidates);
}
Also used : GroovyResolveResult(org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult) GrExpression(org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression) AccessorResolverProcessor(org.jetbrains.plugins.groovy.lang.resolve.processors.AccessorResolverProcessor) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Nullable (org.jetbrains.annotations.Nullable)1 GroovyResolveResult (org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult)1 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)1 AccessorResolverProcessor (org.jetbrains.plugins.groovy.lang.resolve.processors.AccessorResolverProcessor)1