Search in sources :

Example 1 with GrReferenceTypeEnhancer

use of org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrReferenceTypeEnhancer in project intellij-community by JetBrains.

the class GrReferenceExpressionImpl method getNominalType.

@Nullable
private PsiType getNominalType(boolean forceRValue) {
    final GroovyResolveResult resolveResult = PsiImplUtil.extractUniqueResult(multiResolve(false, forceRValue));
    PsiElement resolved = resolveResult.getElement();
    for (GrReferenceTypeEnhancer enhancer : GrReferenceTypeEnhancer.EP_NAME.getExtensions()) {
        PsiType type = enhancer.getReferenceType(this, resolved);
        if (type != null) {
            return type;
        }
    }
    IElementType dotType = getDotTokenType();
    if (dotType == GroovyTokenTypes.mMEMBER_POINTER) {
        return GrClosureType.create(multiResolve(false), this);
    }
    if (ResolveUtil.isDefinitelyKeyOfMap(this)) {
        final PsiType type = getTypeFromMapAccess(this);
        if (type != null) {
            return type;
        }
    }
    PsiType result = getNominalTypeInner(resolved);
    if (result == null)
        return null;
    result = TypesUtil.substituteAndNormalizeType(result, resolveResult.getSubstitutor(), resolveResult.getSpreadState(), this);
    return result;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) GroovyResolveResult(org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult) GrReferenceTypeEnhancer(org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrReferenceTypeEnhancer) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IElementType (com.intellij.psi.tree.IElementType)1 Nullable (org.jetbrains.annotations.Nullable)1 GroovyResolveResult (org.jetbrains.plugins.groovy.lang.psi.api.GroovyResolveResult)1 GrReferenceTypeEnhancer (org.jetbrains.plugins.groovy.lang.psi.typeEnhancers.GrReferenceTypeEnhancer)1