My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
FAQ  
Frequent asked questions
Featured
Updated Feb 4, 2010 by jges...@gmail.com
  1. Methods who return lists will always return null if there is no element in the list?

Yes, the JavaParser don't initialize empty lists. It will be needed to check if it is null when accessing the getter. To initialize a list is necessary to call the setter method with a instance of a List.

Comment by nat.pr...@gmail.com, Feb 27, 2009

Why not initialise List instance variables to Collections.emptyList()? Then client code doesn't have to worry about null checks.

Comment by quinntay...@mac.com, Jul 23, 2009

I totally agree, they should return an empty list. There is actually an item dedicated to this in Effective Java. Returning null forces the user to check for null — it would be preferable to return an empty list so iterators and for-each loops just work.

Comment by ode...@gmail.com, Jan 28, 2010

does the parser deal with annotations values? specifically can i get the default value?

Comment by green...@gmail.com, Apr 6, 2010

the comments(not javadoc) will be lost after 【JavaParser?.parse()】

so, How could I get comments(not javadoc)?

Comment by jebar...@gmail.com, Apr 26, 2010

Can anybody help me to use java parser(japa.parser)? and please give some example code to use visitor and expressions and also give some example code how to use when to use the methods and classes of java parser(japa.parser) Please send me the code to my mail ID jebarlin@gmail.com

Comment by grzegorz...@gmail.com, May 31, 2010

Q: What is the purpose of the data property in the Node class? Why is it defined as java.lang.Object? The comment says "This attribute can store additional information from semantic analysis." But that doesn't help much. Eclipse finds no references to either of the field, its getter or its setter.

Comment by project member jges...@gmail.com, May 31, 2010

A: This property was designed to do exactly what its javadoc says. There is no reference to this attribute because this project does not implement any kind of semantic analysis. But other projects can use this attribute to associate information to the AST nodes while visiting them. The type of this attribute is java.lang.Object to let compilers implementers be free to store any data type in there. For example, I have written a compiler and used this attribute to store the name bindings and data type bindings.

Comment by grzegorz...@gmail.com, May 31, 2010

@jgesser. Thanks for a quick response. Now I see what was meant.

Comment by lamvak, Jul 8, 2010

Q: there're the ClassOrInterfaceType? and ReferenceType? type classes. how are they related? they both derive from Type, but there's no inheritance between them. and now i try to check a type of a method parameter against a class type (ClassOrInterfaceType?) and i get it's not an instanceof, but it's an instanceof ReferenceType?; where should i use which?

Comment by steven.n...@gmail.com, Jul 30, 2010

How would I go about adding or deleting statements from a CompilationUnit??

Comment by Mark.Zel...@gmail.com, Aug 10, 2010

Hi. Great parser! But I found one bug. Parameters with arrays are not handled. They come in as the primitive types. try compiling something like "public void calculate(double d){}" and you'll see what I mean. The only way to tell if they are arrays is to do .toString().contains("")

Comment by miroslav...@gmail.com, Aug 21, 2010

@Mark, your example wih calculate(double) im assuming shows the "after" whats the before ?

Comment by tak...@gmail.com, Dec 3, 2010

Is there a way to load any given node from a Java code snippet? That is, to load a partial branch of AST?

Currently, I only see a way to generate a CompilationUnit? out of a .java file.

Comment by project member jges...@gmail.com, Dec 6, 2010

Currently you have to parse a CompilationUnit?.

But you can create an issue for this suggestion.

Comment by DFroehl...@gmx.at, Feb 3, 2011

is there any way of telling the start line of the method in a MethodCallExpression? for instance if the following code is parsed:

fooObject.
doStuff(v1, 
v2)

(each on an individual line) then i don't know how to find out on which line the name of the method (doStuff) is, since it only is stored as a string in the MethodCallExpression???, is there any way to do this?

something that would also help me is a way to keep the \n chars when parsing, because then i could simply count for those

Comment by DFroehl...@gmx.at, May 10, 2011

I would still need an answer to the above question, is there a solution to this problem?

Comment by Mariano....@gmail.com, Dec 7, 2011

Because of some Syntax changes in Java 7 (Multiple exception catching, empty generic braces on the initialization of generic objects and switch case statements with Strings), will you provide an update to support also Java7?


Sign in to add a comment
Powered by Google Project Hosting