Added: ClassDescription>>addInstVarName:afterIndex: - used by refactoring engine jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Fri, 31 Jan 2014 02:04:30 +0000
branchjv
changeset 18116 bf7f37b63ea2
parent 18115 26ac4840e5d0
child 18117 eb433f2c42b2
Added: ClassDescription>>addInstVarName:afterIndex: - used by refactoring engine This allows refactoring engine to rename instance variables without changing their order - it may have some meaning for either programmer or VM.
ClassDescription.st
--- a/ClassDescription.st	Mon Jan 13 11:46:28 2014 +0000
+++ b/ClassDescription.st	Fri Jan 31 02:04:30 2014 +0000
@@ -697,9 +697,27 @@
 !ClassDescription methodsFor:'Compatibility-ST80'!
 
 addInstVarName:anotherInstVar
-    |sel newClass args newNames|
-
-    newNames := self instanceVariableString , ' ' , anotherInstVar.
+    ^ self addInstVarName:anotherInstVar afterIndex: nil
+
+    "Modified: / 25-02-2009 / 14:51:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
+    "Modified: / 18-01-2011 / 17:57:23 / cg"
+    "Modified: / 31-01-2014 / 02:00:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+addInstVarName:anotherInstVar afterIndex: indexOrNil
+    |newClass newNames|
+
+    indexOrNil notNil ifTrue:[ 
+        | oldNames |
+
+        oldNames := self instVarNames asOrderedCollection.
+        oldNames := oldNames add: anotherInstVar afterIndex: (indexOrNil min: oldNames size).
+        newNames := oldNames asStringWith:' '.  
+    ] ifFalse:[ 
+        newNames := self instanceVariableString , ' ' , anotherInstVar.
+    ].
+
+
 
     self isMeta ifTrue:[
         ^ self instanceVariableNames:newNames.
@@ -759,8 +777,7 @@
     ^ newClass
     "
 
-    "Modified: / 25-02-2009 / 14:51:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
-    "Modified: / 18-01-2011 / 17:57:23 / cg"
+    "Created: / 31-01-2014 / 01:51:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 organization
@@ -822,6 +839,7 @@
     "Created: / 28.3.1998 / 21:21:52 / cg"
 ! !
 
+
 !ClassDescription methodsFor:'Compatibility-V''Age'!
 
 categoriesFor:aSelector are:listOfCategories