Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
0
  @NotNull
  public JetScope getScopeForClassHeaderResolution() {
    if (scopeForClassHeaderResolution == null) {
      WritableScopeImpl scope =
          new WritableScopeImpl(
              JetScope.EMPTY, this, RedeclarationHandler.DO_NOTHING, "Class Header Resolution");
      for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) {
        scope.addClassifierDescriptor(typeParameterDescriptor);
      }
      scope.changeLockLevel(WritableScope.LockLevel.READING);

      scopeForClassHeaderResolution =
          new ChainedScope(
              this,
              scope,
              resolveSession.getResolutionScope(
                  declarationProvider.getOwnerInfo().getScopeAnchor()));
    }
    return scopeForClassHeaderResolution;
  }