1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed Bug 93114 - [Parser] ClassCastException found in CPPASTProblem#getMessage() due to LocationMap$MacroExpansionLocation

This commit is contained in:
John Camelon 2005-04-28 13:52:34 +00:00
parent 7c6f79c6bc
commit 027dc8cb93

View file

@ -272,13 +272,22 @@ public class CPPASTProblem extends CPPASTNode implements IASTProblem {
IASTNodeLocation [] locs = getNodeLocations();
String file = null;
int offset = 0;
if( locs != null && locs.length > 0 ){
if( locs != null && locs.length == 1 && locs[0] instanceof IASTFileLocation ){
file = ((IASTFileLocation) locs[0]).getFileName();
offset = locs[0].getNodeOffset();
} else {
IASTFileLocation f = getTranslationUnit().flattenLocationsToFile(locs);
if( f == null )
{
file = ""; //$NON-NLS-1$
offset = 0;
}
else
{
file = f.getFileName();
offset = f.getNodeOffset();
}
}
Object[] args = new Object[] { msg, file, new Integer(offset) }; //$NON-NLS-1$
message = ParserMessages.getFormattedString(AST_PROBLEM_PATTERN, args);
return message;