Search in sources :

Example 1 with PropertyResolverProcessor

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

the class GrDocFieldReferenceImpl method multiResolveImpl.

@Override
protected ResolveResult[] multiResolveImpl() {
    String name = getReferenceName();
    GrDocReferenceElement holder = getReferenceHolder();
    PsiElement resolved;
    if (holder != null) {
        GrCodeReferenceElement referenceElement = holder.getReferenceElement();
        resolved = referenceElement != null ? referenceElement.resolve() : null;
    } else {
        resolved = PsiUtil.getContextClass(GrDocCommentUtil.findDocOwner(this));
    }
    if (resolved instanceof PsiClass) {
        PropertyResolverProcessor processor = new PropertyResolverProcessor(name, this);
        resolved.processDeclarations(processor, ResolveState.initial(), resolved, this);
        GroovyResolveResult[] candidates = processor.getCandidates();
        if (candidates.length == 0) {
            PsiType thisType = JavaPsiFacade.getInstance(getProject()).getElementFactory().createType((PsiClass) resolved, PsiSubstitutor.EMPTY);
            MethodResolverProcessor methodProcessor = new MethodResolverProcessor(name, this, false, thisType, null, PsiType.EMPTY_ARRAY);
            MethodResolverProcessor constructorProcessor = new MethodResolverProcessor(name, this, true, thisType, null, PsiType.EMPTY_ARRAY);
            resolved.processDeclarations(methodProcessor, ResolveState.initial(), resolved, this);
            resolved.processDeclarations(constructorProcessor, ResolveState.initial(), resolved, this);
            candidates = ArrayUtil.mergeArrays(methodProcessor.getCandidates(), constructorProcessor.getCandidates());
            if (candidates.length > 0) {
                candidates = new GroovyResolveResult[] { candidates[0] };
            }
        }
        return candidates;
    }
    return ResolveResult.EMPTY_ARRAY;
}
Also used : GrCodeReferenceElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement) GroovyResolveResult(org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult) GrDocReferenceElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement) MethodResolverProcessor(org.jetbrains.plugins.groovy.lang.resolve.processors.MethodResolverProcessor) PropertyResolverProcessor(org.jetbrains.plugins.groovy.lang.resolve.processors.PropertyResolverProcessor)

Example 2 with PropertyResolverProcessor

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

the class ControlFlowBuilderUtil method resolveNonQualifiedRefWithoutFlow.

@NotNull
public static GroovyResolveResult[] resolveNonQualifiedRefWithoutFlow(@NotNull GrReferenceExpression ref) {
    LOG.assertTrue(!ref.isQualified());
    final String referenceName = ref.getReferenceName();
    final ResolverProcessor processor = new PropertyResolverProcessor(referenceName, ref);
    treeWalkUp(ref, processor);
    final GroovyResolveResult[] candidates = processor.getCandidates();
    if (candidates.length != 0) {
        return candidates;
    }
    return GroovyResolveResult.EMPTY_ARRAY;
}
Also used : GroovyResolveResult(org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult) PropertyResolverProcessor(org.jetbrains.plugins.groovy.lang.resolve.processors.PropertyResolverProcessor) ResolverProcessor(org.jetbrains.plugins.groovy.lang.resolve.processors.ResolverProcessor) PropertyResolverProcessor(org.jetbrains.plugins.groovy.lang.resolve.processors.PropertyResolverProcessor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

GroovyResolveResult (org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult)2 PropertyResolverProcessor (org.jetbrains.plugins.groovy.lang.resolve.processors.PropertyResolverProcessor)2 NotNull (org.jetbrains.annotations.NotNull)1 GrDocReferenceElement (org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement)1 GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)1 MethodResolverProcessor (org.jetbrains.plugins.groovy.lang.resolve.processors.MethodResolverProcessor)1 ResolverProcessor (org.jetbrains.plugins.groovy.lang.resolve.processors.ResolverProcessor)1