diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java index 97d6ff89d11..7d6c561319c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/IPDOM.java @@ -24,9 +24,11 @@ import org.eclipse.core.runtime.CoreException; */ public interface IPDOM { - public IBinding resolveBinding(IASTName name) throws CoreException; + public IBinding resolveBinding(IASTName name); - public IASTName[] getDeclarations(IBinding binding) throws CoreException; + public IBinding[] resolvePrefix(IASTName name); + + public IASTName[] getDeclarations(IBinding binding); public void delete() throws CoreException; 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 c2a66de1e85..14dd226d3ae 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 @@ -45,7 +45,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult; import org.eclipse.cdt.internal.core.dom.parser.IRequiresLocationInformation; 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 @@ -120,13 +119,8 @@ public class CASTTranslationUnit extends CASTNode implements return resolver.getDeclarations( (IMacroBinding)binding ); } IASTName[] names = CVisitor.getDeclarations(this, binding); - if (names.length == 0 && pdom != null) { - try { - names = pdom.getDeclarations(binding); - } catch (CoreException e) { - names = new IASTName[0]; - } - } + if (names.length == 0 && pdom != null) + names = pdom.getDeclarations(binding); 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 e41b582bfeb..088f42bf4d7 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 @@ -94,7 +94,6 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.ObjectSet; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; -import org.eclipse.core.runtime.CoreException; /** * Created on Nov 5, 2004 @@ -1303,14 +1302,9 @@ public class CVisitor { IASTTranslationUnit tu = (IASTTranslationUnit)blockItem; IPDOM pdom = tu.getPDOM(); binding = null; - if (pdom != null) { - try { - binding = pdom.resolveBinding(name); - } catch (CoreException e) { - // didn't work, null out the binding - binding = null; - } - } + if (pdom != null) + binding = pdom.resolveBinding(name); + if (binding == null) return externalBinding( (IASTTranslationUnit) blockItem, name ); else @@ -1911,6 +1905,11 @@ public class CVisitor { } catch ( DOMException e ) { } } + + IPDOM pdom = name.getTranslationUnit().getPDOM(); + if (pdom != null) + result = (IBinding[])ArrayUtil.addAll(IBinding.class, result, pdom.resolvePrefix(name)); + return (IBinding[]) ArrayUtil.trim( IBinding.class, result ); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java index 8754d07dc06..099b331bdf8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTName.java @@ -55,7 +55,7 @@ public class CPPASTName extends CPPASTNode implements IASTName { } public IBinding[] resolvePrefix() { - return CPPSemantics.prefixLookup(this); + return CPPSemantics.prefixLookup(this); } public void setBinding(IBinding binding) { 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 58ed5d4ec48..d4ce9b4d39e 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,7 +61,6 @@ 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 @@ -179,13 +178,8 @@ public class CPPASTTranslationUnit extends CPPASTNode implements return resolver.getDeclarations( (IMacroBinding)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]; - } - } + if (names.length == 0 && pdom != null) + names = pdom.getDeclarations(b); 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 0a4fe28f807..6c27dfbbf00 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 @@ -125,7 +125,6 @@ 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 @@ -748,13 +747,9 @@ public class CPPSemantics { if( binding == null ){ // Let's try the pdom IPDOM pdom = name.getTranslationUnit().getPDOM(); - if (pdom != null) { - try { - binding = pdom.resolveBinding(name); - } catch (CoreException e) { - binding = null; - } - } + if (pdom != null) + binding = pdom.resolveBinding(name); + // If we're still null... if (binding == null) { if( name instanceof ICPPASTQualifiedName && data.forDefinition() ) @@ -3236,6 +3231,7 @@ public class CPPSemantics { return (IBinding[]) set.keyArray( IBinding.class ); } + public static IBinding [] prefixLookup( IASTName name ){ LookupData data = createLookupData( name, true ); data.prefixLookup = true; @@ -3275,6 +3271,11 @@ public class CPPSemantics { } } } + + IPDOM pdom = name.getTranslationUnit().getPDOM(); + if (pdom != null) + result = (IBinding[])ArrayUtil.addAll(IBinding.class, result, pdom.resolvePrefix(name)); + return (IBinding[]) ArrayUtil.trim( IBinding.class, result ); } diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java index cad5353a175..0545dd321a6 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/dom/InternalASTServiceProvider.java @@ -228,8 +228,10 @@ public class InternalASTServiceProvider implements IASTServiceProvider { // Run the parse and return the completion node parser.parse(); ASTCompletionNode node = parser.getCompletionNode(); - if (node != null) + if (node != null) { + node.getTranslationUnit().setPDOM(PDOM.getPDOM(project)); node.count = scanner.getCount(); + } return node; }