hello everyone i am new to javaParser and i need some help .
i want :
class MethodChangerVisitor extends VoidVisitorAdapter<Void> {
@Override
public void visit(MethodDeclaration n, Void arg) {
System.out.println(n.getParameters().get(0).getType());
System.out.println(n.getParameters().get(0).getName());
System.out.println(n.getParameters().remove(0));//remove parameter not working
//replace statement with other statement ?
System.out.println(n.getBody().get().getStatements().get(0).asExpressionStmt().setExpression("int a = 5;"));
super.visit(n, arg);
}
Hello!
I have a question about chained method calls.
Given a chained invocation (builder pattern):
return new ThingBuilder().withA(a).withB(b).build();
How can I use JavaParser to add another chained invocation to end up with code like this:
return new ThingBuilder().withA(a).withB(b).withC(c).build();
Inserting it anywhere in the chain (before build()
) is fine.
Good morning. I am using LexicalPreservingPrinter to do some code modifications, and it works well, but I can't figure out how to insert whitespace where I need it. My goal is to replace code like
function(new RuntimeException("abc"),
anArgument,
anotherArgument);
with
new RuntimeException("abc",
anArgument,
anotherArgument);
But I can't get the newlines in the replacement, I can only get
new RuntimeException("abc", anArgument, anotherArgument);
Is it possible to do what I want?
int x, b, abc;
)
Assuming that hidden classes (#2886) don't affect anything (I don't think it does, but I don't entirely understand the JEP), we can then formally tick javaparser off as supporting java 15... which would be rather nice! :D
After that, it's just records to go for java 16 support :)
@Betty-Wong However, I think it is useful to share experiences that were problematic.
Well, "problematic" for you. But why should I consider your personal interaction with somebody "problematic" for me? The whole thing is very novel to me. I use a lot of different open source tools in my work and the truth is that I almost never have any idea at all of the personalities of the various people who created those things. I honestly just never gave it much thought. To me, it is a very strange idea that I should decide on the tool stack to use in a project because of an opinion about a person I don't know, expressed by another person whom I also don't know. That, of course, is why I asked you whether you had any technical grounds for telling people not to even consider using JavaCC21. That's the question I'm interested in but you didn't answer it.