@Override
protected void analyze(EnumSet<PostProcessStep> set, ASScope scope, Collection<ICompilerProblem> problems)
{
if (set.contains(PostProcessStep.POPULATE_SCOPE))
{
PackageDefinition definition = buildDefinition();
setDefinition(definition);
/*
* This could be improved because neither code model or the
* compiler will ever dig package definitions out of there by name.
* CM won't get them out of a file scope by name because of this
* check here. The compiler won't ever get them out of a file scope
* by name because the namespace specifier on all package
* definitions is the CM implicit namespace. I opted to leave the
* package definitions in the file scope for two reasons: #1. We
* need to pin the package scopes otherwise they and their contents
* will get GC'd. #2. There is code that enumerates the contents of
* the file scope and that code wants to find package definitions in
* there. This could be cleaned up somewhat by having a list of
* package scopes on every file scope and then changing things such
* that package scopes are not added the file scope's symbol table.
*/
scope.addDefinition(definition);
PackageScope packageScope = new PackageScope(scope, definition.getQualifiedName(), contentsNode);
definition.setContainedScope(packageScope);
scope = packageScope;
}
if (set.contains(PostProcessStep.RECONNECT_DEFINITIONS))
{