diff --git a/pdex/Todo, GSoC 2013.txt b/pdex/Todo, GSoC 2013.txt index 0663bd840..a156e43cb 100644 --- a/pdex/Todo, GSoC 2013.txt +++ b/pdex/Todo, GSoC 2013.txt @@ -46,7 +46,7 @@ Refactoring would work only when code is compiler error free. I plan to do a fin x Edge Case: For renaming a TypeDeclaration, the declaration of SimpleName instance of the TD and it's constructor(s) aren't added to the list generated by DFS. So for renaming TD, will have to manually add the TD SimpleName and it's constructors' SimpleNames to the a list of declaration nodes that can be positively matched against. x Renaming any constructor is equivalent to renaming the TD 3. Find corresponding PDE offsets of the SimpleNames, rename in each line. -* Edge Case: Need to take displaced offsets on a line, due to pde enhancements, into consideration. +x Edge Case: Need to take displaced offsets on a line, due to pde enhancements, into consideration. 4. All the changes in code would be made in a separate copy of the code(?). After all the renaming is done, allow it only if the new code compiles. Basically an undo should be possible in case of conflicts. * Undo misbehaves here, handle carefully. * Handle saving. If sketch closed after renaming w/o saving find bugs. diff --git a/pdex/src/processing/mode/experimental/ASTGenerator.java b/pdex/src/processing/mode/experimental/ASTGenerator.java index 749571692..cd79906e7 100644 --- a/pdex/src/processing/mode/experimental/ASTGenerator.java +++ b/pdex/src/processing/mode/experimental/ASTGenerator.java @@ -1307,19 +1307,17 @@ public class ASTGenerator { - editor.ta.getSelectedText().length(); HashMap lineOffsetDisplacement = new HashMap(); - for (int i = 0; i < defCU.getChildCount(); i++) { + for (int i = defCU.getChildCount() - 1; i >= 0; i--) { ASTNodeWrapper awrap = (ASTNodeWrapper) ((DefaultMutableTreeNode) (defCU .getChildAt(i))).getUserObject(); int pdeoffsets[] = awrap.getPDECodeOffsets(errorCheckerService); int javaoffsets[] = awrap.getJavaCodeOffsets(errorCheckerService); - ErrorCheckerService.scrollToErrorLine(editor, pdeoffsets[0], - pdeoffsets[1], - javaoffsets[1], - javaoffsets[2]); - editor.ta.setSelectedText(newName); + // correction for pde enhancements related displacement on a line + int off = 0; if(lineOffsetDisplacement.get(javaoffsets[0]) != null){ - int off = lineOffsetDisplacement.get(javaoffsets[0]); + off = lineOffsetDisplacement.get(javaoffsets[0]); + lineOffsetDisplacement.put(javaoffsets[0], lineOffsetDisplacementConst + off); } @@ -1327,6 +1325,12 @@ public class ASTGenerator { lineOffsetDisplacement.put(javaoffsets[0], lineOffsetDisplacementConst); } + + ErrorCheckerService.scrollToErrorLine(editor, pdeoffsets[0], + pdeoffsets[1], + javaoffsets[1] + off, + javaoffsets[2]); + editor.ta.setSelectedText(newName); } for (Integer lineNum : lineOffsetDisplacement.keySet()) { System.out.println(lineNum + "line, disp"