Exemplo n.º 1
0
  private void resolveFunctionAndPropertyHeaders() {
    for (Map.Entry<JetFile, WritableScope> entry : context.getNamespaceScopes().entrySet()) {
      JetFile namespace = entry.getKey();
      WritableScope namespaceScope = entry.getValue();
      NamespaceLike namespaceDescriptor = context.getNamespaceDescriptors().get(namespace);

      resolveFunctionAndPropertyHeaders(
          namespace.getDeclarations(),
          namespaceScope,
          namespaceScope,
          namespaceScope,
          namespaceDescriptor);
    }
    for (Map.Entry<JetClass, MutableClassDescriptor> entry : context.getClasses().entrySet()) {
      JetClass jetClass = entry.getKey();
      MutableClassDescriptor classDescriptor = entry.getValue();

      resolveFunctionAndPropertyHeaders(
          jetClass.getDeclarations(),
          classDescriptor.getScopeForMemberResolution(),
          classDescriptor.getScopeForInitializers(),
          classDescriptor.getScopeForMemberResolution(),
          classDescriptor);
      //            processPrimaryConstructor(classDescriptor, jetClass);
      //            for (JetSecondaryConstructor jetConstructor :
      // jetClass.getSecondaryConstructors()) {
      //                processSecondaryConstructor(classDescriptor, jetConstructor);
      //            }
    }
    for (Map.Entry<JetObjectDeclaration, MutableClassDescriptor> entry :
        context.getObjects().entrySet()) {
      JetObjectDeclaration object = entry.getKey();
      MutableClassDescriptor classDescriptor = entry.getValue();

      resolveFunctionAndPropertyHeaders(
          object.getDeclarations(),
          classDescriptor.getScopeForMemberResolution(),
          classDescriptor.getScopeForInitializers(),
          classDescriptor.getScopeForMemberResolution(),
          classDescriptor);
    }

    // TODO : Extensions
  }
Exemplo n.º 2
0
 private void processSecondaryConstructor(
     MutableClassDescriptor classDescriptor, JetSecondaryConstructor constructor) {
   if (classDescriptor.getKind() == ClassKind.TRAIT) {
     //            context.getTrace().getErrorHandler().genericError(constructor.getNameNode(), "A
     // trait may not have a constructor");
     context.getTrace().report(CONSTRUCTOR_IN_TRAIT.on(constructor.getNameNode()));
   }
   ConstructorDescriptor constructorDescriptor =
       context
           .getDescriptorResolver()
           .resolveSecondaryConstructorDescriptor(
               classDescriptor.getScopeForMemberResolution(), classDescriptor, constructor);
   classDescriptor.addConstructor(constructorDescriptor, context.getTrace());
   context.getConstructors().put(constructor, constructorDescriptor);
   context.getDeclaringScopes().put(constructor, classDescriptor.getScopeForMemberLookup());
 }