/**
   * Check that function or property with the given qualified name can be resolved in given scope
   * and called on given receiver
   *
   * @param callableFQN
   * @param project
   * @param scope
   * @return
   */
  public static List<CallableDescriptor> canFindSuitableCall(
      @NotNull FqName callableFQN,
      @NotNull Project project,
      @NotNull JetExpression receiverExpression,
      @NotNull JetType receiverType,
      @NotNull JetScope scope) {

    JetImportDirective importDirective =
        JetPsiFactory.createImportDirective(project, callableFQN.getFqName());

    Collection<? extends DeclarationDescriptor> declarationDescriptors =
        ImportsResolver.analyseImportReference(importDirective, scope, new BindingTraceContext());

    List<CallableDescriptor> callableExtensionDescriptors = new ArrayList<CallableDescriptor>();
    ReceiverDescriptor receiverDescriptor =
        new ExpressionReceiver(receiverExpression, receiverType);

    for (DeclarationDescriptor declarationDescriptor : declarationDescriptors) {
      if (declarationDescriptor instanceof CallableDescriptor) {
        CallableDescriptor callableDescriptor = (CallableDescriptor) declarationDescriptor;

        if (checkIsExtensionCallable(receiverDescriptor, callableDescriptor)) {
          callableExtensionDescriptors.add(callableDescriptor);
        }
      }
    }

    return callableExtensionDescriptors;
  }
Example #2
0
  @Override
  public boolean equals(Object obj) {
    if (this == obj) return true;
    if (!(obj instanceof ImportPath)) return false;

    ImportPath other = (ImportPath) obj;
    return fqName.equals(other.fqName) && (isAllUnder == other.isAllUnder);
  }
Example #3
0
 @Override
 public int hashCode() {
   return 31 * fqName.hashCode() + (isAllUnder ? 1 : 0);
 }
Example #4
0
 public String getPathStr() {
   return fqName.getFqName() + (isAllUnder ? ".*" : "");
 }
Example #5
0
 public final boolean equalsTo(@NotNull FqName that) {
   return equalsTo(that.toUnsafe());
 }