Exemplo n.º 1
0
  public static AnalyzeExhaust analyzeOneFileWithJavaIntegrationAndCheckForErrors(
      JetFile file, List<AnalyzerScriptParameter> scriptParameters) {
    AnalyzingUtils.checkForSyntacticErrors(file);

    AnalyzeExhaust analyzeExhaust = analyzeOneFileWithJavaIntegration(file, scriptParameters);

    AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());

    return analyzeExhaust;
  }
Exemplo n.º 2
0
  private static void checkAllResolvedCallsAreCompleted(
      @NotNull List<JetFile> jetFiles, @NotNull BindingContext bindingContext) {
    for (JetFile file : jetFiles) {
      if (!AnalyzingUtils.getSyntaxErrorRanges(file).isEmpty()) {
        return;
      }
    }

    ImmutableMap<JetElement, ResolvedCall<?>> resolvedCallsEntries =
        bindingContext.getSliceContents(BindingContext.RESOLVED_CALL);
    for (Map.Entry<JetElement, ResolvedCall<?>> entry : resolvedCallsEntries.entrySet()) {
      JetElement element = entry.getKey();
      ResolvedCall<?> resolvedCall = entry.getValue();

      DiagnosticUtils.LineAndColumn lineAndColumn =
          DiagnosticUtils.getLineAndColumnInPsiFile(
              element.getContainingFile(), element.getTextRange());

      assertTrue(
          "Resolved call for '" + element.getText() + "'" + lineAndColumn + " is not completed",
          ((MutableResolvedCall<?>) resolvedCall).isCompleted());
    }

    checkResolvedCallsInDiagnostics(bindingContext);
  }
Exemplo n.º 3
0
 @NotNull
 public static ClassFileFactory generateFiles(
     @NotNull JetCoreEnvironment environment, @NotNull CodegenTestFiles files) {
   AnalyzeExhaust analyzeExhaust =
       AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegrationAndCheckForErrors(
           environment.getProject(),
           files.getPsiFiles(),
           files.getScriptParameterTypes(),
           Predicates.<PsiFile>alwaysTrue());
   analyzeExhaust.throwIfError();
   AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
   CompilerConfiguration configuration = environment.getConfiguration();
   GenerationState state =
       new GenerationState(
           environment.getProject(),
           ClassBuilderFactories.TEST,
           Progress.DEAF,
           analyzeExhaust.getBindingContext(),
           files.getPsiFiles(),
           configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, true),
           configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, true),
           /*generateDeclaredClasses = */ true,
           configuration.get(
               JVMConfigurationKeys.ENABLE_INLINE, InlineUtil.DEFAULT_INLINE_FLAG_FOR_TEST));
   KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
   return state.getFactory();
 }
Exemplo n.º 4
0
  public static AnalyzeExhaust analyzeFilesWithJavaIntegrationAndCheckForErrors(
      Project project,
      Collection<JetFile> files,
      List<AnalyzerScriptParameter> scriptParameters,
      Predicate<PsiFile> filesToAnalyzeCompletely) {
    for (JetFile file : files) {
      AnalyzingUtils.checkForSyntacticErrors(file);
    }

    AnalyzeExhaust analyzeExhaust =
        analyzeFilesWithJavaIntegration(
            project, files, scriptParameters, filesToAnalyzeCompletely, false);

    AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());

    return analyzeExhaust;
  }
Exemplo n.º 5
0
 public BindingContext compile(JetFile file) {
   final BindingContext bindingContext =
       AnalyzerFacade.analyzeOneFileWithJavaIntegration(
           file, JetControlFlowDataTraceFactory.EMPTY);
   AnalyzingUtils.throwExceptionOnErrors(bindingContext);
   compileCorrectFiles(
       bindingContext,
       Collections.singletonList(file),
       CompilationErrorHandler.THROW_EXCEPTION,
       true);
   return bindingContext;
   //        NamespaceCodegen codegen = forNamespace(namespace);
   //        bindingContexts.push(bindingContext);
   //        typeMapper = new JetTypeMapper(standardLibrary, bindingContext);
   //        try {
   //            AnalyzingUtils.throwExceptionOnErrors(bindingContext);
   //
   //            codegen.generate(namespace);
   //        }
   //        finally {
   //            bindingContexts.pop();
   //            typeMapper = null;
   //        }
 }