vesperin / vesper

source code curation library for Java 1.6 and above
1 stars 0 forks source link

Failed Rename member refactoring #31

Closed hsanchez closed 9 years ago

hsanchez commented 9 years ago
  1. Renaming the int[] a throws errors
  2. Renaming loBound (from si) left a[si] = a[i - 1]; a[i - 1] = pivot; qsort(a, si, i - 2); qsort(a, i, hiBound);

    untouched. That is why I had to manually edit the array parameter.

The problem is that array indexes are not inspected; therefore, if the param name is an array index, then it won't be renamed.

Here is the code snippet.

class Quicksort {
  public static void qsort(int[] arrayOfIntegers, int si, int ei) {
    if (ei <= si || si >= ei) {
    } else {
      int pivot = arrayOfIntegers[si];
      int i = si + 1;
      int tmp;
      for (int j = si + 1; j <= ei; j++) {
        if (pivot > arrayOfIntegers[j]) {
          tmp = arrayOfIntegers[j];
          arrayOfIntegers[j] = arrayOfIntegers[i];
          arrayOfIntegers[i] = tmp;
          i++;
        }
      }
      arrayOfIntegers[si] = arrayOfIntegers[i - 1];
      arrayOfIntegers[i - 1] = pivot;
      qsort(arrayOfIntegers, si, i - 2);
      qsort(arrayOfIntegers, i, ei);
    }
  }
}
hsanchez commented 9 years ago

fixed in #33