Example #1
0
  public static boolean traverseOverridenDescriptors(
      @NotNull CallableDescriptor originalDescriptor,
      @NotNull final Function1<CallableDescriptor, Boolean> handler) {
    return DFS.dfs(
        Collections.singletonList(originalDescriptor),
        new DFS.Neighbors<CallableDescriptor>() {
          @NotNull
          @Override
          public Iterable<? extends CallableDescriptor> getNeighbors(CallableDescriptor current) {
            return current.getOverriddenDescriptors();
          }
        },
        new DFS.AbstractNodeHandler<CallableDescriptor, Boolean>() {
          private boolean result = true;

          @Override
          public boolean beforeChildren(CallableDescriptor current) {
            if (!handler.invoke(current)) {
              result = false;
            }
            return result;
          }

          @Override
          public Boolean result() {
            return result;
          }
        });
  }
Example #2
0
 @NotNull
 @KotlinSignature(
     "fun getTopmostOverridenDescriptors(originalDescriptor: CallableDescriptor): List<out CallableDescriptor>")
 public static List<? extends CallableDescriptor> getTopmostOverridenDescriptors(
     @NotNull CallableDescriptor originalDescriptor) {
   return DFS.dfs(
       Collections.singletonList(originalDescriptor),
       new DFS.Neighbors<CallableDescriptor>() {
         @NotNull
         @Override
         public Iterable<? extends CallableDescriptor> getNeighbors(CallableDescriptor current) {
           return current.getOverriddenDescriptors();
         }
       },
       new DFS.CollectingNodeHandler<
           CallableDescriptor, CallableDescriptor, ArrayList<CallableDescriptor>>(
           new ArrayList<CallableDescriptor>()) {
         @Override
         public void afterChildren(CallableDescriptor current) {
           if (current.getOverriddenDescriptors().isEmpty()) {
             result.add(current);
           }
         }
       });
 }