Make ModuleDescriptor#getPackage() return not null lazy object with lazy scope

Refactor: no need to create package view in order to obtain its subpackages
LazyPackageViewDescriptorImpl to replace PackageViewDescriptorImpl
This allows to avoid computations when package views are requested but their contents not necessarily queried
For example: DescriptorResolver.resolvePackageHeader()
This commit is contained in:
Pavel V. Talanov
2015-05-07 19:43:17 +03:00
parent 1cf38e4799
commit 37bcd455b5
40 changed files with 103 additions and 105 deletions
@@ -167,15 +167,13 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
@Override
public boolean packageExists(@NotNull FqName fqName, @NotNull GlobalSearchScope scope) {
return getModule().getPackage(fqName) != null;
return !getModule().getPackage(fqName).isEmpty();
}
@NotNull
@Override
public Collection<FqName> getSubPackages(@NotNull FqName fqn, @NotNull GlobalSearchScope scope) {
PackageViewDescriptor packageView = getModule().getPackage(fqn);
if (packageView == null) return Collections.emptyList();
Collection<DeclarationDescriptor> members = packageView.getMemberScope().getDescriptors(DescriptorKindFilter.PACKAGES, JetScope.ALL_NAME_FILTER);
return ContainerUtil.mapNotNull(members, new Function<DeclarationDescriptor, FqName>() {
@Override