Ejemplo n.º 1
0
    @NotNull
    private MutableClassDescriptor createClassDescriptorForClass(
        @NotNull JetClass klass, @NotNull DeclarationDescriptor containingDeclaration) {
      ClassKind kind = getClassKind(klass);
      // Kind check is needed in order to not consider enums as inner in any case
      // (otherwise it would be impossible to create a class object in the enum)
      boolean isInner = kind == ClassKind.CLASS && klass.isInner();
      MutableClassDescriptor mutableClassDescriptor =
          new MutableClassDescriptor(
              containingDeclaration,
              outerScope,
              kind,
              isInner,
              JetPsiUtil.safeName(klass.getName()));
      c.getClasses().put(klass, mutableClassDescriptor);
      trace.record(
          FQNAME_TO_CLASS_DESCRIPTOR, JetPsiUtil.getUnsafeFQName(klass), mutableClassDescriptor);

      createClassObjectForEnumClass(mutableClassDescriptor);

      JetScope classScope = mutableClassDescriptor.getScopeForMemberDeclarationResolution();

      prepareForDeferredCall(classScope, mutableClassDescriptor, klass);

      return mutableClassDescriptor;
    }
Ejemplo n.º 2
0
    @NotNull
    private MutableClassDescriptor createClassDescriptorForSingleton(
        @NotNull JetClassOrObject declaration, @NotNull Name name, @NotNull ClassKind kind) {
      MutableClassDescriptor descriptor =
          new MutableClassDescriptor(owner.getOwnerForChildren(), outerScope, kind, false, name);

      prepareForDeferredCall(
          descriptor.getScopeForMemberDeclarationResolution(), descriptor, declaration);

      createPrimaryConstructorForObject(declaration, descriptor);
      trace.record(BindingContext.CLASS, declaration, descriptor);

      c.getClasses().put(declaration, descriptor);

      return descriptor;
    }