Search in sources :

Example 56 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class GrDocMethodParamsImpl method getParameterTypes.

@Override
public PsiType[] getParameterTypes() {
    ArrayList<PsiType> types = new ArrayList<>();
    PsiManagerEx manager = getManager();
    GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
    PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
    for (GrDocMethodParameter parameter : getParameters()) {
        GrDocReferenceElement typeElement = parameter.getTypeElement();
        try {
            PsiType type = factory.createTypeFromText(typeElement.getText(), this);
            type = TypesUtil.boxPrimitiveType(type, manager, scope);
            types.add(type);
        } catch (IncorrectOperationException e) {
            LOG.info(e);
            types.add(null);
        }
    }
    return types.toArray(PsiType.createArray(types.size()));
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) GrDocReferenceElement(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocReferenceElement) ArrayList(java.util.ArrayList) PsiElementFactory(com.intellij.psi.PsiElementFactory) IncorrectOperationException(com.intellij.util.IncorrectOperationException) GrDocMethodParameter(org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocMethodParameter) PsiType(com.intellij.psi.PsiType) PsiManagerEx(com.intellij.psi.impl.PsiManagerEx)

Example 57 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class GrTupleType method isAssignableFrom.

@Override
public boolean isAssignableFrom(@NotNull PsiType type) {
    if (type instanceof GrTupleType) {
        PsiType[] otherComponents = ((GrTupleType) type).getComponentTypes();
        PsiType[] componentTypes = getComponentTypes();
        for (int i = 0; i < Math.min(componentTypes.length, otherComponents.length); i++) {
            PsiType componentType = componentTypes[i];
            PsiType otherComponent = otherComponents[i];
            if (otherComponent == null) {
                if (componentType != null && !TypesUtil.isClassType(componentType, CommonClassNames.JAVA_LANG_OBJECT))
                    return false;
            } else if (componentType != null && !componentType.isAssignableFrom(otherComponent))
                return false;
        }
        return true;
    }
    return super.isAssignableFrom(type);
}
Also used : PsiType(com.intellij.psi.PsiType)

Example 58 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class GrMapType method merge.

public static GrMapType merge(GrMapType l, GrMapType r) {
    final GlobalSearchScope scope = l.getScope().intersectWith(r.getResolveScope());
    final LinkedHashMap<String, PsiType> strings = ContainerUtil.newLinkedHashMap();
    strings.putAll(l.getStringEntries());
    strings.putAll(r.getStringEntries());
    List<Couple<PsiType>> other = new ArrayList<>();
    other.addAll(l.getOtherEntries());
    other.addAll(r.getOtherEntries());
    return create(l.myFacade, scope, strings, other);
}
Also used : GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Couple(com.intellij.openapi.util.Couple) PsiType(com.intellij.psi.PsiType)

Example 59 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class GrMapType method create.

public static GrMapType create(GlobalSearchScope scope) {
    JavaPsiFacade facade = JavaPsiFacade.getInstance(scope.getProject());
    List<Couple<PsiType>> otherEntries = Collections.emptyList();
    LinkedHashMap<String, PsiType> stringEntries = ContainerUtil.newLinkedHashMap();
    return new GrMapTypeImpl(facade, scope, stringEntries, otherEntries, LanguageLevel.JDK_1_5);
}
Also used : JavaPsiFacade(com.intellij.psi.JavaPsiFacade) Couple(com.intellij.openapi.util.Couple) PsiType(com.intellij.psi.PsiType)

Example 60 with PsiType

use of com.intellij.psi.PsiType in project intellij-community by JetBrains.

the class DFAType method create.

@Nullable
public static DFAType create(DFAType t1, DFAType t2, PsiManager manager) {
    if (t1.equals(t2))
        return t1;
    final PsiType primary = TypesUtil.getLeastUpperBoundNullable(t1.primary, t2.primary, manager);
    final DFAType type = new DFAType(primary);
    for (Mixin mixin1 : t1.mixins) {
        for (Mixin mixin2 : t2.mixins) {
            if (mixin1.ID == mixin2.ID && mixin1.myNegated == mixin2.myNegated) {
                type.mixins.add(mixin1);
            }
        }
    }
    return type;
}
Also used : PsiType(com.intellij.psi.PsiType) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiType (com.intellij.psi.PsiType)157 PsiElement (com.intellij.psi.PsiElement)34 Nullable (org.jetbrains.annotations.Nullable)24 GrExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression)24 NotNull (org.jetbrains.annotations.NotNull)21 PsiClassType (com.intellij.psi.PsiClassType)20 PsiClass (com.intellij.psi.PsiClass)14 GrReferenceExpression (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrReferenceExpression)13 PsiPrimitiveType (com.intellij.psi.PsiPrimitiveType)12 ArrayList (java.util.ArrayList)9 GrTypeElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement)9 PsiArrayType (com.intellij.psi.PsiArrayType)7 PsiExpression (com.intellij.psi.PsiExpression)7 PsiField (com.intellij.psi.PsiField)7 NonNls (org.jetbrains.annotations.NonNls)7 GrVariable (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrVariable)7 PsiLiteralExpression (com.intellij.psi.PsiLiteralExpression)6 PsiMethod (com.intellij.psi.PsiMethod)6 GrStatement (org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement)6 GrLiteral (org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrLiteral)6