Generator, get method body

59 views
Skip to first unread message

Manuel Carrasco Moñino

unread,
May 12, 2013, 6:57:35 AM5/12/13
to google-web-tool...@googlegroups.com
Hi all

Is there a way to get the body of a method in a generator? I've seen JMethodBody is used in compile time, but I dont figure out how to get it in generators.

Thanks

Roberto Lublinerman

unread,
May 15, 2013, 5:39:15 PM5/15/13
to google-web-tool...@googlegroups.com
Can you share what you are attempting to do? Generators only get to see structure (class hierarchy and method definitions) as far as I know.

Manuel Carrasco Moñino

unread,
May 23, 2013, 5:28:44 PM5/23/13
to google-web-tool...@googlegroups.com
Hi Roberto, sorry by the delay.

What I'm doing is a generator for presentations. Given a java class with my example methods, create a set of html slides. 

The generator reads the javadoc and the body of the method, and put them in a hash table into the generated class. Then in client side I can use this info to insert the code and wording in my slides using gwtquery.

You can see my generator in github [1], focus on parseJava() in line #73.

Right now I'm using japa.parser.JavaParser [2], but I'm wondering if there is a way to use gwt parsers so as I dont have to import a 3party library.

--
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "Google Web Toolkit Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit-co...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

John A. Tamplin

unread,
May 23, 2013, 5:32:42 PM5/23/13
to Google Web Toolkit Contributors
On Thu, May 23, 2013 at 5:28 PM, Manuel Carrasco Moñino <man...@apache.org> wrote:
What I'm doing is a generator for presentations. Given a java class with my example methods, create a set of html slides. 

The generator reads the javadoc and the body of the method, and put them in a hash table into the generated class. Then in client side I can use this info to insert the code and wording in my slides using gwtquery.

Manuel Carrasco Moñino

unread,
May 23, 2013, 7:56:48 PM5/23/13
to google-web-tool...@googlegroups.com
Thank John for the link.

The ShowcaseGenerator, is actually reading the content of the source files and generating .html files, but I want to extract method bodies and their javadoc so what I need an AST. So my question is more about how to use the gwt ast from a generator. 

 


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors
---
You received this message because you are subscribed to the Google Groups "GWT Contributors" group.

John A. Tamplin

unread,
May 23, 2013, 8:35:33 PM5/23/13
to Google Web Toolkit Contributors
On Thu, May 23, 2013 at 7:56 PM, Manuel Carrasco Moñino <man...@apache.org> wrote:
The ShowcaseGenerator, is actually reading the content of the source files and generating .html files, but I want to extract method bodies and their javadoc so what I need an AST. So my question is more about how to use the gwt ast from a generator.  

The GWT AST is not available to generators, so you will have to build your own -- you can use JDT as that is included with GWT.

--
John A. Tamplin

Roberto Lublinerman

unread,
May 24, 2013, 12:54:06 AM5/24/13
to google-web-tool...@googlegroups.com
Even if it were accessible to the generators the GWT AST does not contain javadocs nor comments. 

Roberto Lublinerman | Software Engineer | rlu...@google.com | 408-500-9148


--

Manuel Carrasco Moñino

unread,
May 24, 2013, 5:55:59 AM5/24/13
to google-web-tool...@googlegroups.com
It seems that the eclipse-jdt-core included in GWT doesnt have certain classes like ASTParser. I would give a  try including the eclipse dependency in my pom.xml.


--

Manuel Carrasco Moñino

unread,
May 24, 2013, 5:56:21 AM5/24/13
to google-web-tool...@googlegroups.com
Good to know. thanks.

Roberto Lublinerman

unread,
May 24, 2013, 6:33:20 AM5/24/13
to google-web-tool...@googlegroups.com
ASTParser should be in eclipse-jdt-core, although there seems to be different AST representation, GWT uses the one in org.eclipse.jdt.internal.compiler.ast whereas the ASTParser works in org.eclipse.jdt.core.dom. JDT has a very thick api to support the eclipse editor and some simple tasks might become overly complex. I wonder if the approach you have taken using a much smaller and simpler parser is not actually better.

John A. Tamplin

unread,
May 24, 2013, 8:48:03 AM5/24/13
to Google Web Toolkit Contributors
On Fri, May 24, 2013 at 6:33 AM, Roberto Lublinerman <rlu...@google.com> wrote:
ASTParser should be in eclipse-jdt-core, although there seems to be different AST representation, GWT uses the one in org.eclipse.jdt.internal.compiler.ast whereas the ASTParser works in org.eclipse.jdt.core.dom. JDT has a very thick api to support the eclipse editor and some simple tasks might become overly complex. I wonder if the approach you have taken using a much smaller and simpler parser is not actually better.

When I needed to parse the source to get parameter names from interface methods (which aren't included in the bytecode), I used CodeSnippetParsingUtil in JDT and it seemed straightforward enough.

--
John A. Tamplin

Manuel Carrasco Moñino

unread,
May 24, 2013, 6:40:47 PM5/24/13
to google-web-tool...@googlegroups.com
Agreed, I've tried to use the eclipse stuff in gwt-dev and my code get much more complex, so finally I keep using javaparser.

Thank guys
- Manolo


On Fri, May 24, 2013 at 12:33 PM, Roberto Lublinerman <rlu...@google.com> wrote:
ASTParser should be in eclipse-jdt-core, although there seems to be different AST representation, GWT uses the one in org.eclipse.jdt.internal.compiler.ast whereas the ASTParser works in org.eclipse.jdt.core.dom. JDT has a very thick api to support the eclipse editor and some simple tasks might become overly complex. I wonder if the approach you have taken using a much smaller and simpler parser is not actually better.

--
Reply all
Reply to author
Forward
0 new messages