@NotNull
 private List<KotlinLightPackageClassInfo> findPackageClassesInfos(
     @NotNull FqName fqName, @NotNull GlobalSearchScope wholeScope) {
   Collection<JetFile> allFiles = findFilesForPackage(fqName, wholeScope);
   Map<IdeaModuleInfo, List<JetFile>> filesByInfo = groupByModuleInfo(allFiles);
   List<KotlinLightPackageClassInfo> result = new ArrayList<KotlinLightPackageClassInfo>();
   for (Map.Entry<IdeaModuleInfo, List<JetFile>> entry : filesByInfo.entrySet()) {
     result.add(new KotlinLightPackageClassInfo(entry.getValue(), entry.getKey()));
   }
   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;
 }
  @NotNull
  @Override
  public LightClassConstructionContext getContextForPackage(@NotNull Collection<JetFile> files) {
    assert !files.isEmpty() : "No files in package";

    List<JetFile> sortedFiles = new ArrayList<JetFile>(files);
    Collections.sort(sortedFiles, scopeFileComparator);

    JetFile file = sortedFiles.get(0);
    ResolveSessionForBodies session =
        KotlinCacheService.getInstance(file.getProject()).getLazyResolveSession(file);
    forceResolvePackageDeclarations(files, session);
    return new LightClassConstructionContext(
        session.getBindingContext(), session.getModuleDescriptor());
  }
  @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;
  }