private Object[] processPackage(final PsiPackage aPackage) { final ArrayList<Object> list = new ArrayList<Object>(); final int startOffset = StringUtil.isEmpty(aPackage.getName()) ? 0 : aPackage.getQualifiedName().length() + 1; final GlobalSearchScope scope = getScope(); for (final PsiPackage subPackage : aPackage.getSubPackages(scope)) { final String shortName = subPackage.getQualifiedName().substring(startOffset); if (JavaPsiFacade.getInstance(subPackage.getProject()) .getNameHelper() .isIdentifier(shortName)) { list.add(subPackage); } } final PsiClass[] classes = aPackage.getClasses(scope); final Map<CustomizableReferenceProvider.CustomizationKey, Object> options = getOptions(); if (options != null) { final boolean instantiatable = JavaClassReferenceProvider.INSTANTIATABLE.getBooleanValue(options); final boolean concrete = JavaClassReferenceProvider.CONCRETE.getBooleanValue(options); final boolean notInterface = JavaClassReferenceProvider.NOT_INTERFACE.getBooleanValue(options); final boolean notEnum = JavaClassReferenceProvider.NOT_ENUM.getBooleanValue(options); final ClassKind classKind = getClassKind(); for (PsiClass clazz : classes) { if (isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum)) { list.add(clazz); } } } else { ContainerUtil.addAll(list, classes); } return list.toArray(); }
@NotNull private Object[] getSubclassVariants( @NotNull PsiPackage context, @NotNull String[] extendClasses) { HashSet<Object> lookups = new HashSet<Object>(); GlobalSearchScope packageScope = PackageScope.packageScope(context, true); GlobalSearchScope scope = myJavaClassReferenceSet.getProvider().getScope(); if (scope != null) { packageScope = packageScope.intersectWith(scope); } final GlobalSearchScope allScope = ProjectScope.getAllScope(context.getProject()); final boolean instantiatable = JavaClassReferenceProvider.INSTANTIATABLE.getBooleanValue(getOptions()); final boolean notInterface = JavaClassReferenceProvider.NOT_INTERFACE.getBooleanValue(getOptions()); final boolean notEnum = JavaClassReferenceProvider.NOT_ENUM.getBooleanValue(getOptions()); final boolean concrete = JavaClassReferenceProvider.CONCRETE.getBooleanValue(getOptions()); final ClassKind classKind = getClassKind(); for (String extendClassName : extendClasses) { final PsiClass extendClass = JavaPsiFacade.getInstance(context.getProject()).findClass(extendClassName, allScope); if (extendClass != null) { // add itself if (packageScope.contains(extendClass.getContainingFile().getVirtualFile())) { if (isClassAccepted( extendClass, classKind, instantiatable, concrete, notInterface, notEnum)) { ContainerUtil.addIfNotNull(createSubclassLookupValue(context, extendClass), lookups); } } for (final PsiClass clazz : ClassInheritorsSearch.search(extendClass, packageScope, true)) { if (isClassAccepted(clazz, classKind, instantiatable, concrete, notInterface, notEnum)) { ContainerUtil.addIfNotNull(createSubclassLookupValue(context, clazz), lookups); } } } } return lookups.toArray(); }