Example #1
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();
 }
Example #2
0
 @NotNull
 protected String loadFileByFullPath(@NotNull String fullPath) {
   try {
     File file = new File(fullPath);
     String content = FileUtil.loadFile(file, Charsets.UTF_8.name(), true);
     myFiles = CodegenTestFiles.create(file.getName(), content, myEnvironment.getProject());
     return content;
   } catch (IOException e) {
     throw new RuntimeException(e);
   }
 }
  public void testNoAssertionsForKotlinFromBinary() throws Exception {
    CompilerConfiguration configuration =
        JetTestUtils.compilerConfigurationForTests(
            ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK);
    JetCoreEnvironment tmpEnvironment =
        new JetCoreEnvironment(getTestRootDisposable(), configuration);
    GenerationState state =
        generateCommon(
            ClassBuilderFactories.TEST,
            tmpEnvironment,
            CodegenTestFiles.create(
                tmpEnvironment.getProject(),
                new String[] {"notNullAssertions/noAssertionsForKotlin.kt"}));
    File compiledDirectory = new File(FileUtil.getTempDirectory(), "kotlin-classes");
    CompileEnvironmentUtil.writeToOutputDirectory(state.getFactory(), compiledDirectory);

    setUpEnvironment(true, false, compiledDirectory);

    loadFile("notNullAssertions/noAssertionsForKotlinMain.kt");

    assertNoIntrinsicsMethodIsCalled(PackageClassUtils.getPackageClassName(FqName.ROOT));
  }
Example #4
0
 @NotNull
 protected Class<?> generateFileClass() {
   FqName fileClassFqName =
       JvmFileClassUtil.getFileClassInfoNoResolve(myFiles.getPsiFile()).getFileClassFqName();
   return generateClass(fileClassFqName.asString());
 }
Example #5
0
 protected void loadFiles(@NotNull String... names) {
   myFiles = CodegenTestFiles.create(myEnvironment.getProject(), names);
 }
Example #6
0
 protected void loadText(@NotNull String text) {
   myFiles =
       CodegenTestFiles.create(DEFAULT_TEST_FILE_NAME + ".kt", text, myEnvironment.getProject());
 }