use of org.eclipse.n4js.xtext.scoping.IEObjectDescriptionWithError in project n4js by eclipse.
the class ComposedMemberDescriptionWithError method initSubMessages.
/**
* Combines error messages to one message.
*/
protected boolean initSubMessages(IEObjectDescription[] descriptions, MapOfIndexes<String> indexesPerCode) {
// all subScopes returned same code:
if (indexesPerCode.size() == 1 && indexesPerCode.numberOf(indexesPerCode.firstKey()) == max) {
code = indexesPerCode.firstKey();
int index = indexesPerCode.firstIndex(code);
message = ((IEObjectDescriptionWithError) descriptions[index]).getMessage();
String scopeName = getNameForSubScope(index);
message.replace(scopeName, "all types");
return true;
}
if (indexesPerCode.size() > 0) {
StringBuilder strb = new StringBuilder();
for (String subCode : indexesPerCode.keySet()) {
int index = indexesPerCode.firstIndex(subCode);
IEObjectDescriptionWithError descrWithError = (IEObjectDescriptionWithError) descriptions[index];
String submessage = descrWithError.getMessage();
String scopeName = getNameForSubScope(index);
String allScopeNames = indexesPerCode.getScopeNamesForKey(subCode);
String completeSubMessage;
if (submessage.contains(scopeName)) {
completeSubMessage = submessage.replace(scopeName, allScopeNames);
} else {
if (submessage.endsWith(".")) {
submessage = submessage.substring(0, submessage.length() - 1);
}
completeSubMessage = IssueCodes.getMessageForCOMP_SUBMESSAGES(allScopeNames, submessage);
}
if (strb.length() > 0) {
strb.append(" ");
}
strb.append(completeSubMessage);
}
message = strb.toString();
code = IssueCodes.COMP_SUBMESSAGES;
return true;
}
return false;
}
Aggregations