* in a class and its namespace is the same as the enclosing class' superclass'
* protected namespace; otherwise, return the definition's namespace.
*/
public static INamespaceDefinition getNamespaceInClassContext(IDefinition def, ICompilerProject project)
{
INamespaceDefinition namespace = def.resolveNamespace(project);
IDefinition parent = def.getParent();
if ( namespace != null && parent instanceof ClassDefinition )
{
// Iterate over the superclasses of this method's class.
ClassDefinition cls = (ClassDefinition)parent;
ClassDefinition base = (ClassDefinition)cls.resolveBaseClass(project);
if (base != null)
{
// Adjust the namespace if this is the protected namespace
INamespaceDefinition protectedNS = cls.getProtectedNamespaceReference().resolveNamespaceReference(project);
if (namespace.equals(protectedNS))
namespace = base.getProtectedNamespaceReference().resolveNamespaceReference(project);
}
}