コード例 #1
0
ファイル: OverridingUtil.java プロジェクト: anujk3/kotlin
  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;
          }
        });
  }
コード例 #2
0
ファイル: OverridingUtil.java プロジェクト: anujk3/kotlin
 @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);
           }
         }
       });
 }