Search in sources :

Example 1 with GrClassReferenceType

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

the class GrAnonymousClassDefinitionImpl method getBaseClassType.

@Override
@NotNull
public PsiClassType getBaseClassType() {
    PsiClassType type = SoftReference.dereference(myCachedBaseType);
    if (type != null && type.isValid())
        return type;
    type = new GrClassReferenceType(getBaseClassReferenceGroovy());
    myCachedBaseType = new SoftReference<>(type);
    return type;
}
Also used : GrClassReferenceType(org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with GrClassReferenceType

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

the class GrReferenceListImpl method getReferencedTypes.

@NotNull
@Override
public PsiClassType[] getReferencedTypes() {
    if (myCachedTypes == null || !isValid()) {
        final ArrayList<PsiClassType> types = new ArrayList<>();
        for (GrCodeReferenceElement ref : getReferenceElementsGroovy()) {
            types.add(new GrClassReferenceType(ref));
        }
        myCachedTypes = types.toArray(new PsiClassType[types.size()]);
    }
    return myCachedTypes;
}
Also used : GrCodeReferenceElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement) GrClassReferenceType(org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with GrClassReferenceType

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

the class GrClassReferenceTypePointer method calcType.

@Nullable
@Override
protected GrClassReferenceType calcType() {
    final GrReferenceElement reference = mySmartPsiElementPointer.getElement();
    if (reference != null) {
        return new GrClassReferenceType(reference);
    }
    try {
        final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(myProject);
        GrTypeElement typeElement = factory.createTypeElement(myReferenceText, null);
        return (GrClassReferenceType) typeElement.getType();
    } catch (IncorrectOperationException e) {
        LOG.error(e);
    }
    return null;
}
Also used : GroovyPsiElementFactory(org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory) GrTypeElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement) GrClassReferenceType(org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType) IncorrectOperationException(com.intellij.util.IncorrectOperationException) GrReferenceElement(org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with GrClassReferenceType

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

the class GrTypeParameterParameterExtendsListImpl method getReferencedTypes.

@Override
@NotNull
public PsiClassType[] getReferencedTypes() {
    final GrCodeReferenceElement[] refs = findChildrenByClass(GrCodeReferenceElement.class);
    PsiClassType[] result = new PsiClassType[refs.length];
    for (int i = 0; i < result.length; i++) {
        result[i] = new GrClassReferenceType(refs[i]);
    }
    return result;
}
Also used : GrCodeReferenceElement(org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement) PsiClassType(com.intellij.psi.PsiClassType) GrClassReferenceType(org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with GrClassReferenceType

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

the class GroovyShellCodeFragment method addVariable.

public void addVariable(String name, GrExpression expr) {
    PsiType type = expr.getType();
    if (type instanceof GrClassReferenceType) {
        final PsiClassType.ClassResolveResult resolveResult = ((GrClassReferenceType) type).resolveGenerics();
        final PsiClass psiClass = resolveResult.getElement();
        type = psiClass == null ? null : new PsiImmediateClassType(psiClass, resolveResult.getSubstitutor());
    }
    if (type != null) {
        myVariables.put(name, new GrLightVariable(getManager(), name, type, this));
    }
}
Also used : PsiImmediateClassType(com.intellij.psi.impl.source.PsiImmediateClassType) GrClassReferenceType(org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType) GrLightVariable(org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightVariable)

Aggregations

GrClassReferenceType (org.jetbrains.plugins.groovy.lang.psi.impl.GrClassReferenceType)5 NotNull (org.jetbrains.annotations.NotNull)3 GrCodeReferenceElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement)2 PsiClassType (com.intellij.psi.PsiClassType)1 PsiImmediateClassType (com.intellij.psi.impl.source.PsiImmediateClassType)1 IncorrectOperationException (com.intellij.util.IncorrectOperationException)1 ArrayList (java.util.ArrayList)1 Nullable (org.jetbrains.annotations.Nullable)1 GrReferenceElement (org.jetbrains.plugins.groovy.lang.psi.GrReferenceElement)1 GroovyPsiElementFactory (org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElementFactory)1 GrTypeElement (org.jetbrains.plugins.groovy.lang.psi.api.types.GrTypeElement)1 GrLightVariable (org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrLightVariable)1