1. Jan Lahoda
  2. jackpot30
  3. Issues
Issue #18 new

context.createRenamed(...) fails or looses information in some cases

Ernie Rael
created an issue

Or probably doesn't handle field access. (I'll find a workaround; so this is for reporting, not urgent)

In class A there is {{{ static Option p_f1; }}}

and the fix below does the following transformation.

{{{ if(A.p_f1.getBoolean()) }}} into {{{ if(p_f1Option.getBoolean()) }}}

Note the "A." is missing (it's actually replaced by a TAB). Interesting that in Context.createRenamed you can see {{{ origVariablePath.getLeaf().toString is "A.p_f1" Type: JCTree$JCFieldAccess

newVariablePath.getLeaf().toString is "(ERROR)"
                        Type: Hacks$RenameTree


Here's the pattern/fix

{{{ 'xxx --> xxxOption':

$opt :: $opt instanceof t.Option && hasModifier($opt, Modifier.STATIC) => $optNew :: changeVariableName($opt, $optNew) ;;

<? public boolean changeVariableName(Variable v, Variable target) { String name = context.name(v); context.createRenamed(v, target, name + "Option"); return true; } ?> }}}

Comments (0)

  1. Log in to comment