Extracted method for finding exactly one fragment.

This commit is contained in:
Evgeny Gerashchenko
2013-11-27 14:36:06 +04:00
parent 1bbe9b0bd4
commit 98ad890b60
4 changed files with 26 additions and 16 deletions
@@ -21,6 +21,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.TestOnly;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
@@ -484,4 +485,12 @@ public class DescriptorUtils {
return isTopLevelDeclaration(descriptor) ||
containing instanceof ClassDescriptor && isTopLevelOrInnerClass((ClassDescriptor) containing);
}
@TestOnly
@NotNull
public static PackageFragmentDescriptor getExactlyOnePackageFragment(@NotNull ModuleDescriptor module, @NotNull FqName fqName) {
List<PackageFragmentDescriptor> packageFragments = module.getPackageFragmentProvider().getPackageFragments(fqName);
assert packageFragments.size() == 1 : "Exactly one package fragment expected: " + packageFragments;
return packageFragments.get(0);
}
}