public class FixAssignmentsToUnboxOrCast extends JModVisitor
GenerateJavaAST
. The only cases it does
not handle are ++
, --
, and compound assignment
operations (+=
, etc.) when applied to a boxed type. This class
fixes such cases in two steps. First, an internal subclass of
CompoundAssignmentNormalizer
simplifies such expressions to a simple
assignment expression. Second, this visitor replaces an assignment to an
unboxing method (unbox(x) = unbox(x) + 1
) with an assignment to
the underlying box (x = box(unbox(x) + 1)
).
Update: GenerateJavaAST can also leave invalid AST structures of the form
(Foo) x = foo
due to the way generics are handled. This can
happen when assigning into a field of a generic type. We'll go ahead and
resolve that case here as well.
LVALUE_CONTEXT, UNMODIFIABLE_CONTEXT
Modifier and Type | Method and Description |
---|---|
void |
endVisit(JBinaryOperation x,
Context ctx) |
static void |
exec(JProgram program) |
accept, accept, accept, acceptImmutable, acceptLvalue, acceptWithInsertRemove, acceptWithInsertRemoveImmutable, checkReplacement, didChange, getNumMods, madeChanges, traverse
accept, accept, accept, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, endVisit, translateException, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
public static void exec(JProgram program)
public void endVisit(JBinaryOperation x, Context ctx)
Copyright © 2018. All rights reserved.