コード例 #1
0
  @NotNull
  public Collection<? extends DeclarationDescriptor> lookupDescriptorsForUserType(
      @NotNull JetUserType userType, @NotNull JetScope outerScope, @NotNull BindingTrace trace) {

    if (userType.isAbsoluteInRootNamespace()) {
      trace.report(Errors.UNSUPPORTED.on(userType, "package"));
      return Collections.emptyList();
    }
    JetSimpleNameExpression referenceExpression = userType.getReferenceExpression();
    if (referenceExpression == null) {
      return Collections.emptyList();
    }
    JetUserType qualifier = userType.getQualifier();
    if (qualifier == null) {
      return lookupDescriptorsForSimpleNameReference(
          referenceExpression, outerScope, outerScope, trace, LookupMode.ONLY_CLASSES, false, true);
    }
    Collection<? extends DeclarationDescriptor> declarationDescriptors =
        lookupDescriptorsForUserType(qualifier, outerScope, trace);
    return lookupSelectorDescriptors(
        referenceExpression,
        declarationDescriptors,
        trace,
        outerScope,
        LookupMode.ONLY_CLASSES,
        true);
  }
コード例 #2
0
ファイル: JetPsiUtil.java プロジェクト: vijaykiran/kotlin
  /** @return <code>null</code> iff the tye has syntactic errors */
  @Nullable
  public static FqName toQualifiedName(@NotNull JetUserType userType) {
    List<String> reversedNames = Lists.newArrayList();

    JetUserType current = userType;
    while (current != null) {
      String name = current.getReferencedName();
      if (name == null) return null;

      reversedNames.add(name);
      current = current.getQualifier();
    }

    return FqName.fromSegments(ContainerUtil.reverse(reversedNames));
  }
コード例 #3
0
  @NotNull
  public Collection<DeclarationDescriptor> lookupDescriptorsForUserType(
      @NotNull JetUserType userType,
      @NotNull JetScope outerScope,
      @NotNull BindingTrace trace,
      boolean onlyClassifiers) {

    if (userType.isAbsoluteInRootPackage()) {
      trace.report(Errors.UNSUPPORTED.on(userType, "package"));
      return Collections.emptyList();
    }

    JetSimpleNameExpression referenceExpression = userType.getReferenceExpression();
    if (referenceExpression == null) {
      return Collections.emptyList();
    }
    JetUserType qualifier = userType.getQualifier();

    // We do not want to resolve the last segment of a user type to a package
    JetScope filteredScope = filterOutPackagesIfNeeded(outerScope, onlyClassifiers);

    if (qualifier == null) {
      return lookupDescriptorsForSimpleNameReference(
          referenceExpression,
          filteredScope,
          outerScope,
          trace,
          LookupMode.ONLY_CLASSES_AND_PACKAGES,
          false,
          true);
    }
    Collection<DeclarationDescriptor> declarationDescriptors =
        lookupDescriptorsForUserType(qualifier, outerScope, trace, false);
    return lookupSelectorDescriptors(
        referenceExpression,
        declarationDescriptors,
        trace,
        filteredScope,
        LookupMode.ONLY_CLASSES_AND_PACKAGES,
        true);
  }