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

How know a variable is read or modified using JavaParser

I am using JavaParser to parse Java applications. I need a function to return the number of cases that a variable in a method body is read or modified. As an example, the function should determines variable x in the below code is read two times and…
Iman
  • 91
  • 7
0
votes
0 answers

java to parse/extract Vietnamese characters from a xml file

This is what i have : Document xmlDoc = XmlUtils.getXMLDocument(custData); if (xmlDoc == null) { obj.setErr_message("Invalid form data"); return obj; } if…
sandesh b n
  • 15
  • 1
  • 7
0
votes
0 answers

Unable to find Parser.varContext

Trying to follow the example in definitive antlr 4 reference and stuck on page 147 where i cannot find the reference to parser.VarContext for my java grammar.** - I need to get to the ID and i cannot find VarContext, only a VarLocalContext which…
Javatoneo
  • 11
  • 2
0
votes
0 answers

JavaParser SymbolSolver and JGit to find method qualified name for a given commit

Consider the following code: mt.resolve().getQualifiedSignature(); Here mt is of type MethodDeclaration, and it might come from a MethodCallExpr. Now in order it to work accurately, I need to set the following: CombinedTypeSolver…
0
votes
1 answer

Javaparser collect multiple orphan and not attached comments from inner/nested class definition

I am writing a tool for collecting class comments, and I would like to gather all comments that are logically attached to a class by developers: public abstract class A { private Integer d; // comment line /** * javadoc comment …
0
votes
1 answer

Get all variable names in methods

I would like to retrieve all variable names in all methods of a java file. Example Like a Person.java contains class Person { private String firstName; private String lastName; public static void main() { String test =…
user3413646
  • 167
  • 2
  • 11
0
votes
1 answer

Javaparser: How to get the name of the method that a Node belongs to?

For an assignment, I have to find nodes in a java class that meet a certain requirement(being useless). I figured out how to find the required nodes and add them to a separate list but the assignment requires that I list the method names that these…
pkovacs92
  • 1
  • 2
0
votes
1 answer

Parse Java code with JavaParser and find the statement type of parent nodes

I have made a small program that uses JavaParser [1] to parse Java code and identify the types of statements that appear in the code. This has been implemented successfully. What I want to do next, and is a bit tricky, is to find the parent node for…
John Stef
  • 585
  • 1
  • 4
  • 16
0
votes
1 answer

JSoup not sees table on web page

I want to get a table from a web page: ...
I use Element market = page.select("table[class=coupon-row-item coupone-labels").first(); And get Exception in thread "main"…
0
votes
1 answer

what is the functional difference between VoidVisitorAdapter and GenericVisitorAdapter in JavaParser

what is the functional difference between VoidVisitorAdapter and GenericVisitorAdapter in JavaParser. I am using both , but they seem to provide the same functionality .
sangram
  • 3
  • 1
0
votes
1 answer

How to use JavaParser to walk over all the nodes of AST (abstract syntax tree) of some Java source code?

I am trying to build a translator of Java source code to other object-oriented programming languages. For this I want to traverse the whole AST (generated by JavaParser) and gather each and every component of the Java source code and then…
0
votes
1 answer

What would be the problem in providing this keyword for Java's lambda body?

Consider the following examples Consumer f1 = new Consumer<>() { @Override public void accept(Long value) { if (value < 5) { this.accept(value + 1); //this refers to the anonymous context. } …
Amrish Kumar
  • 308
  • 3
  • 12
0
votes
0 answers

Can Eclipse JDT find corresponding test class from source class

Suppose I have source class with inheritance like (baseClassA -> subClassB), I would like to find if there any (testClassA -> testClassB). I know I can find it in IDE, but I would like to extract the data automatically.
RickyY9
  • 45
  • 6
0
votes
1 answer

Is there a way to get all the statements in a method without manually traversing the AST

just wondering if there is a way to get all the statements in a method without manually traversing the AST of a method. So far I've tried to get all of the statements by manually traversing through the tree which is generally a bad idea and tricky…
0
votes
1 answer

How to automate tracing concern implementation in Java

Consider the common problem of adding tracing to your code. Suppose AspectJ or Spring AOP approach is NOT something you want to do - what other approaches are possible, besides simply adding the traces manually? Supposedly Spoon or JavaParser are…
aleksander_si
  • 1,021
  • 10
  • 28