Example #1
0
 @Override
 protected boolean isVisible(
     @NotNull DeclarationDescriptorWithVisibility what,
     @NotNull DeclarationDescriptor from) {
   ModuleDescriptor parentModule =
       DescriptorUtils.getParentOfType(what, ModuleDescriptor.class, false);
   ModuleDescriptor fromModule =
       DescriptorUtils.getParentOfType(from, ModuleDescriptor.class, false);
   assert parentModule != null && fromModule != null;
   return parentModule.equals(fromModule);
 }
Example #2
0
        @Override
        protected boolean isVisible(
            @NotNull DeclarationDescriptorWithVisibility what,
            @NotNull DeclarationDescriptor from) {
          ClassDescriptor classDescriptor =
              DescriptorUtils.getParentOfType(what, ClassDescriptor.class);
          if (classDescriptor == null) return false;

          ClassDescriptor fromClass =
              DescriptorUtils.getParentOfType(from, ClassDescriptor.class, false);
          if (fromClass == null) return false;
          if (DescriptorUtils.isSubclass(fromClass, classDescriptor)) {
            return true;
          }
          return false;
        }
  @Nullable
  public static JavaPackageFragmentDescriptor getPackageForCorrespondingJavaClass(
      @NotNull JavaClassDescriptor javaClass) {
    PackageFragmentDescriptor packageFragment =
        DescriptorUtils.getParentOfType(javaClass, PackageFragmentDescriptor.class);
    assert packageFragment instanceof JavaPackageFragmentDescriptor
        : "java class " + javaClass + " is under non-java fragment: " + packageFragment;

    JavaPackageFragmentProvider provider =
        ((JavaPackageFragmentDescriptor) packageFragment).getProvider();
    return provider.getPackageFragment(getFqNameSafe(javaClass));
  }
Example #4
0
 public static boolean isVisible(
     DeclarationDescriptorWithVisibility what, DeclarationDescriptor from) {
   DeclarationDescriptorWithVisibility parent = what;
   while (parent != null) {
     if (parent.getVisibility() == LOCAL) {
       return true;
     }
     if (!parent.getVisibility().isVisible(parent, from)) {
       return false;
     }
     parent = DescriptorUtils.getParentOfType(parent, DeclarationDescriptorWithVisibility.class);
   }
   return true;
 }
Example #5
0
 public static boolean isBuiltin(@NotNull DeclarationDescriptor descriptor) {
   PackageFragmentDescriptor containingPackageFragment =
       DescriptorUtils.getParentOfType(descriptor, PackageFragmentDescriptor.class);
   return containingPackageFragment == KotlinBuiltIns.getInstance().getBuiltInsPackageFragment();
 }