This proposed enhancement is in the Sourceforge feature request system.
This is a continuation of the class library translation feature here.
The first version provided for a simple substitution of one symbol table entry
for another but we really need a more complex translation, In the following
We want to:
- Translate the import 'java.lang.System' to the equivalent in the destination language for example 'System'.
- The translation must be able to handle wildcards, for instance 'import java.lang.*;'
- Then we want to translate any external method calls and parameters. In this case we want to translate 'System.out.println' to 'Console.WriteLine'.
- If there is no import 'java.lang.System' but instead we have a system defined locally then we want leave the class name as it is.
- If the text 'java.lang.System' appears in a comment or a string constant then we want leave the string as it is.
Note: the syntax and keywords (such as 'import' to 'using') are translated by parser when reading or XSLT when exporting so do not need to translated by this method.
To implement this we need to go though this sequence:
- Translate the package/method names in the import statements to Java package/method names.
- Load the external references described here with information about other classes in the current packages and packages/classes referenced in import statements.
- All references to classes, methods and parameters must be matched to their definitions which might be in the local file structure or in the external references. When the definition is found it is recorded in the node that uses it as an XPath string.
- Where the definition is an external import it is translated into the equivalent Java name.