This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
The following looks weird: { $p$; $t $v; $intervening$; $q$; $v = $e; return $v; } => { $p$; $q$; return $e; } shouldn't it be: { $p$; $t $v; $intervening$; $v = $e; return $v; } => { $p$; $intervening$; return $e; } :: !assignedIn($intervening$); The next one is not wrong, but rather it might be improved - it is the one with "Effective Java, item 29: Minimize the scope of local variables": { $p$; $t $v; $intervening$; $v = $e; $q$; } => { $p$; $intervening$; $t $v = $e; $q$; } :: !assignedIn($v, $intervening$); which could be more general: { $p$; $t $v; $intervening$; $q$; } => { $p$; $intervening$; $t $v; $q$; } :: ! assignedIn($v, $intervening$);
I lowered the priority because the current transformations are just examples. You are right about the need for the first rule to have a !assignedIn() guard; I have updated the rule in the distribution. I think your second rule would recurse on itself if made too general. To fully address all cases for minimizing scope, I think a Java transformation is needed since Scopes will soon be part of the Tree API and thus can be directly used instead of inferred.