CtUnaryOperator extends CtStatement

49 Views Asked by At

I can't understand why.

In the expression if (a++ > 0) {...} a++ can't be a Statement but since a++ is a CtUnaryOperator then it's also a CtStatement.

How can I differentiate between a++; and i = a++; since in both cases a++ will be a CtStatement?

2

There are 2 best solutions below

1
On

to differentiate between both, one looks at the parent. One class encapsulates this logic:

// does element act as a statement?
boolean hasStatementRole = new LineFilter().matches(element)
0
On

Since the issues in this questions comes from design decisions in the Spoon tool, it can't be answered properly.