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.

Bug 262008 - Refactoring: Renaming a class or interface fails to change type of field or var after first in a comma separated declaration.
Summary: Refactoring: Renaming a class or interface fails to change type of field or v...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Refactoring (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Ralph Ruijs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-15 19:38 UTC by nimarukan
Modified: 2016-05-15 19:38 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nimarukan 2016-05-15 19:38:16 UTC
/**
 * Renaming a class or interface only changes the type of the first of
 * multiple fields or local variables declared with that type in a
 * comma separated list.  The names after the first still have the
 * old type name, now erroneous, and are moved to a separate declaration.<p/>
 *
 * To reproduce an example:
 * Rename type 'Result' to 'Solution' in the code below:
 * (Right click on 'Result', click 'Refactor' / 'Rename...')
 */
public class RenameTypeOfCommaSeparatedNames {

  static class Result {
  }

  Result s;
  Result t, u;
  Result w, x, y;

  void method() {
    Result a;
    Result b, c;
    Result d, e, f;
  }
}


//
// Actual: 'Result' becomes 'Solution' on 6 lines, but names after comma
// have old type name, separated into a new declaration statement.
//
//   public class RenameTypeOfCommaSeparatedNames {
//
//     static class Solution {
//     }
//
//     Solution s;
//     Solution t;
//     Result u;
//     Solution w;
//     Result x, y;
//
//     void method() {
//       Solution a;
//       Solution b;
//       Result c;
//       Solution d;
//       Result e, f;
//     }
//   }
//
// Expect: 'Result' becomes 'Solution' on all 6 declaration lines below.
//
//   public class RenameTypeOfCommaSeparatedNames {
//
//     static class Solution {
//     }
//
//     Solution s;
//     Solution t, u;
//     Solution w, x, y;
//
//      void method() {
//        Solution a;
//        Solution b, c;
//        Solution d, e, f;
//      }
//    }
//