Closed rinsley closed 11 years ago
Hello, Is it possible to indicate what is the bug, how to reproduce it and provide a way to have it raised on our platform ? Thanks,
The plugin.xml for org.osate.aadl2.modelsupport implements the org.eclipse.core.runtime.adapters extension point. This extension point is implemented through the class org.osate.aadl2.modelsupport.resources.ModelLoadingAdapter. This is intended to simplify loading of AADL XText models in external tools. This is explained in this article that is referenced in the comments to ModelLoadingAdapter: http://coopology.com/2011/06/easily-load-xtext-files-and-objects-in-eclipse-plugin-or-rcp-projects-using-adapters/
For example, to load a system instance model in an external tool, it should be possible to use this code:
SystemInstance target = (SystemInstance) Platform.getAdapterManager().getAdapter(instanceFile, Element.class);
where instanceFile is the IFile of the .aaxl2 file. However, there is a bug in ModelLoadingAdapter that causes the model that is returned by the above code to always be null. The bug is on lines 51 and 67 of ModelLoadingAdapter. Both of those lines have this:
if (resource.getContents().size() > 1)
when they should have this instead:
if (resource.getContents().size() > 0)
Ok, thanks for the description. Do you have a patch to solve this issue ? If yes, is it possible to get it to apply it or would you mind to make a pull request on github ?
I have sent a pull request.
Merged. Feel free to close this issue if you think this is appropriate. Regards.
Thanks!
The ModelLoadingAdapter cannot be used to load models because of an off by one error. Lines 51 and 67 check if the size of the contents of the model's resource > 1. But the assignments at lines 53 and 69 only need the size of the contents to be > 0. So currently the comparison always fails when the resource only has 1 item in its contents and the model that is returned is null.