@NotNull public static PsiClassType[] getExtendsListTypes(GrTypeDefinition grType) { final PsiClassType[] extendsTypes = getReferenceListTypes(grType.getExtendsClause()); if (grType.isInterface()) { return extendsTypes; } for (PsiClassType type : extendsTypes) { final PsiClass superClass = type.resolve(); if (superClass instanceof GrTypeDefinition && !superClass.isInterface() || superClass != null && GroovyCommonClassNames.GROOVY_OBJECT_SUPPORT.equals( superClass.getQualifiedName())) { return extendsTypes; } } PsiClass grObSupport = GroovyPsiManager.getInstance(grType.getProject()) .findClassWithCache( GroovyCommonClassNames.GROOVY_OBJECT_SUPPORT, grType.getResolveScope()); if (grObSupport != null) { final PsiClassType type = JavaPsiFacade.getInstance(grType.getProject()) .getElementFactory() .createType(grObSupport); return ArrayUtil.append(extendsTypes, type, PsiClassType.ARRAY_FACTORY); } return extendsTypes; }
private void getVariantsFromQualifierType( @NotNull PsiType qualifierType, @NotNull Project project) { final ResolveState state = ResolveState.initial(); if (qualifierType instanceof PsiClassType) { PsiClassType.ClassResolveResult result = ((PsiClassType) qualifierType).resolveGenerics(); PsiClass qualifierClass = result.getElement(); if (qualifierClass != null) { qualifierClass.processDeclarations( myProcessor, state.put(PsiSubstitutor.KEY, result.getSubstitutor()), null, myRefExpr); } } else if (qualifierType instanceof PsiArrayType) { final GrTypeDefinition arrayClass = GroovyPsiManager.getInstance(project) .getArrayClass(((PsiArrayType) qualifierType).getComponentType()); if (arrayClass != null) { if (!arrayClass.processDeclarations(myProcessor, state, null, myRefExpr)) return; } } else if (qualifierType instanceof PsiIntersectionType) { for (PsiType conjunct : ((PsiIntersectionType) qualifierType).getConjuncts()) { getVariantsFromQualifierType(conjunct, project); } return; } ResolveUtil.processNonCodeMembers(qualifierType, myProcessor, myRefExpr, state); }
public static boolean processImplicitImports( @NotNull PsiScopeProcessor processor, ResolveState state, PsiElement lastParent, PsiElement place, @NotNull GroovyFile file) { JavaPsiFacade facade = JavaPsiFacade.getInstance(file.getProject()); final DelegatingScopeProcessor packageSkipper = new DelegatingScopeProcessor(processor) { @Override public boolean execute(@NotNull PsiElement element, ResolveState state) { if (element instanceof PsiPackage) return true; return super.execute(element, state); } }; for (final String implicitlyImported : getImplicitlyImportedPackages(file)) { PsiPackage aPackage = facade.findPackage(implicitlyImported); if (aPackage == null) continue; if (!aPackage.processDeclarations(packageSkipper, state, lastParent, place)) { return false; } } GroovyPsiManager groovyPsiManager = GroovyPsiManager.getInstance(file.getProject()); for (String implicitlyImportedClass : GroovyFileBase.IMPLICITLY_IMPORTED_CLASSES) { PsiClass clazz = groovyPsiManager.findClassWithCache(implicitlyImportedClass, file.getResolveScope()); if (clazz != null && !ResolveUtil.processElement(processor, clazz, state)) return false; } return true; }
public static PsiType boxPrimitiveType( @Nullable PsiType result, @NotNull PsiManager manager, @NotNull GlobalSearchScope resolveScope, boolean boxVoid) { if (result instanceof PsiPrimitiveType && (boxVoid || result != PsiType.VOID)) { PsiPrimitiveType primitive = (PsiPrimitiveType) result; String boxedTypeName = primitive.getBoxedTypeName(); if (boxedTypeName != null) { return GroovyPsiManager.getInstance(manager.getProject()) .createTypeByFQClassName(boxedTypeName, resolveScope); } } return result; }
public PsiType getType() { return GroovyPsiManager.getInstance(getProject()).getType(this, TYPE_CALCULATOR); }
@NotNull public static PsiClassType createTypeByFQClassName( @NotNull String fqName, @NotNull PsiElement context) { return GroovyPsiManager.getInstance(context.getProject()) .createTypeByFQClassName(fqName, context.getResolveScope()); }