use of com.android.common.ide.common.blame.Message in project buck by facebook.
the class MergingException method getMessage.
/**
* Computes the error message to display for this error
*/
@NonNull
@Override
public String getMessage() {
List<String> messages = Lists.newArrayListWithCapacity(mMessages.size());
for (Message message : mMessages) {
StringBuilder sb = new StringBuilder();
List<SourceFilePosition> sourceFilePositions = message.getSourceFilePositions();
if (sourceFilePositions.size() > 1 || !sourceFilePositions.get(0).equals(SourceFilePosition.UNKNOWN)) {
sb.append(Joiner.on('\t').join(sourceFilePositions));
}
String text = message.getText();
if (sb.length() > 0) {
sb.append(':').append(' ');
// string to the left of a colon.)
if (!text.startsWith("Error: ")) {
sb.append("Error: ");
}
} else if (!text.contains("Error: ")) {
sb.append("Error: ");
}
// /my/full/path: /my/full/path (Permission denied)
if (sourceFilePositions.size() == 1) {
File file = sourceFilePositions.get(0).getFile().getSourceFile();
if (file != null) {
String path = file.getAbsolutePath();
if (text.startsWith(path)) {
int stripStart = path.length();
if (text.length() > stripStart && text.charAt(stripStart) == ':') {
stripStart++;
}
if (text.length() > stripStart && text.charAt(stripStart) == ' ') {
stripStart++;
}
text = text.substring(stripStart);
}
}
}
sb.append(text);
messages.add(sb.toString());
}
return Joiner.on('\n').join(messages);
}
Aggregations