scope = scopeNode != null ? scopeNode.getScope() : null;
}
if (scope instanceof TypeScope)
{
TypeScope typeScope = (TypeScope)scope;
if (this instanceof BaseDefinitionNode)
{
if (((BaseDefinitionNode)this).hasModifier(ASModifier.STATIC))
scope = typeScope.getStaticScope();
else
scope = typeScope.getInstanceScope();
}
else
{
// Do we need the class or instance scope?
BaseDefinitionNode bdn = (BaseDefinitionNode)this.getAncestorOfType(BaseDefinitionNode.class);
if (bdn instanceof ClassNode)
{
// We must be loose code in a class
scope = typeScope.getStaticScope();
}
else
{
if (bdn != null && bdn.hasModifier(ASModifier.STATIC)
// Namespaces are always static
|| bdn instanceof NamespaceNode)
scope = typeScope.getStaticScope();
else
scope = typeScope.getInstanceScope();
}
}
}
ASScope asScope = scope instanceof ASScope ? (ASScope)scope : null;
return asScope;