Search in sources :

Example 1 with EmptyPackageFragmentDescriptor

use of org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor in project kotlin by JetBrains.

the class KotlinBuiltIns method createPackage.

@NotNull
private PackageFragmentDescriptor createPackage(@NotNull PackageFragmentProvider fragmentProvider, @Nullable Map<FqName, PackageFragmentDescriptor> packageNameToPackageFragment, @NotNull final FqName packageFqName) {
    final List<PackageFragmentDescriptor> packageFragments = fragmentProvider.getPackageFragments(packageFqName);
    PackageFragmentDescriptor result = packageFragments.isEmpty() ? new EmptyPackageFragmentDescriptor(builtInsModule, packageFqName) : packageFragments.size() == 1 ? packageFragments.iterator().next() : new PackageFragmentDescriptorImpl(builtInsModule, packageFqName) {

        @NotNull
        @Override
        public MemberScope getMemberScope() {
            return new ChainedMemberScope("built-in package " + packageFqName, CollectionsKt.map(packageFragments, new Function1<PackageFragmentDescriptor, MemberScope>() {

                @Override
                public MemberScope invoke(PackageFragmentDescriptor descriptor) {
                    return descriptor.getMemberScope();
                }
            }));
        }
    };
    if (packageNameToPackageFragment != null)
        packageNameToPackageFragment.put(packageFqName, result);
    return result;
}
Also used : ChainedMemberScope(org.jetbrains.kotlin.resolve.scopes.ChainedMemberScope) Function1(kotlin.jvm.functions.Function1) EmptyPackageFragmentDescriptor(org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor) EmptyPackageFragmentDescriptor(org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor) PackageFragmentDescriptorImpl(org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl) MemoizedFunctionToNotNull(org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Function1 (kotlin.jvm.functions.Function1)1 NotNull (org.jetbrains.annotations.NotNull)1 EmptyPackageFragmentDescriptor (org.jetbrains.kotlin.descriptors.impl.EmptyPackageFragmentDescriptor)1 PackageFragmentDescriptorImpl (org.jetbrains.kotlin.descriptors.impl.PackageFragmentDescriptorImpl)1 ChainedMemberScope (org.jetbrains.kotlin.resolve.scopes.ChainedMemberScope)1 MemoizedFunctionToNotNull (org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull)1