use of org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation 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);
}
use of org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation in project kotlin by JetBrains.
the class MavenPluginLogMessageCollector method throwKotlinCompilerException.
public void throwKotlinCompilerException() throws KotlinCompilationFailureException {
throw new KotlinCompilationFailureException(CollectionsKt.map(getCollectedErrors(), new Function1<Pair<CompilerMessageLocation, String>, CompilerMessage>() {
@Override
public CompilerMessage invoke(Pair<CompilerMessageLocation, String> pair) {
CompilerMessageLocation location = pair.getFirst();
String message = pair.getSecond();
String lineContent = location.getLineContent();
int lineContentLength = lineContent == null ? 0 : lineContent.length();
return new CompilerMessage(location.getPath(), CompilerMessage.Kind.ERROR, fixLocation(location.getLine()), fixLocation(location.getColumn()), fixLocation(location.getLine()), Math.min(fixLocation(location.getColumn()), lineContentLength), message);
}
}));
}
Aggregations