scala-ide/scala-ide — pull request #32 by dotta (2011-11-06 19:44:57+00:00)
Title: Fixes #1000711: no-symbol does not have an owner during structure building

To be visible from Java sources, classes nested in a module have to be exposed as children
of the module's companion class (this matches the Scala compiler's behavior). To this end,
when traversing a ClassDef tree node, we were checking its symbol's owner to know if the
declaration was nested in a module. This manipulation was from time to time preventing the
structure builder to correctly traverse the file (and produced an exception:
'java.lang.Error: no-symbol does not have owner').

The issue is that symbols in the structure builder have to be handled with care, as we deal
with trees that are not fully typechecked, and consequently most symbols are not set.

Therefore, I reworked the way we check if a ClassDef is nested in a module, and no symbol is
used this time to carry out the check.

Furthermore, I noticed a slight regression, i.e., ClassDefs nested in a module where no longer
shown as children of the module in the Eclipse Outline (this because they were traversed as
children of the module's companion class, which may not exist in the editor, and hence it would
not be shown in the Outline).
The underneath problem is that the Outline is currently too coupled to the structure builder,
and therefore no real solution exist to correctly build the Outline view (without a major rewriting,
which it can't happen now).
The current solution is to show ClassDefs nested in a module twice if both the module and the
companion class exist. This is not ideal, but in this way ClassDefs nested in a module will
be reported in the Outline view.