Search in sources :

Example 1 with CompilerMessageSeverity

use of org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity in project kotlin by JetBrains.

the class AbstractModuleXmlParserTest method doTest.

protected static void doTest(String xmlPath) throws IOException {
    File txtFile = new File(FileUtil.getNameWithoutExtension(xmlPath) + ".txt");
    ModuleScriptData result = ModuleXmlParser.parseModuleScript(xmlPath, new MessageCollector() {

        @Override
        public void report(@NotNull CompilerMessageSeverity severity, @NotNull String message, @NotNull CompilerMessageLocation location) {
            throw new AssertionError(MessageRenderer.PLAIN_FULL_PATHS.render(severity, message, location));
        }

        @Override
        public void clear() {
        // Do nothing
        }

        @Override
        public boolean hasErrors() {
            throw new UnsupportedOperationException();
        }
    });
    StringBuilder sb = new StringBuilder();
    for (Module module : result.getModules()) {
        sb.append(moduleToString(module)).append("\n");
    }
    String actual = sb.toString();
    if (!txtFile.exists()) {
        FileUtil.writeToFile(txtFile, actual);
        fail("Expected data file does not exist. A new file created: " + txtFile);
    }
    KotlinTestUtils.assertEqualsToFile(txtFile, actual);
}
Also used : ModuleScriptData(org.jetbrains.kotlin.cli.common.modules.ModuleScriptData) CompilerMessageSeverity(org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity) MessageCollector(org.jetbrains.kotlin.cli.common.messages.MessageCollector) Module(org.jetbrains.kotlin.modules.Module) File(java.io.File) CompilerMessageLocation(org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation)

Aggregations

File (java.io.File)1 CompilerMessageLocation (org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation)1 CompilerMessageSeverity (org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity)1 MessageCollector (org.jetbrains.kotlin.cli.common.messages.MessageCollector)1 ModuleScriptData (org.jetbrains.kotlin.cli.common.modules.ModuleScriptData)1 Module (org.jetbrains.kotlin.modules.Module)1