Ejemplo n.º 1
0
 // Temporary
 // Returns true if deprecated constructor is in use, like
 // ENTRY: Enum(arguments) instead of
 // ENTRY(arguments)
 public static boolean enumEntryUsesDeprecatedSuperConstructor(@NotNull JetEnumEntry enumEntry) {
   JetInitializerList initializerList = enumEntry.getInitializerList();
   if (initializerList == null || initializerList.getInitializers().isEmpty()) return false;
   JetTypeReference typeReference = initializerList.getInitializers().get(0).getTypeReference();
   if (typeReference == null) return false;
   JetUserType userType = (JetUserType) typeReference.getTypeElement();
   if (userType == null
       || userType.getReferenceExpression() instanceof JetEnumEntrySuperclassReferenceExpression)
     return false;
   return true;
 }
Ejemplo n.º 2
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);
  }