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
1
vote
2 answers

How to add a line comment just after a method with JavaParser

What I want to do I am trying to add a single-line comments around a method annotated with @lombok.Generated to tell Parasoft Jtest to suppress the reporting of findings in the method like this: // parasoft-begin-suppress ALL @lombok.Generated void…
SATO Yusuke
  • 1,600
  • 15
  • 39
1
vote
2 answers

How could i inherit a class using github.parser without deprication warrings

I am using Com.GitHub.java parser for generating java code. i am facing a problem for generating extends keywords This line "extendsList.add(new ClassOrInterfaceType("CustomEndpointResource"));". This statement is showing deprecated .that means it…
1
vote
1 answer

How to use javaparser plugin of JQAssistant?

I'm trying to use javaparser plugin of JQAssistant using command line. I have done the following: Copied "jqassistant.plugin.javaparser-1.8.0.jar" to "plugin" folder. I also noticed plugin has runtime dependency to…
hmozaffari
  • 31
  • 3
1
vote
1 answer

How to resolve a Maven project?

I have a Maven project using lombok and other external dependencies. I would like to add it to the resolver so that I can work on any of the generated Java files. So far I have tried JavaParserTypeSolver and JarTypeSolver and even tried delomboking…
Saif
  • 2,530
  • 3
  • 27
  • 45
1
vote
1 answer

JavaParser- Removing an operator from the expression at the AST level. How to replace a parent node with its child?

I am doing some work on mutation testing at the Abstract Syntax Tree level. So far, I have dealt with Operator Replacement mutations, which were fairly easy to implement using the JavaParser library (https://github.com/javaparser/javaparser). Below…
1
vote
0 answers

What is the difference between com.google.code.javaparser and com.github.javaparser?

When I am working with com.google.code.javaparser , I found that this parser have less documentation and creating new statements with this parser seems difficult. If I am wrong share the coding snippets to create method and VariableDeclarationExpr…
VA splash
  • 553
  • 1
  • 8
  • 25
1
vote
0 answers

how to get the fully qualified name of a method call when it exists in the source code using javaparser

My test code to excercise various functions of JavaParser: public class test001 { public static void main(String[] args) { test001 t = new test001(); t.run(); } @sample.mkGetSet int g1; @sample.start test001(){ g1 = 14; …
Dave
  • 31
  • 3
1
vote
0 answers

How to extract AST from AspectJ native syntax aspect?

I encountered several specify java files when extracting the ASTs of the all java files of AspectJ. One example is as follows: package aspects; public aspect Logging { pointcut methods () : execution(* *..*(..)) &&…
Vallxy
  • 13
  • 3
1
vote
0 answers

Creating an invalid AST in JavaParser

I am using the JavaParser library and would like to be able to create an invalid AST by omitting variable types. I am trying to create the following: Input code: package org.javaparser.samples; public class Simple { public static void main(String[]…
DaveK
  • 11
  • 1
1
vote
0 answers

JavaParser 3.16.1 using LexicalPreservingPrinter.setup leaks memory

I am using JavaParser 3.16.1, Whenever I use LexicalPreservingPrinter.setup(CompilationUnit node) the memory usage keeps going up. I keep going through a folder full of java files and using javaparser.parse I parse each files , I get a return value…
Maths
  • 15
  • 3
1
vote
0 answers

How to refactor some classes from the maven project into a separate module

I was recently tasked to separate some classes along with all the dependencies and properties, etc from a spring boot microservice project into another new spring boot microservice project. I did it by hand but there were too many redundant things…
user1539343
  • 1,569
  • 6
  • 28
  • 45
1
vote
1 answer

JavaParser and SymbolSolver for Eclipse Scout

I want to analyze dependencies among classes which I have started using JavaParser and it's SymbolResolver for. But it keeps failing when resolving several of the method references on a sample project from Eclipse Scout. Scout uses it's own BEAN…
jofroe
  • 431
  • 1
  • 5
  • 14
1
vote
1 answer

How to get the source code using getRange in javaparser

For example, I can get the begin line and end line, but how do I get the source code between begin line and end line. for the example code here. String[] cmds =new String[2]; String OS = System.getProperty("os.name"); if (OS.startsWith("Windows"))…
heshuguo
  • 21
  • 4
1
vote
2 answers

JavaParser reading a src directory

I've been using a CompilationUnit to parse Java files but now I'd like to parse all files within a directory. I've tried the following however the compilation size is calculated as 0 when I expect it to be the number of Java files within the…
algorhythm
  • 3,304
  • 6
  • 36
  • 56
1
vote
1 answer

How to get original packages names or classes of parsed by JavaParser method parameters

There is a little problem with JavaParser usage. I've parsed source code file and get all methods from parsed interface. Each method has a few parameters. I can get types of this parameters as string, but I couldn't get original package name or…
Jackkobec
  • 5,889
  • 34
  • 34