diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemBinding.java index 514fa2d5248..b7606199ada 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IProblemBinding.java @@ -38,6 +38,19 @@ public interface IProblemBinding extends IBinding, IScope, IType { * @return */ public IASTNode getASTNode(); + + /** + * returns the file name this problem occured in if known. + * @return + */ + public String getFileName(); + + /** + * returns the line number for this problem if known + * @return + */ + public int getLineNumber(); + /* * Parser Semantic Problems * All Semantic problems take a char[] as an argument diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java index cae02d56d8c..9850dec316b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/ProblemBinding.java @@ -86,11 +86,7 @@ public class ProblemBinding implements IProblemBinding, IType, IScope { msg = MessageFormat.format(msg, new Object[] { new String(arg) }); } - IASTNodeLocation [] locs = node.getNodeLocations(); - IASTFileLocation fileLoc = node.getTranslationUnit().flattenLocationsToFile( locs ); - Object[] args = new Object[] { msg, fileLoc.getFileName(), new Integer(-1) }; //$NON-NLS-1$ - message = ParserMessages.getFormattedString(PROBLEM_PATTERN, args); - return message; + return msg; } /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() @@ -116,8 +112,8 @@ public class ProblemBinding implements IProblemBinding, IType, IScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getPhysicalNode() */ - public IASTNode getPhysicalNode() throws DOMException { - throw new DOMException( this ); + public IASTNode getPhysicalNode() { + return getASTNode(); } public Object clone(){ @@ -191,4 +187,20 @@ public class ProblemBinding implements IProblemBinding, IType, IScope { public void flushCache() { } + + public String getFileName() { + if( node != null ) + return node.getContainingFilename(); + + return ""; //$NON-NLS-1$ + } + + public int getLineNumber() { + if( node != null ){ + IASTNodeLocation [] locs = node.getNodeLocations(); + IASTFileLocation fileLoc = node.getTranslationUnit().flattenLocationsToFile( locs ); + return fileLoc.getStartingLineNumber(); + } + return -1; + } }