Ejemplo n.º 1
0
  public void process(@NotNull BodiesResolveContext bodiesResolveContext) {
    for (JetFile file : bodiesResolveContext.getFiles()) {
      checkModifiersAndAnnotationsInPackageDirective(file);
      AnnotationTargetChecker.INSTANCE$.check(file, trace);
    }

    Map<JetClassOrObject, ClassDescriptorWithResolutionScopes> classes =
        bodiesResolveContext.getDeclaredClasses();
    for (Map.Entry<JetClassOrObject, ClassDescriptorWithResolutionScopes> entry :
        classes.entrySet()) {
      JetClassOrObject classOrObject = entry.getKey();
      ClassDescriptorWithResolutionScopes classDescriptor = entry.getValue();

      checkSupertypesForConsistency(classDescriptor);
      checkTypesInClassHeader(classOrObject);

      if (classOrObject instanceof JetClass) {
        JetClass jetClass = (JetClass) classOrObject;
        checkClass(bodiesResolveContext, jetClass, classDescriptor);
        descriptorResolver.checkNamesInConstraints(
            jetClass, classDescriptor, classDescriptor.getScopeForClassHeaderResolution(), trace);
      } else if (classOrObject instanceof JetObjectDeclaration) {
        checkObject((JetObjectDeclaration) classOrObject, classDescriptor);
      }

      checkPrimaryConstructor(classOrObject, classDescriptor);

      modifiersChecker.checkModifiersForDeclaration(classOrObject, classDescriptor);
    }

    Map<JetNamedFunction, SimpleFunctionDescriptor> functions = bodiesResolveContext.getFunctions();
    for (Map.Entry<JetNamedFunction, SimpleFunctionDescriptor> entry : functions.entrySet()) {
      JetNamedFunction function = entry.getKey();
      SimpleFunctionDescriptor functionDescriptor = entry.getValue();

      checkFunction(function, functionDescriptor);
      modifiersChecker.checkModifiersForDeclaration(function, functionDescriptor);
    }

    Map<JetProperty, PropertyDescriptor> properties = bodiesResolveContext.getProperties();
    for (Map.Entry<JetProperty, PropertyDescriptor> entry : properties.entrySet()) {
      JetProperty property = entry.getKey();
      PropertyDescriptor propertyDescriptor = entry.getValue();

      checkProperty(property, propertyDescriptor);
      modifiersChecker.checkModifiersForDeclaration(property, propertyDescriptor);
    }

    for (Map.Entry<JetSecondaryConstructor, ConstructorDescriptor> entry :
        bodiesResolveContext.getSecondaryConstructors().entrySet()) {
      ConstructorDescriptor constructorDescriptor = entry.getValue();
      JetSecondaryConstructor declaration = entry.getKey();
      checkConstructorDeclaration(constructorDescriptor, declaration);
    }
  }
Ejemplo n.º 2
0
  private void resolveFunctionBodies(@NotNull BodiesResolveContext c) {
    for (Map.Entry<JetNamedFunction, SimpleFunctionDescriptor> entry :
        c.getFunctions().entrySet()) {
      JetNamedFunction declaration = entry.getKey();

      LexicalScope scope = c.getDeclaringScope(declaration);
      assert scope != null
          : "Scope is null: " + PsiUtilPackage.getElementTextWithContext(declaration);

      if (!c.getTopDownAnalysisMode().getIsLocalDeclarations()
          && !(bodyResolveCache instanceof BodyResolveCache.ThrowException)
          && expressionTypingServices.getStatementFilter() != StatementFilter.NONE) {
        bodyResolveCache.resolveFunctionBody(declaration).addOwnDataTo(trace, true);
      } else {
        resolveFunctionBody(c.getOuterDataFlowInfo(), trace, declaration, entry.getValue(), scope);
      }
    }
  }