Community
Participate
Working Groups
The last few lines of ModelUtils.load select the first content of a multi-rooted Ecore resource. Multi-rooted Ecore resources are valid, and MOFM2T inherently works on a forest since there may be multiple top level template matches. Why should these be constrained to come from the first root? Surely the return from ModelUtils.load should either be a singleton Resource or a Collection of EObject roots?
Ed, The ModelUtils utility class was designed as such, and though we know full well that more than a single root can exist in a model (as mentionned in the javadoc of each of our ModelUtils#load() methods : <p>This will return the first root of the loaded model, other roots can be accessed via the resource's content.</p>), we return the first root for ease of use. Most resources will only contain a single root we need to access (Acceleo's mtl files can only contain a single module, UML files often contain a single Model (though they do contain stereortype applications and the such...), etc). We make this assumption so as not to always iterate on every root, which can be extremely costly with UML. However, if there _are_ actual locations in the code where we should go back up to the resource to check for other roots, then these are bugs. Please raise separate entries for them.