コード例 #1
0
ファイル: TaskPrioritizer.java プロジェクト: rafacm/kotlin
  private static <D extends CallableDescriptor>
      Collection<ResolutionCandidate<D>> convertWithReceivers(
          Collection<? extends D> descriptors,
          Iterable<ReceiverDescriptor> thisObjects,
          Iterable<ReceiverDescriptor> receiverParameters,
          boolean hasExplicitThisObject) {

    Collection<ResolutionCandidate<D>> result = Lists.newArrayList();
    convertWithReceivers(
        descriptors, thisObjects, receiverParameters, result, hasExplicitThisObject);
    return result;
  }
コード例 #2
0
ファイル: TaskPrioritizer.java プロジェクト: rafacm/kotlin
  private static <D extends CallableDescriptor, F extends D> void doComputeTasks(
      @NotNull JetScope scope,
      @NotNull ReceiverDescriptor receiver,
      @NotNull Name name,
      @NotNull ResolutionTaskHolder<D, F> result,
      @NotNull BasicResolutionContext context,
      @NotNull CallableDescriptorCollector<? extends D> callableDescriptorCollector) {

    ProgressIndicatorProvider.checkCanceled();

    AutoCastServiceImpl autoCastService =
        new AutoCastServiceImpl(context.dataFlowInfo, context.trace.getBindingContext());
    List<ReceiverDescriptor> implicitReceivers = Lists.newArrayList();
    scope.getImplicitReceiversHierarchy(implicitReceivers);
    boolean hasExplicitThisObject = context.call.getThisObject().exists();
    if (hasExplicitThisObject) {
      implicitReceivers.add(context.call.getThisObject());
    }
    if (receiver.exists()) {
      List<ReceiverDescriptor> variantsForExplicitReceiver =
          autoCastService.getVariantsForReceiver(receiver);

      Collection<ResolutionCandidate<D>> extensionFunctions =
          convertWithImpliedThis(
              scope,
              variantsForExplicitReceiver,
              callableDescriptorCollector.getNonMembersByName(scope, name));
      List<ResolutionCandidate<D>> nonlocals = Lists.newArrayList();
      List<ResolutionCandidate<D>> locals = Lists.newArrayList();
      //noinspection unchecked,RedundantTypeArguments
      TaskPrioritizer.<D>splitLexicallyLocalDescriptors(
          extensionFunctions, scope.getContainingDeclaration(), locals, nonlocals);

      Collection<ResolutionCandidate<D>> members = Lists.newArrayList();
      for (ReceiverDescriptor variant : variantsForExplicitReceiver) {
        Collection<? extends D> membersForThisVariant =
            callableDescriptorCollector.getMembersByName(variant.getType(), name);
        convertWithReceivers(
            membersForThisVariant,
            Collections.singletonList(variant),
            Collections.singletonList(NO_RECEIVER),
            members,
            hasExplicitThisObject);
      }

      result.addLocalExtensions(locals);
      result.addMembers(members);

      for (ReceiverDescriptor implicitReceiver : implicitReceivers) {
        Collection<? extends D> memberExtensions =
            callableDescriptorCollector.getNonMembersByName(
                implicitReceiver.getType().getMemberScope(), name);
        List<ReceiverDescriptor> variantsForImplicitReceiver =
            autoCastService.getVariantsForReceiver(implicitReceiver);
        result.addNonLocalExtensions(
            convertWithReceivers(
                memberExtensions,
                variantsForImplicitReceiver,
                variantsForExplicitReceiver,
                hasExplicitThisObject));
      }

      result.addNonLocalExtensions(nonlocals);
    } else {
      Collection<ResolutionCandidate<D>> functions =
          convertWithImpliedThis(
              scope,
              Collections.singletonList(receiver),
              callableDescriptorCollector.getNonExtensionsByName(scope, name));

      List<ResolutionCandidate<D>> nonlocals = Lists.newArrayList();
      List<ResolutionCandidate<D>> locals = Lists.newArrayList();
      //noinspection unchecked,RedundantTypeArguments
      TaskPrioritizer.<D>splitLexicallyLocalDescriptors(
          functions, scope.getContainingDeclaration(), locals, nonlocals);

      result.addLocalExtensions(locals);
      result.addNonLocalExtensions(nonlocals);

      for (ReceiverDescriptor implicitReceiver : implicitReceivers) {
        doComputeTasks(scope, implicitReceiver, name, result, context, callableDescriptorCollector);
      }
    }
  }