mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
PDOM Update - First open declaration out of the PDOM!
This commit is contained in:
parent
bae4e4f3fa
commit
083a674975
3 changed files with 38 additions and 4 deletions
|
@ -10,6 +10,10 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
|
@ -19,4 +23,8 @@ package org.eclipse.cdt.core.dom;
|
|||
*/
|
||||
public interface IPDOM {
|
||||
|
||||
public IBinding resolveBinding(IASTName name) throws CoreException;
|
||||
|
||||
public IASTName[] getDeclarations(IBinding binding) throws CoreException;
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ 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
|
||||
|
@ -118,7 +119,15 @@ public class CASTTranslationUnit extends CASTNode implements
|
|||
return EMPTY_NAME_ARRAY;
|
||||
return resolver.getDeclarations( (IMacroBinding)binding );
|
||||
}
|
||||
return CVisitor.getDeclarations(this, binding);
|
||||
IASTName[] names = CVisitor.getDeclarations(this, binding);
|
||||
if (names.length == 0 && pdom != null) {
|
||||
try {
|
||||
names = pdom.getDeclarations(binding);
|
||||
} catch (CoreException e) {
|
||||
names = null;
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
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.IASTArrayDeclarator;
|
||||
|
@ -93,6 +94,7 @@ 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
|
||||
|
@ -1295,9 +1297,24 @@ public class CVisitor {
|
|||
}
|
||||
return ArrayUtil.trim( IBinding.class, result );
|
||||
}
|
||||
if( blockItem != null)
|
||||
if( blockItem != null) {
|
||||
// We're at the end of our rope, check the PDOM if we can
|
||||
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 (binding == null)
|
||||
return externalBinding( (IASTTranslationUnit) blockItem, name );
|
||||
|
||||
else
|
||||
return binding;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue