예제 #1
0
 @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();
   }
 }
예제 #2
0
                  @Override
                  public List<TypeParameterDescriptor> invoke() {
                    JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo();
                    List<JetTypeParameter> typeParameters = classInfo.getTypeParameters();

                    List<TypeParameterDescriptor> parameters =
                        new ArrayList<TypeParameterDescriptor>(typeParameters.size());
                    for (int i = 0; i < typeParameters.size(); i++) {
                      parameters.add(
                          new LazyTypeParameterDescriptor(
                              resolveSession, LazyClassDescriptor.this, typeParameters.get(i), i));
                    }

                    return parameters;
                  }
예제 #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;
 }
예제 #4
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);
  }
예제 #5
0
  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();
              }
            });
  }