pharo
pharo copied to clipboard
Cannot rename a class instance var: RBRenameInstanceVariableRefactoring can not deal with class instance variables
Bug description Cannot rename a class instance variable
To Reproduce Steps to reproduce the behavior:
- Define a class
Object << #Foo
classSlots: { #Default };
package: 'ToRemove';
install
- Open the browser on #Foo class on class side
- Select
#Defaultand right-click to choose rename - put a new name
- See error
Screenshots
Pharo-12.0.0+SNAPSHOT.build.1513.sha.ee8b9dea9b3bbc42dbcc5efca62ee8de39633f9e
I think the Code just can not yet handle class instance variables (aka class side slots). It uses RBRenameInstanceVariableRefactoring, but the condisoon checking there uses the name of the class:
applicabilityPreconditions
^ {
(ReIsValidInstanceVariableName name: newName).
(ReDefinesInstanceVariableCondition
classNamed: class name
inModel: self model
instanceVariables: { variableName }).
(ReIsVariableNotDefinedInHierarchy name: newName class: class).
(ReNameIsGlobalCondition new model: self model className: newName)
not }
The class it "Foo class", but if we ask for #name we get Foo, which then means that the check looks for instance side ivars, not class side.
ReDefinesInstanceVariableCondition has be refactored to not use names or it needs in addition a flag that the name should be interpreted as the class side.