Questions tagged [javaparser]

A Java Parser with AST (abstract syntax tree) generation and visitor support.

Javaparser is a Java 1.0..9 Parser with AST (abstract syntax tree) generation and visitor support. The AST records the source code structure, javadoc and comments. It is also possible to change the AST nodes or create new ones to modify the source code.

Main features

  • lightweight
  • good performance
  • easy to use
  • lexical preservation
  • AST can be modified
  • AST can be created from scratch
  • comments support
192 questions
0
votes
1 answer

javaparser Symbol solver: I can resolve inherited classes of a class but cannot resolve anything else

I have setup the JavaSymbolSolver like below: Instance Variables: private CombinedTypeSolver combinedTypeSolver = new CombinedTypeSolver(); private JavaSymbolSolver symbolSolver; private ParserConfiguration parserConfiguration = new…
nfountou
  • 11
  • 4
0
votes
2 answers

How to speed up JavaParser

I'm using JavaParser v3.13.5 to build AST from an expressions. I have spotted that parsing expression even simple like Objects.equals(a, b) takes up too much time (~0.15 s). Are there any options, besides ParserConfiguration, to speed up…
matoni
  • 2,479
  • 21
  • 39
0
votes
0 answers

Is there any java Parser available to parse rabbitmq.conf (erlang) file?

I know that in rabbitmq latest versions, they have simplified the template of rabbitmq.conf file. But for the older versions it has a more complex format, which is more dynamic than structured. I need to read and write those conf files through…
indhu
  • 56
  • 5
0
votes
1 answer

JavaParser add ArrayList as method return type

I'm trying to create a new method using the JavaParser API below, where I need to define my method return type. My method return type is ArrayList. I'm wondering if anyone knows how it is possible to create such a method return type, which…
media
  • 433
  • 5
  • 19
0
votes
1 answer

How can I get the data type of a switch statement with the javaparser?

How can I get the data type of a switch statement with the Java parser? Currently with getSelector() I can only get it as a Name expression which does not have the type.
Zotov
  • 265
  • 1
  • 8
  • 20
0
votes
2 answers

How can i search in java file using javaParser?

I have a problem that I changed the class name in java class using javaParser and now I want to change all references from the old name to the new name. For example, if I have a java class like this class A{ private static final Logger log4j =…
Eslam Ashour
  • 113
  • 12
0
votes
2 answers

JavaParser how to get the original line-size of a block-statement?

I am using JavaParser for a code analysis project, where I read a Java source-file and generate an AST (abstract-syntax-tree) for analysis. I need to determine the original number of lines spanned by a given block-statement from an AST. …
Daniel Valland
  • 1,057
  • 4
  • 21
  • 45
0
votes
3 answers

How to use JavaParser to add new methods to a parsing file?

I have parsed a java file and get the Compilation Unit CompilationUnit cu = JavaParser.parse(in); in a java file How can I add some new methods by using this cu? I just want to add the new methods in my original class.
asdfghjkl
  • 1
  • 1
0
votes
1 answer

How to add elements before other elements using javaparser?

I try to add new FieldDeclarations to my Main Class in CompilationUnit before all other existing FieldDeclarations. mainClassInCompilationUnitDeclaration.addPrivateField("Type", "fieldName"); Where mainClassInCompilationUnitDeclaration is a…
StefanLe
  • 11
  • 3
0
votes
1 answer

How to obtain annotation qualified name using Javasymbol solver?

I'm writing a library based on JavaParser, using Javasymbol solver to resolve class names on source files. I'm trying to obtain qualified class names of annotations to classes and methods, but at the moment I'm not able to obtain them. My current…
Luis M. Villa
  • 159
  • 11
0
votes
1 answer

Java: how to use JavaParser to get number of identifiers of a Java class

I want to use JavaParser to get the number of identifiers that a java class has. I downloaded JavaParser jar file and added it to my project, then, I followed some of these instructions and now I am able to programatically parse some Java classes…
undisp
  • 711
  • 3
  • 11
  • 34
0
votes
1 answer

get method statements using javaparser

Is it possible to get list of method statements without comments, i used method.getBody() and this is the output /* set the value of the age integer to 32 */ int age = 32; I want to make statements only are the outcome like this int age = 32;
M.Shaltoot
  • 33
  • 7
0
votes
0 answers

JavaParser. How to convert jpa to POJO

I have JPA Entity @Entity @Table(name = "PEOPLES_TABLE") public class peoplesTable { @Id @Column(name = "ID", nullable = false, length = 36) private String id; @Column(name = "Name", nullable = false, length = 255) private…
0
votes
1 answer

Error while parsing for-loop using javaparse

It's continuous of my previous question: How to parse a for-loop using Javaparser?. I'm trying to parse this incorrect for-loop: FOR(j, k, 15, >, -); to the correct form: for (var j = k; j > 15; j--){}. It means to parse Class.java to the class…
Viola
  • 487
  • 1
  • 10
  • 33
0
votes
2 answers

How to parse a for-loop using Javaparser?

I need using javaparser to parse uncorrect form of the for-loop to the correct form. My loop has 5 arguments: index of the loop (i); initial value of the index. It can be other value (for example, k) or int value (10); value of the loop invariant…
Viola
  • 487
  • 1
  • 10
  • 33