Ejemplo n.º 1
0
  public void process(
      @NotNull TopDownAnalysisContext c,
      @NotNull JetScope outerScope,
      @NotNull PackageLikeBuilder owner,
      @NotNull Collection<? extends PsiElement> declarations) {

    {
      // TODO: Very temp code - main goal is to remove recursion from
      // collectPackageFragmentsAndClassifiers
      Queue<JetDeclarationContainer> forDeferredResolve = new LinkedList<JetDeclarationContainer>();
      forDeferredResolve.addAll(
          collectPackageFragmentsAndClassifiers(c, outerScope, owner, declarations));

      while (!forDeferredResolve.isEmpty()) {
        JetDeclarationContainer declarationContainer = forDeferredResolve.poll();
        assert declarationContainer != null;

        DeclarationDescriptor descriptorForDeferredResolve =
            c.forDeferredResolver.get(declarationContainer);
        JetScope scope = c.normalScope.get(declarationContainer);

        // Even more temp code
        if (descriptorForDeferredResolve instanceof MutableClassDescriptorLite) {
          forDeferredResolve.addAll(
              collectPackageFragmentsAndClassifiers(
                  c,
                  scope,
                  ((MutableClassDescriptorLite) descriptorForDeferredResolve).getBuilder(),
                  declarationContainer.getDeclarations()));
        } else if (descriptorForDeferredResolve instanceof MutablePackageFragmentDescriptor) {
          forDeferredResolve.addAll(
              collectPackageFragmentsAndClassifiers(
                  c,
                  scope,
                  ((MutablePackageFragmentDescriptor) descriptorForDeferredResolve).getBuilder(),
                  declarationContainer.getDeclarations()));
        } else {
          assert false;
        }
      }
    }

    importsResolver.processTypeImports(c);

    createTypeConstructors(
        c); // create type constructors for classes and generic parameters, supertypes are not
            // filled in
    resolveTypesInClassHeaders(
        c); // Generic bounds and types in supertype lists (no expressions or constructor
            // resolution)

    c.setClassesTopologicalOrder(topologicallySortClassesAndObjects(c));

    // Detect and disconnect all loops in the hierarchy
    detectAndDisconnectLoops(c);
  }
Ejemplo n.º 2
0
  public void process(@NotNull TopDownAnalysisContext c) {
    resolveAnnotationConstructors(c);
    resolveConstructorHeaders(c);
    resolveAnnotationStubsOnClassesAndConstructors(c);
    resolveFunctionAndPropertyHeaders(c);

    // SCRIPT: Resolve script declarations
    scriptHeaderResolver.resolveScriptDeclarations(c);

    createFunctionsForDataClasses(c);
    importsResolver.processMembersImports(c);
    checkRedeclarationsInPackages(c);
    checkRedeclarationsInInnerClassNames(c);
  }