Пример #1
0
  private void checkFunction(
      JetDeclarationWithBody function, final @NotNull JetType expectedReturnType) {
    assert function instanceof JetDeclaration;

    JetExpression bodyExpression = function.getBodyExpression();
    if (bodyExpression == null) return;
    JetFlowInformationProvider flowInformationProvider =
        new JetFlowInformationProvider((JetDeclaration) function, trace);

    boolean isPropertyAccessor = function instanceof JetPropertyAccessor;
    if (!isPropertyAccessor) {
      flowInformationProvider.recordInitializedVariables();
    }

    if (topDownAnalysisParameters.isDeclaredLocally()) return;

    flowInformationProvider.checkDefiniteReturn(expectedReturnType);

    if (!isPropertyAccessor) {
      // Property accessor is checked through initialization of a class/object or package properties
      // (at 'checkDeclarationContainer')
      flowInformationProvider.markUninitializedVariables();
    }

    flowInformationProvider.markUnusedVariables();

    flowInformationProvider.markUnusedLiteralsInBlock();
  }
Пример #2
0
 @Override
 public boolean completeAnalysisNeeded(@NotNull PsiElement element) {
   PsiFile containingFile = element.getContainingFile();
   boolean result =
       containingFile != null
           && topDownAnalysisParameters.getAnalyzeCompletely().apply(containingFile);
   if (!result) {
     debug(containingFile);
   }
   return result;
 }
Пример #3
0
  private void checkDeclarationContainer(JetDeclarationContainer declarationContainer) {
    // A pseudocode of class/object initialization corresponds to a class/object
    // or initialization of properties corresponds to a package declared in a file
    JetFlowInformationProvider flowInformationProvider =
        new JetFlowInformationProvider((JetElement) declarationContainer, trace);
    flowInformationProvider.recordInitializedVariables();

    if (topDownAnalysisParameters.isDeclaredLocally()) return;

    flowInformationProvider.markUninitializedVariables();
  }
Пример #4
0
  public void resolveBehaviorDeclarationBodies() {

    resolveDelegationSpecifierLists();
    resolveClassAnnotations();

    resolvePropertyDeclarationBodies();
    resolveAnonymousInitializers();
    resolvePrimaryConstructorParameters();

    resolveSecondaryConstructorBodies();
    resolveFunctionBodies();

    if (!topDownAnalysisParameters.isDeclaredLocally()) {
      computeDeferredTypes();
    }
  }