use of com.android.ide.common.blame.parser.ParsingFailedException in project android by JetBrains.
the class ManifestMergeFailureParser method parse.
@Override
public boolean parse(@NotNull String line, @NotNull OutputLineReader reader, @NotNull List<Message> messages, @NotNull ILogger logger) throws ParsingFailedException {
Matcher m = ERROR1.matcher(line);
if (m.matches()) {
String sourcePath = m.group(1);
int lineNumber;
try {
lineNumber = Integer.parseInt(m.group(2));
} catch (NumberFormatException e) {
throw new ParsingFailedException(e);
}
String message = m.group(3);
messages.add(new Message(Message.Kind.ERROR, message, new SourceFilePosition(new File(sourcePath), new SourcePosition(lineNumber - 1, -1, -1))));
return true;
}
m = ERROR2.matcher(line);
if (m.matches()) {
String sourcePath = removeLeadingTab(m.group(1)).trim();
int lineNumber;
try {
lineNumber = Integer.parseInt(m.group(2));
} catch (NumberFormatException e) {
throw new ParsingFailedException(e);
}
int column;
try {
column = Integer.parseInt(m.group(3));
} catch (NumberFormatException e) {
throw new ParsingFailedException(e);
}
if (lineNumber == 0 && column == 0) {
// When both line number and column is zero, it is just a message saying "Validation failed, exiting". No need to display it.
String next = reader.peek(0);
if (next != null && next.contains("Validation failed, exiting")) {
reader.readLine();
return true;
}
} else {
String msg = reader.readLine();
if (msg != null) {
msg = removeLeadingTab(msg).trim();
Message.Kind kind = Message.Kind.findIgnoringCase(m.group(4), Message.Kind.ERROR);
messages.add(new Message(kind, msg.trim(), new SourceFilePosition(new File(sourcePath), new SourcePosition(lineNumber - 1, column - 1, -1))));
return true;
}
}
}
return false;
}
Aggregations