Exemple #1
0
 private static <D extends CallableDescriptor> void collectAllOverriddenDescriptors(
     @NotNull D current, @NotNull Set<D> result) {
   if (result.contains(current)) return;
   for (CallableDescriptor callableDescriptor : current.getOriginal().getOverriddenDescriptors()) {
     @SuppressWarnings("unchecked")
     D descriptor = (D) callableDescriptor;
     collectAllOverriddenDescriptors(descriptor, result);
     result.add(descriptor);
   }
 }
Exemple #2
0
 @NotNull
 @SuppressWarnings("unchecked")
 public static <D extends CallableMemberDescriptor> Set<D> getAllOverriddenDeclarations(
     @NotNull D memberDescriptor) {
   Set<D> result = new HashSet<D>();
   for (CallableMemberDescriptor overriddenDeclaration :
       memberDescriptor.getOverriddenDescriptors()) {
     CallableMemberDescriptor.Kind kind = overriddenDeclaration.getKind();
     if (kind == DECLARATION) {
       result.add((D) overriddenDeclaration);
     } else if (kind == DELEGATION || kind == FAKE_OVERRIDE || kind == SYNTHESIZED) {
       // do nothing
     } else {
       throw new AssertionError("Unexpected callable kind " + kind);
     }
     result.addAll(getAllOverriddenDeclarations((D) overriddenDeclaration));
   }
   return result;
 }
 @NotNull
 private static Collection<CallableMemberDescriptor>
     getAllDeclaredNonOverridableOverriddenDescriptors(
         @NotNull CallableMemberDescriptor callableMemberDescriptor) {
   Set<CallableMemberDescriptor> result = Sets.newHashSet();
   Collection<CallableMemberDescriptor> nonOverridableOverriddenDescriptors =
       retainNonOverridableMembers(callableMemberDescriptor.getOverriddenDescriptors());
   for (CallableMemberDescriptor overriddenDescriptor : nonOverridableOverriddenDescriptors) {
     CallableMemberDescriptor.Kind kind = overriddenDescriptor.getKind();
     if (kind == DECLARATION) {
       result.add(overriddenDescriptor);
     } else if (kind == FAKE_OVERRIDE || kind == DELEGATION) {
       result.addAll(getAllDeclaredNonOverridableOverriddenDescriptors(overriddenDescriptor));
     } else if (kind == SYNTHESIZED) {
       // do nothing, final synthesized members can't be made open
     } else {
       throw new UnsupportedOperationException("Unexpected callable kind " + kind);
     }
   }
   return result;
 }