mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
clean up problem messages and add getLineNumber and getFileName for bug 84148
This commit is contained in:
parent
8558156ee2
commit
5fb6783a6f
2 changed files with 32 additions and 7 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue