Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
jessechen09
@jessechen09

Hey @jessechen09 - since you have checked out the source code of JavaParser, are you going to modify it? Maybe it is interesting for the JavaParser project?

I'm using javaparser to create ASTs, as we need ASTs for our research project. That said I don't think I'll modify it, unless there is a feature that's missing and is an easy fix.

jessechen09
@jessechen09
In the Node class's toString() method, it prints out the node AND its children, so if I toString() a CompilationUnit, it should print out the whole AST, right? However, I am only getting the original class's code. Did I misunderstand something or did I do something wrong? Thanks
3 replies
image.png
TY
@CTY-git

I cant seem to find this in any documentation but how do you add java.lang.* and javax.* Type Declarations to the compilation unit?
or is there a way to check if a type, found by parsing source code, extends a java.lang.* and javax.* class?

I did set the ReflectionTypeSolver for my parser but java.lang.* and javax.* classes are unresolvable. This prevents me from using isAssignable to determine inheritance.

Thiago Henrique Hüpner
@Thihup
Hi all! I'd like to know if it is possible to parse some Expression Language using the JavaParser. While most of the SimpleJavaParse.parseExpression() would work just fine, they have added some changes to the change, like enabling using "eq" instead of "==", and they have added a new syntax for Lists and Sets ([1,2,3,4], {1,2,3}) and for Map ({"key":"value"}).
In this case it is still possible to use the JavaParser?
Roger Howell
@MysterAitch
@Thihup -- it wouldn't work as-is, instead you'd need to work with a forked version of the grammar/program
Thiago Henrique Hüpner
@Thihup
@MysterAitch Thanks
Roger Howell
@MysterAitch
if you do go for it, let us know - it sounds interesting! :)
antlr sounds like it could potentially be a good option too, though I think the latest java grammar isn't very recent
Thiago Henrique Hüpner
@Thihup
Yeah, is it a little outdated, but I only need to parse expressions, not a full class ;)
I have a prototype using ANTLR, but I'd like to reuse other code instead of implementing the Lexer, parser and stuff
Peeradon Sukkasem
@littleheart005
Hi. there! I have been using JavaParser and SymbolSolver for a while. Now I facing a problem (UnsolvedSymbolException) when I try to solve a method call in java class. These are part of my code.
Screen Shot 2564-04-07 at 16.06.46.png
Roger Howell
@MysterAitch
@littleheart005 -- double check your source value -- this is usually the source root (i.e. the place where the default package files would be)
e.g. if Duck is in the package headfirst.strategy, the source root will be the folder above headfirst(i.e. the src directory)
1 reply
aiddroid
@aiddroid
Here's a demo for callgraph: https://github.com/aiddroid/java-callgraph
aiddroid
@aiddroid
alt
Danny van Bruggen
@matozoid
Hey, nice work @aiddroid !
Shall I put it on Twitter?
aiddroid
@aiddroid

Shall I put it on Twitter?

ok

Danny van Bruggen
@matozoid
Several people asked if JP has data flow graph/diagram/analysis support, and I wondered how much effort it would be to build it. It's now in a state that the design is right - lots of stuff still missing though - so I thought I would make it public: https://github.com/matozoid/data_flow_analyser_with_javaparser
Feel free to help/comment/ignore :-)
DaGeRe
@DaGeRe
Hi, I'm currently trying to instrument code for monitoring using Javaparser. Therefore, I need to know whether a statement is considered as unreachable by the compiler or not (to eventually add a return statement). From what I've seen now, https://github.com/javaparser/javaparser/blob/master/javaparser-symbol-solver-core/src/main/java/com/github/javaparser/symbolsolver/resolution/typeinference/ControlFlowLogic.java should do this job, but is not implemented yet. Are there other options for doing this with javaparser (besides implementing ControlFlowLogic myself)?
Danny van Bruggen
@matozoid
Ah, @DaGeRe - you just made me realize that I'm building a control flow analyser, not a data flow analyser. Thanks!
jean pierre Lerbscher
@jlerbsc
@DaGeRe What you need is a control flow graph but it does not exist in JP. But JP (AST) can help you to build a cfg.
Danny van Bruggen
@matozoid
Thanks to @jlerbsc for teaching me a new word :-) https://en.wikipedia.org/wiki/Schmilblick
4 replies
Jonathan Locke
@jonathanl-telenav
Hi All
I saw a discussion on the web somewhere about adding Kotlin support to JavaParser. Has there been any work done on this?
Danny van Bruggen
@matozoid
No, I think that would have to be a separate product. Tons of work!
Jonathan Locke
@jonathanl-telenav
Thanks Danny
Bart Naudts
@bnaudts
Hi, I’m working on a static code analyser (e2immu.org) that uses JavaParser as its source code parser. To be able to analyse its own code, e2immu would need Java 16 language features. I’m not using the JavaParser’s symbol solver. Could you please point me to a time-line for JavaParser’s Java 16 language support? I would consider helping a hand if that can speed things up.
7 replies
Yoshi van den Akker
@yoshivda
Hey, I just opened an issue (javaparser/javaparser#3244) but realised this might actually be a better place for it. I'm struggling with an OrphanComment in a BlockStmt, it doesn't appear when added programmatically (it does output correctly when it's in the parsed file). My project was still stuck on V3.6 of the parser and there it worked fine, but now that I'm upgrading to the latest version all of a sudden the comment fully disappears, leaving behind an empty block. Is this a regression or should I create a block that only contains a comment in another way?
15 replies
Danny van Bruggen
@matozoid
@jonathanl-telenav - if you're still around, today I saw a project that worked on the AST that Kotlin's compiler supplies. Maybe that's usable.
Roger Howell
@MysterAitch
Not caught up with all messages, but just a quick note to say I will get the next release out this weekend
If not sooner
Danny van Bruggen
@matozoid
That's great!
ridhij93
@ridhij93
Hi, Does Javaparser also work for .class files?
2 replies
Danny van Bruggen
@matozoid
@MysterAitch - I noticed a release because dependabot sends me PR's for a new JP dependency :-)
Roger Howell
@MysterAitch
haha yes.. though long overdue... :sweat:
Roger Howell
@MysterAitch
good to see that it's working though! :D
Danny van Bruggen
@matozoid
Is Java 15 support now complete (enough)? Let's tweet it!
... and update sites everywhere :-)
Roger Howell
@MysterAitch
java 16?

y'know... I just had a look and I think you're right! (just gotta fix the sealed classes thing to be second preview in java 16, not release...)

https://github.com/javaparser/javaparser/blob/master/FEATURES.md#jdk-16-current---march-2021

Roger Howell
@MysterAitch

RecordDeclaration's @sincementioned 3.21.0, and the features document also mentions it (says it was released on 11/april) but I don't see it on github releases or maven central...

now i'm wondering if I was a complete muppet and somehow completely skipped a version?? or thought it'd been released??

meh... it happens...
haha
Roger Howell
@MysterAitch
just pushed v3.22.1 which has parsing support up to java 16 and solver support up to java 15