I think there is an easier solution. Use the fully qualified name in
the generated code when referring to the types defined by the type
system descriptor file. That way you can leave the import statements as
they are. The generated code for types named 'Feature' and 'Type' can
each be fixed with three changes to the generated code in the files with
the suffix "_Type". (Note that creating a type called "Feature"
generates error-free code if you don't add any features to the type.)
Personally, I don't think all possible names for types need to be
accommodated - and some should be actively discouraged such as "JCas" -
but this is a moot point with the above solution.
Marshall Schor wrote:
The JCasGen code already has a test to check for "reserved" Feature
names. These are typically names that are part of the
FeatureStructure interface, starting with get or set. For instance,
there is a getType() - so if you had a feature named "Type", this
would conflict.
The easy fix for this case would be as you suggested: to replace all
refs to Feature in the generated code with the fully qualified name,
and remove the import. The downside is that this would make the
generated code more un-readable (not that anyone reads it :-).
If we did this for other imported things: JCas, JCasRegistry, CASImpl,
FSGenerator, FeatureStructure, TypeImpl,
Type, FeatureImpl, Annotation_Type, it might make the code look quite
hard to read.
A more complex fix could be to only do this if the defined type was a
conflicting name, and then only for that type.
Perhaps you can take a look at the JCasGen code and propose a patch?
-Marshall