From c739209ea07fcf1e7b29cc7a8e31d9475061c84e Mon Sep 17 00:00:00 2001 From: Andrew Niefer Date: Wed, 6 Apr 2005 18:15:54 +0000 Subject: [PATCH] file names in problem bindings, and don't report type problems if nothing was found --- .../cdt/internal/core/dom/parser/ProblemBinding.java | 6 +++++- .../cdt/internal/core/dom/parser/cpp/CPPSemantics.java | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) 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 5feee8129d0..5fac2302b1d 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 @@ -17,8 +17,10 @@ package org.eclipse.cdt.internal.core.dom.parser; import java.text.MessageFormat; import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTNodeLocation; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; @@ -83,7 +85,9 @@ public class ProblemBinding implements IProblemBinding, IType, IScope { msg = MessageFormat.format(msg, new Object[] { new String(arg) }); } - Object[] args = new Object[] { msg, new String("") /*file*/, new Integer(0) /*line*/}; //$NON-NLS-1$ + 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; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java index 40bf3e83f5a..9630acfaf1f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPSemantics.java @@ -461,9 +461,11 @@ public class CPPSemantics { binding = e.getProblem(); } - } - if( data.astName.getPropertyInParent() == IASTNamedTypeSpecifier.NAME && !( binding instanceof IType || binding instanceof ICPPConstructor) ){ - binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.name ); + } + if( binding != null ) { + if( data.astName.getPropertyInParent() == IASTNamedTypeSpecifier.NAME && !( binding instanceof IType || binding instanceof ICPPConstructor) ){ + binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_INVALID_TYPE, data.name ); + } } if( binding != null && !( binding instanceof IProblemBinding ) ){