@Override
protected void analyze(EnumSet<PostProcessStep> set, ASScope scope, Collection<ICompilerProblem> problems)
{
if (set.contains(PostProcessStep.POPULATE_SCOPE))
{
FunctionDefinition definition = buildDefinition();
setDefinition(definition);
// if the parent is an anonymous function, then don't add the function definition to the scope
// we have already added the anonymous function to the scope and this function definition does not
// belong to the scope
if (this.getParent() instanceof FunctionObjectNode)
{
String funcName = definition.getBaseName();
if (funcName.length() == 0)
scope.setAsContainingScopeOfAnonymousFunction(definition);
else
{
// If the parent is an "anonymous" function with a name, then
// the name will have to be visibly within the function body, so it can
// call itself recursively. So make a special closure scope
// Add a closure scope below the containing scope
ASScope closureScope = new ClosureScope(scope);
scope = closureScope; // now build the function scope below this..
scope.addDefinition(definition); // This sets the containing scope of the def
}
}
else
scope.addDefinition(definition); // This sets the containing scope of the def
ScopedBlockNode contents = contentsPart.getContents();
if (contents != null)
{
ASScope localScope = new FunctionScope(scope, contents);
definition.setContainedScope(localScope);
scope = localScope;
}
}
if (set.contains(PostProcessStep.RECONNECT_DEFINITIONS))
{
reconnectDef(scope);
final FunctionDefinition functionDef = this.getDefinition();
if (functionDef != null)
{
scope = functionDef.getContainedScope();
ScopedBlockNode contents = contentsPart.getContents();
// scope can be null for generated binding wrappers of
// getters and setters
if (contents != null && scope != null)
{