Beispiel #1
0
  public LazyClassDescriptor(
      @NotNull ResolveSession resolveSession,
      @NotNull DeclarationDescriptor containingDeclaration,
      @NotNull Name name,
      @NotNull JetClassLikeInfo classLikeInfo) {
    this.resolveSession = resolveSession;
    this.name = name;

    if (classLikeInfo.getCorrespondingClassOrObject() != null) {
      this.resolveSession
          .getTrace()
          .record(BindingContext.CLASS, classLikeInfo.getCorrespondingClassOrObject(), this);
    }

    this.originalClassInfo = classLikeInfo;
    JetClassLikeInfo classLikeInfoForMembers =
        classLikeInfo.getClassKind() != ClassKind.ENUM_CLASS
            ? classLikeInfo
            : noEnumEntries(classLikeInfo);
    this.declarationProvider =
        resolveSession
            .getDeclarationProviderFactory()
            .getClassMemberDeclarationProvider(classLikeInfoForMembers);
    this.containingDeclaration = containingDeclaration;
    this.unsubstitutedMemberScope =
        new LazyClassMemberScope(resolveSession, declarationProvider, this);
    this.unsubstitutedInnerClassesScope = new InnerClassesScopeWrapper(unsubstitutedMemberScope);

    this.typeConstructor = new LazyClassTypeConstructor();

    this.kind = classLikeInfo.getClassKind();
    if (kind == ClassKind.OBJECT) {
      this.modality = Modality.FINAL;
    } else {
      Modality defaultModality = kind == ClassKind.TRAIT ? Modality.ABSTRACT : Modality.FINAL;
      JetModifierList modifierList = classLikeInfo.getModifierList();
      this.modality = ModifiersChecker.resolveModalityFromModifiers(modifierList, defaultModality);
    }
    JetModifierList modifierList = classLikeInfo.getModifierList();
    this.visibility =
        ModifiersChecker.resolveVisibilityFromModifiers(modifierList, Visibilities.INTERNAL);
  }
 @NotNull
 private List<AnnotationDescriptor> resolveAnnotations() {
   JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
   JetModifierList modifierList = classInfo.getModifierList();
   if (modifierList != null) {
     AnnotationResolver annotationResolver = resolveSession.getInjector().getAnnotationResolver();
     JetScope scopeForDeclaration =
         getScopeProvider().getResolutionScopeForDeclaration(classInfo.getScopeAnchor());
     return annotationResolver.resolveAnnotationsWithArguments(
         scopeForDeclaration, modifierList, resolveSession.getTrace());
   } else {
     return Collections.emptyList();
   }
 }
Beispiel #3
0
 @Override
 public List<AnnotationDescriptor> getAnnotations() {
   if (annotations == null) {
     JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
     JetModifierList modifierList = classInfo.getModifierList();
     if (modifierList != null) {
       AnnotationResolver annotationResolver =
           resolveSession.getInjector().getAnnotationResolver();
       annotations =
           annotationResolver.resolveAnnotations(
               resolveSession.getResolutionScope(classInfo.getScopeAnchor()),
               modifierList,
               resolveSession.getTrace());
     } else {
       annotations = Collections.emptyList();
     }
   }
   return annotations;
 }
  public LazyClassDescriptor(
      @NotNull ResolveSession resolveSession,
      @NotNull DeclarationDescriptor containingDeclaration,
      @NotNull Name name,
      @NotNull JetClassLikeInfo classLikeInfo) {
    super(containingDeclaration, name);
    this.resolveSession = resolveSession;

    if (classLikeInfo.getCorrespondingClassOrObject() != null) {
      this.resolveSession
          .getTrace()
          .record(BindingContext.CLASS, classLikeInfo.getCorrespondingClassOrObject(), this);
    }

    this.originalClassInfo = classLikeInfo;
    JetClassLikeInfo classLikeInfoForMembers =
        classLikeInfo.getClassKind() != ClassKind.ENUM_CLASS
            ? classLikeInfo
            : noEnumEntries(classLikeInfo);
    this.declarationProvider =
        resolveSession
            .getDeclarationProviderFactory()
            .getClassMemberDeclarationProvider(classLikeInfoForMembers);

    this.unsubstitutedMemberScope =
        new LazyClassMemberScope(resolveSession, declarationProvider, this);
    this.unsubstitutedInnerClassesScope = new InnerClassesScopeWrapper(unsubstitutedMemberScope);

    this.typeConstructor = new LazyClassTypeConstructor();

    JetModifierList modifierList = classLikeInfo.getModifierList();
    this.kind = classLikeInfo.getClassKind();
    if (kind.isObject()) {
      this.modality = Modality.FINAL;
    } else {
      Modality defaultModality = kind == ClassKind.TRAIT ? Modality.ABSTRACT : Modality.FINAL;
      this.modality = resolveModalityFromModifiers(modifierList, defaultModality);
    }
    this.visibility = resolveVisibilityFromModifiers(modifierList, getDefaultClassVisibility(this));
    this.isInner = isInnerClass(modifierList);

    StorageManager storageManager = resolveSession.getStorageManager();
    this.thisAsReceiverParameter =
        storageManager.createLazyValue(
            new Function0<ReceiverParameterDescriptor>() {
              @Override
              public ReceiverParameterDescriptor invoke() {
                return DescriptorFactory.createLazyReceiverParameterDescriptor(
                    LazyClassDescriptor.this);
              }
            });
    this.annotations =
        storageManager.createLazyValue(
            new Function0<List<AnnotationDescriptor>>() {
              @Override
              public List<AnnotationDescriptor> invoke() {
                return resolveAnnotations();
              }
            });
    this.classObjectDescriptor =
        storageManager.createNullableLazyValue(
            new Function0<ClassDescriptor>() {
              @Override
              public ClassDescriptor invoke() {
                return computeClassObjectDescriptor();
              }
            });
    this.scopeForClassHeaderResolution =
        storageManager.createLazyValue(
            new Function0<JetScope>() {
              @Override
              public JetScope invoke() {
                return computeScopeForClassHeaderResolution();
              }
            });
    this.scopeForMemberDeclarationResolution =
        storageManager.createLazyValue(
            new Function0<JetScope>() {
              @Override
              public JetScope invoke() {
                return computeScopeForMemberDeclarationResolution();
              }
            });
    this.scopeForPropertyInitializerResolution =
        storageManager.createLazyValue(
            new Function0<JetScope>() {
              @Override
              public JetScope invoke() {
                return computeScopeForPropertyInitializerResolution();
              }
            });
  }