- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 399
 
[Refactoring] Fix generating accessors variable slots bug #18777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: Pharo14
Are you sure you want to change the base?
[Refactoring] Fix generating accessors variable slots bug #18777
Conversation
When generating getter and setter for an instance variable on class side, they were generated on instance side. Therefore, I made the distinction between those two instance variable types when configuring the refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to add a regression test :)
| 
           I will do the tests but for now this works  | 
    
| } | ||
| 
               | 
          ||
| { #category : 'testing' } | ||
| ClyClassDefinitionContext >> isInstanceSide [ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this one strange.
And I also wondered why we could not use metaLevelOf: even if I do not like the name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metaLevelOf: is for classes I think and there we want to check it for variables
| 
           It is because in the execute method we can have different contexts, so using isInstanceSide simplify the API for all of them, in there indeed:  | 
    
| 
           Alexis can you run the refactoring tests locally because it will give you useful feedback.  | 
    
| 
               | 
          ||
| 
               | 
          ||
| (ReGenerateAccessorsDriver new | ||
| targetClass: variables first definingClass; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The #definingClass actually gives you the correct class side object for class side variables.
You can detect the class side by:
variables first definingClass isInstanceSideNo need to analyze the toolContext at all. Variables are first class objects with the full information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is shame that new driver system is based on raw string names for variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is to make it easy to use for scripting.
When you call it in a playground it's not nice to have to get variable objects.
But maybe we can add some API to configure the driver with real variables and then the driver gets the name and side of the variable for the refactoring?
When generating getter and setter for an instance variable on class side, they were generated on instance side. Therefore, I made the distinction between those two instance variable types when configuring the refactoring
Fixes #18771