From 027dc8cb93bcdb70daa9cbca46891c950eb326b1 Mon Sep 17 00:00:00 2001 From: John Camelon Date: Thu, 28 Apr 2005 13:52:34 +0000 Subject: [PATCH] Fixed Bug 93114 - [Parser] ClassCastException found in CPPASTProblem#getMessage() due to LocationMap$MacroExpansionLocation --- .../core/dom/parser/cpp/CPPASTProblem.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblem.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblem.java index 4d9e0adac44..edfd9e7d571 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblem.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTProblem.java @@ -272,12 +272,21 @@ 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 { - file = ""; //$NON-NLS-1$ - offset = 0; + 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);