How to get binary subexpressions with javaparser

22 views
Skip to first unread message

Jeremy S

unread,
Jun 2, 2015, 3:50:58 AM6/2/15
to javap...@googlegroups.com
Hi everyone,

I am using javaparser to parse the AST for Java source files.

I would like to get all binary subexpressions in the source code as individual nodes. Here is the source code I am parsing:

class MyClass {
  public MyClass() {
    double x = (4 / 10.0) + 15;
  }
}

I implemented a Visitor that accepts the built-in BinaryExp type, but the only node that it finds contains the binary expression:

(4 / 10.0) + 15

Is there a way to visit the subexpression "(4 / 10.0)" as well? I tried getting the full expression's "left operand", but it is of type Expression, and not BinaryExpr as I expected.

Any help would be appreciated.

Reply all
Reply to author
Forward
0 new messages