Search in sources :

Example 1 with LiteralConstructorReference

use of org.jetbrains.plugins.groovy.findUsages.LiteralConstructorReference in project intellij-community by JetBrains.

the class GppTypeConverter method isConvertible.

@Override
public Boolean isConvertible(@NotNull PsiType lType, @NotNull PsiType rType, @NotNull GroovyPsiElement context) {
    if (context instanceof GrListOrMap && context.getReference() instanceof LiteralConstructorReference && ((LiteralConstructorReference) context.getReference()).getConstructedClassType() != null)
        return null;
    if (rType instanceof GrTupleType) {
        final GrTupleType tupleType = (GrTupleType) rType;
        final PsiType expectedComponent = PsiUtil.extractIterableTypeParameter(lType, false);
        if (expectedComponent != null && isMethodCallConversion(context)) {
            PsiType[] parameters = tupleType.getParameters();
            if (parameters.length == 1) {
                PsiType tupleComponent = parameters[0];
                if (tupleComponent != null && TypesUtil.isAssignable(expectedComponent, tupleComponent, context) && hasDefaultConstructor(lType)) {
                    return true;
                }
            }
        }
    }
    return null;
}
Also used : LiteralConstructorReference(org.jetbrains.plugins.groovy.findUsages.LiteralConstructorReference) GrListOrMap(org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap) GrTupleType(org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType) PsiType(com.intellij.psi.PsiType)

Aggregations

PsiType (com.intellij.psi.PsiType)1 LiteralConstructorReference (org.jetbrains.plugins.groovy.findUsages.LiteralConstructorReference)1 GrListOrMap (org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap)1 GrTupleType (org.jetbrains.plugins.groovy.lang.psi.impl.GrTupleType)1