You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@uima.apache.org by Marshall Schor <ms...@schor.com> on 2016/03/08 22:19:03 UTC

suggestions for parsing / modifying Java source code?

Hi,

As part of UIMA V3, I'm looking into tooling that will help users convert their
JCas files from V2 to V3.

I think the best flow might be to do a source - to - source transformation; that
way, everything can be manually checked and arbitrary customizations can be
manually addressed.

To handle the case where perhaps the source from JCas class is hard to find, we
could also provide a decompiler to generate that source (although, without the
comments and most annotations).

Once V2 source is converted to V3, we could then just compile and package those
files, and insure they're in the class path ahead of other versions.

Along these lines, can anyone suggest a suitable framework for doing Java source
-> source transformations? I've seen javaparse [1] (Apache licensed) which looks
promising, but perhaps there's other alternatives.  (I don't think I want an
Eclipse based solution in case the users are not using Eclipse).

Thanks for any suggestions! -Marshall

[1] https://github.com/javaparser/javaparser

Re: suggestions for parsing / modifying Java source code?

Posted by Richard Eckart de Castilho <re...@apache.org>.
Hi,

it should be possible to use the relevant parts of Eclipse JDT without
Eclipse. I have been parsing Java files using JDT in the past in a
plain Java project, but I didn't try AST transformations, or compiling.
But since the Maven compiler plugin can also switch to JDT-based compilations
without having Eclipse installed, I guess it should not be a problem [1].

I think that JDT is probably one of the best options because I believe
it gets updated rather quickly if there are changes to the Java language.

Cheers,

-- Richard

[1] https://kthoms.wordpress.com/2011/01/10/using-the-jdt-compiler-in-normal-maven-builds/

> On 08.03.2016, at 22:19, Marshall Schor <ms...@schor.com> wrote:
> 
> Hi,
> 
> As part of UIMA V3, I'm looking into tooling that will help users convert their
> JCas files from V2 to V3.
> 
> I think the best flow might be to do a source - to - source transformation; that
> way, everything can be manually checked and arbitrary customizations can be
> manually addressed.
> 
> To handle the case where perhaps the source from JCas class is hard to find, we
> could also provide a decompiler to generate that source (although, without the
> comments and most annotations).
> 
> Once V2 source is converted to V3, we could then just compile and package those
> files, and insure they're in the class path ahead of other versions.
> 
> Along these lines, can anyone suggest a suitable framework for doing Java source
> -> source transformations? I've seen javaparse [1] (Apache licensed) which looks
> promising, but perhaps there's other alternatives.  (I don't think I want an
> Eclipse based solution in case the users are not using Eclipse).
> 
> Thanks for any suggestions! -Marshall
> 
> [1] https://github.com/javaparser/javaparser