I am implementing a transformation from a proprietary IDL format into Franca IDL. I got everything runnig except IDL imports. I am currently running into two problems:
1.) When I add an import to the appropriate transformed Franca IDL file I get a NullPointerException when I try to save the transformed IDL.
The transformed Franca IDL itself is saved correctly. But then the ModelPersistenceHandler tries to recursively save all imported models. But at that point it is unable to find the imported model in the resource set although I see it loaded in the debugger. This happens in ModelPersistenceHandler.saveModel(EObject, String, String). It should be line 154 in the current Git HEAD.
When I open the transformed Franca IDL in the Eclipse editor the import is correctly resolved, so this may well be a bug.
2.) I am not sure how I should resolve references to types that are defined in the imported IDL. I was thinking about using the FrancaIDLScopeProvider but as far as I have seen that would require a resource set which is not available during the transformation.
Can somebody help me with this problem?
Kind regards
Klaus
Hi,I am implementing a transformation from a proprietary IDL format into Franca IDL. I got everything runnig except IDL imports. I am currently running into two problems:
1.) When I add an import to the appropriate transformed Franca IDL file I get a NullPointerException when I try to save the transformed IDL.
The transformed Franca IDL itself is saved correctly. But then the ModelPersistenceHandler tries to recursively save all imported models. But at that point it is unable to find the imported model in the resource set although I see it loaded in the debugger. This happens in ModelPersistenceHandler.saveModel(EObject, String, String). It should be line 154 in the current Git HEAD.
When I open the transformed Franca IDL in the Eclipse editor the import is correctly resolved, so this may well be a bug.
2.) I am not sure how I should resolve references to types that are defined in the imported IDL. I was thinking about using the FrancaIDLScopeProvider but as far as I have seen that would require a resource set which is not available during the transformation.
on 1) I will file a bug.
on 2) Ok, my description might have been a bit brief ;-)
I have two IDL files. One file (lets call it decl.idl) defines a set of common datatypes. The second file (lets call it iface.idl) defines an interface that imports decl.idl and uses some of the types declared there in its method signatures.
I have already successfully transformed decl.idl to decl.fidl. Now, I want to transform iface.idl to iface.fidl, using the already transfomed decl.fidl (and the type definitions therein) as import. I am currently using only the filename for the import because URI resolution does not work as I would need it (see https://groups.google.com/d/topic/franca-framework/i9mk19MfLbU/discussion), i.e. the transformed iface.fidl contains the definition
import model "decl.fidl"
Unfortunately, I cannot easily load the imported model because I do not "natively" have access to a resource set. My transformation is called from IFrancaConnector.toFranca() which returns an FModel that is created "in the air" (i.e. not connected to any Resource or ResourceSet) and is saved outside of the connector and transformation classes.
I could, of course, inject a FrancaPersistenceManager into my transformation class and create a local ResourceSet there but then I would have to pass the (parent) path of the iface.fidl into the transformation so that the URI resolution would work. I would definitely find a workaround to do that but it feels a bit clumsy in my opinion.
Therefore, I am asking if there is a best known method to handle this kind of transformation. Maybe it does not yet exist and maybe the Franca interfaces need to be extended at this point.
Kind regards
Klaus
thank you for the hint.
Eventually, I ended up creating the ResourceSet directly in the transformation class because I wanted to have a new, empty resource set for each IDL file to be transformed. After having converted the imports from the source IDL into Franca IDL URIs I just loaded those models into the resource set from within the transformation method (using org.franca.core.utils.ModelPersistenceHandler).
To get the type references resolved I just built a lookup table of qualified type names and FType objects by iterating over all type collections and types in all loaded models.
This worked - at least for a first proof of concept implementation. However, it would be convenient if Franca provided utility classes which can be used by any toFranca() transformation that alredy provide this functionality.
Kind regards
Klaus
PS: After having all imported FModel's and the transformed FModel itself loaded into a common ResourceSet the NullPointerException I have reported in https://code.google.com/a/eclipselabs.org/p/franca/issues/detail?id=102 during saving the model is also gone. However, there should be no NullPointerException if the model to be saved is not completely valid.