@NotNull @Override public Collection<PsiClass> getPackageClasses( @NotNull FqName packageFqName, @NotNull GlobalSearchScope scope) { List<PsiClass> result = new ArrayList<PsiClass>(); List<KotlinLightPackageClassInfo> packageClassesInfos = findPackageClassesInfos(packageFqName, scope); for (KotlinLightPackageClassInfo info : packageClassesInfos) { List<JetFile> files = PackagePartClassUtils.getPackageFilesWithCallables(info.getFiles()); if (files.isEmpty()) continue; IdeaModuleInfo moduleInfo = info.getModuleInfo(); if (moduleInfo instanceof ModuleSourceInfo) { KotlinLightClassForPackage lightClass = KotlinLightClassForPackage.Factory.create( psiManager, packageFqName, moduleInfo.contentScope(), files); if (lightClass == null) continue; result.add(lightClass); if (files.size() > 1) { for (JetFile file : files) { result.add(new FakeLightClassForFileOfPackage(psiManager, lightClass, file)); } } } else { PsiClass clsClass = getLightClassForDecompiledPackage(packageFqName, files); if (clsClass != null) { result.add(clsClass); } } } return result; }
@Nullable private static PsiClass getLightClassForDecompiledPackage( @NotNull FqName packageFqName, @NotNull List<JetFile> filesWithCallables) { JetFile firstFile = filesWithCallables.iterator().next(); if (firstFile.isCompiled()) { if (filesWithCallables.size() > 1) { LOG.error("Several files with callables for package: " + packageFqName); } return createLightClassForDecompiledKotlinFile(firstFile); } return null; }