use of org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method testNoWarningsOnJavaKotlinInheritance.
public void testNoWarningsOnJavaKotlinInheritance() throws Exception {
// This test checks that there are no PARAMETER_NAME_CHANGED_ON_OVERRIDE or DIFFERENT_NAMES_FOR_THE_SAME_PARAMETER_IN_SUPERTYPES
// warnings when subclassing in Kotlin from Java binaries (in case when no parameter names are available for Java classes)
KotlinTestUtils.compileJavaFiles(Collections.singletonList(getTestDataFileWithExtension("java")), Arrays.asList("-d", tmpdir.getPath()));
KotlinCoreEnvironment environment = createEnvironment(Collections.singletonList(tmpdir));
AnalysisResult result = JvmResolveUtil.analyze(KotlinTestUtils.loadJetFile(environment.getProject(), getTestDataFileWithExtension("kt")), environment);
result.throwIfError();
BindingContext bindingContext = result.getBindingContext();
AnalyzerWithCompilerReport.Companion.reportDiagnostics(bindingContext.getDiagnostics(), new PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false));
assertEquals("There should be no diagnostics", 0, Iterables.size(bindingContext.getDiagnostics()));
}
use of org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector in project kotlin by JetBrains.
the class StdlibTest method createEnvironment.
@Override
protected KotlinCoreEnvironment createEnvironment() {
@SuppressWarnings("deprecation") File[] runtimeClasspath = ForTestCompileRuntime.runtimeClassesForTests();
CompilerConfiguration configuration = KotlinTestUtils.newConfiguration(ConfigurationKind.JDK_NO_RUNTIME, TestJdkKind.FULL_JDK, runtimeClasspath);
JvmContentRootsKt.addJvmClasspathRoot(configuration, ForTestCompileRuntime.kotlinTestJarForTests());
File junitJar = new File("libraries/lib/junit-4.11.jar");
assertTrue(junitJar.exists());
JvmContentRootsKt.addJvmClasspathRoot(configuration, junitJar);
ContentRootsKt.addKotlinSourceRoot(configuration, KotlinTestUtils.getHomeDirectory() + "/libraries/stdlib/test");
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, new PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false));
KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
ModuleVisibilityManager moduleVisibilityManager = ModuleVisibilityManager.SERVICE.getInstance(environment.getProject());
for (File path : runtimeClasspath) {
moduleVisibilityManager.addFriendPath(path.getPath());
}
return environment;
}
use of org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector in project kotlin by JetBrains.
the class BasicTest method translateFiles.
private void translateFiles(@NotNull List<KtFile> jetFiles, @NotNull File outputFile, @NotNull MainCallParameters mainCallParameters, @NotNull JsConfig config) throws Exception {
K2JSTranslator translator = new K2JSTranslator(config);
TranslationResult translationResult = translator.translate(jetFiles, mainCallParameters);
if (!(translationResult instanceof TranslationResult.Success)) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintingMessageCollector collector = new PrintingMessageCollector(new PrintStream(outputStream), MessageRenderer.PLAIN_FULL_PATHS, true);
AnalyzerWithCompilerReport.Companion.reportDiagnostics(translationResult.getDiagnostics(), collector);
String messages = new String(outputStream.toByteArray(), "UTF-8");
throw new AssertionError("The following errors occurred compiling test:\n" + messages);
}
TranslationResult.Success successResult = (TranslationResult.Success) translationResult;
OutputFileCollection outputFiles = successResult.getOutputFiles(outputFile, getOutputPrefixFile(), getOutputPostfixFile());
File outputDir = outputFile.getParentFile();
assert outputDir != null : "Parent file for output file should not be null, outputFilePath: " + outputFile.getPath();
OutputUtilsKt.writeAllTo(outputFiles, outputDir);
processJsProgram(successResult.getProgram(), jetFiles);
}
Aggregations