Skip to content

Conversation

@AlexisCnockaert
Copy link
Collaborator

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

AlexisCnockaert and others added 2 commits October 28, 2025 14:59
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
Copy link
Member

@jecisc jecisc left a 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 :)

@AlexisCnockaert
Copy link
Collaborator Author

I will do the tests but for now this works

}

{ #category : 'testing' }
ClyClassDefinitionContext >> isInstanceSide [
Copy link
Member

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.

Copy link
Collaborator Author

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

@AlexisCnockaert
Copy link
Collaborator Author

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:
scopeInstanceSide: ((toolContext respondsTo: #metaLevelScope) ifTrue: [ toolContext metaLevelScope isInstanceSide ] ifFalse: [ toolContext isInstanceSide ]);

@Ducasse Ducasse added the Status: Need more work The issue is nearly ready. Waiting some last bits. label Oct 29, 2025
@Ducasse
Copy link
Member

Ducasse commented Oct 29, 2025

Alexis can you run the refactoring tests locally because it will give you useful feedback.
Now we have 90 tests failing.



(ReGenerateAccessorsDriver new
targetClass: variables first definingClass;
Copy link
Contributor

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 isInstanceSide

No need to analyze the toolContext at all. Variables are first class objects with the full information.

Copy link
Contributor

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

Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Need more work The issue is nearly ready. Waiting some last bits.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactoring] Generating var of instance class variables generate methods instance side

4 participants