diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java index 8daab64b179..c2a66de1e85 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java @@ -124,7 +124,7 @@ public class CASTTranslationUnit extends CASTNode implements try { names = pdom.getDeclarations(binding); } catch (CoreException e) { - names = null; + names = new IASTName[0]; } } return names; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java index cb39304ea14..e41b582bfeb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CVisitor.java @@ -916,7 +916,8 @@ public class CVisitor { binding = scope.getBinding( name, false ); if( binding != null ){ - ((CStructure)binding).addDefinition( compositeTypeSpec ); + if (binding instanceof CStructure) + ((CStructure)binding).addDefinition( compositeTypeSpec ); return binding; } } catch (DOMException e2) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java index f78ebe7e663..58ed5d4ec48 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java @@ -61,6 +61,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation; import org.eclipse.cdt.internal.core.dom.parser.GCCBuiltinSymbolProvider.CPPBuiltinParameter; import org.eclipse.cdt.internal.core.parser.scanner2.ILocationResolver; import org.eclipse.cdt.internal.core.parser.scanner2.InvalidPreprocessorNodeException; +import org.eclipse.core.runtime.CoreException; /** * @author jcamelon @@ -177,7 +178,15 @@ public class CPPASTTranslationUnit extends CPPASTNode implements return EMPTY_NAME_ARRAY; return resolver.getDeclarations( (IMacroBinding)b ); } - return CPPVisitor.getDeclarations( this, b ); + IASTName[] names = CPPVisitor.getDeclarations( this, b ); + if (names.length == 0 && pdom != null) { + try { + names = pdom.getDeclarations(b); + } catch (CoreException e) { + names = new IASTName[0]; + } + } + return names; } /* 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 1701cbdf193..0a4fe28f807 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 @@ -13,6 +13,7 @@ */ package org.eclipse.cdt.internal.core.dom.parser.cpp; +import org.eclipse.cdt.core.dom.IPDOM; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; @@ -124,6 +125,7 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil.ArrayWrapper; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; +import org.eclipse.core.runtime.CoreException; /** * @author aniefer @@ -744,10 +746,22 @@ public class CPPSemantics { } } if( binding == null ){ - if( name instanceof ICPPASTQualifiedName && data.forDefinition() ) - binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND, data.name() ); - else - binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, data.name() ); + // Let's try the pdom + IPDOM pdom = name.getTranslationUnit().getPDOM(); + if (pdom != null) { + try { + binding = pdom.resolveBinding(name); + } catch (CoreException e) { + binding = null; + } + } + // If we're still null... + if (binding == null) { + if( name instanceof ICPPASTQualifiedName && data.forDefinition() ) + binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_MEMBER_DECLARATION_NOT_FOUND, data.name() ); + else + binding = new ProblemBinding( data.astName, IProblemBinding.SEMANTIC_NAME_NOT_FOUND, data.name() ); + } } return binding; }