Skip to content

Conversation

@carolahp
Copy link
Contributor

Also refactor variable-related choices.
Finally, refactors conditions to optionally set their action as a block from the driver (preventing the creation of a new class each time)

@carolahp carolahp requested a review from Ducasse September 25, 2025 11:19
@carolahp carolahp changed the title Implement Driver for PushDownSharedVariable [Refactorings] Implement Driver for PushDownSharedVariable Sep 25, 2025
Comment on lines +45 to +48
RePushDownSharedVariableRefactoring >> preconditions [

^ self applicabilityPreconditions & self breakingChangePreconditions
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be needed anymore, and should not be used anywhere. I think this will also fail if it is called because both calls return lists and we try to & them. I should probably do a cleanup and remove preconditions soon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted it

Comment on lines +20 to +24
{ #category : 'accessing' }
ReVariableCondition >> violatorCandidates [

self subclassResponsibility
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this new method? I saw it's usage, but was wondering what the existing API was missing?

Copy link
Contributor Author

@carolahp carolahp Oct 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

violatorCandidates is the same as subjects in this PR. It is necessary to improve the error messages of condition negations. I think the implementation in the mentioned PR is more clean. We may review and merge that PR before this one

Comment on lines +15 to +25
{ #category : 'accessing' }
ReChoice >> action [
"The action is dynamically set as a block. Some subclasses may override this method to hardcode their own actions"
^ actionBlock value
]

{ #category : 'accessing' }
ReChoice >> actionBlock: aBlockClosure [
actionBlock := aBlockClosure
]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the upside of this approach compared to the existing approach?

Right now, we just invoke proper methods from the driver:

driver applyChanges.
driver browseSenders.

I'm asking because there is two ways to do 1 thing, and it would be better to only be one way. So either this or old one. If you want this all usages should be changed so we don't have confusion...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I didn't understand the standard way to do it when I prepared this PR. I will change the code to the existing approach

^ self class defaultSelectDialog
title: 'Warning you may break your code';
label:
'The variable you want to push down is referenced from methods in its defining class!';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to ask breaking change for its violation message?
hasNoReferences violationMessage
that way we don't have to hard-code anything

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! it makes sense, removed the hardcoded text

Comment on lines +47 to +55
RePushDownVariableDriver >> configureRefactoring [

" we should manage multiple instance variables"

refactoring := self refactoringClass
model: model
variable: variable
class: class
]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self prepareForExecution at the end

@Ducasse
Copy link
Member

Ducasse commented Oct 2, 2025

Thanks Balsa. I'm thinking that it would be great if you have a list of constraints that the implementation should follow. I could try to turn them into automated rules.

@balsa-sarenac
Copy link
Member

balsa-sarenac commented Oct 3, 2025

@Ducasse we kind of have that written here: https://github.com/pharo-project/reEngine/blob/master/DEVELOPMENT.md
Now, it might lack a couple of things. I should analyze it and analyze the implementation and start adding rules at the bottom.

GitHub
This project is to coordinate with people that want to help on the refactoring pharo engine - pharo-project/reEngine

@Ducasse
Copy link
Member

Ducasse commented Oct 8, 2025

@carolahp did you see the feedback for balsa?

@carolahp
Copy link
Contributor Author

carolahp commented Oct 9, 2025

@carolahp did you see the feedback for balsa?

@Ducasse I did, but I haven't updated the PR yet. I will finishing the scope issue breaks refactoring and I will update this PR after that

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants