Skip to content

Improve UI for rename argument/temporary variable and add tests - #19846

Open
Biljcica wants to merge 11 commits into
pharo-project:Pharo15from
Biljcica:week1
Open

Improve UI for rename argument/temporary variable and add tests#19846
Biljcica wants to merge 11 commits into
pharo-project:Pharo15from
Biljcica:week1

Conversation

@Biljcica

@Biljcica Biljcica commented Jul 1, 2026

Copy link
Copy Markdown

Copied StRefactoringPreviewPresenter and modified the UI to support renaming arguments/temporary variables. The updated view allows entering a new name, triggering the rename action, and displaying a preview of changes based on the selected scope. Added unit tests to verify each part of the functionality and introduced missing tests for ReLocalNameConflictCondition.

@request-info

request-info Bot commented Jul 1, 2026

Copy link
Copy Markdown

This issue has either a default title or empty body. We would appreciate it if you could provide more information. Note: I am not a very intelligent bot, I can only react to new comments. Please add a comment for me if you update the body or title.

@Biljcica
Biljcica marked this pull request as draft July 1, 2026 11:50
@balsa-sarenac

Copy link
Copy Markdown
Member

Thanks! Feel free to update description and explain what you did and optionally why!
In the reviewers section, you can find people you want to take a look before we get this merged, then we'll be notified, and will review the code. Happy to help with your first contribution!

@balsa-sarenac

Copy link
Copy Markdown
Member

@Ducasse we want to leave this for Pharo15, right?

@Ducasse
Ducasse requested a review from balsa-sarenac July 1, 2026 20:08
@Ducasse

Ducasse commented Jul 1, 2026

Copy link
Copy Markdown
Member

@Ducasse we want to leave this for Pharo15, right?

This is my impression like that less stress :)

@Ducasse

Ducasse commented Jul 1, 2026

Copy link
Copy Markdown
Member

I will change the branch when it is ready so that we have less git magic.

@Biljcica
Biljcica marked this pull request as ready for review July 2, 2026 12:33

@balsa-sarenac balsa-sarenac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is good progress, awesome to see tests alongside!

let's iterate and try to clean the noise, there are a lot of changes/additions that are not needed. I tried to flag them with inline comments. to get this merged, we ideally want minimal code to introduce, and remove the dead code/unused code. we can discuss if something is not clear

it would be nice if for next iteration to clean the leftover halts and new empty lines in random methods (just brings noise and unnecessary history)

Comment on lines +15 to +18
| temp |
temp := 35.
| tmp1 |
tmp1 := 35.

^ temp
^ tmp1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

testing leftovers

Comment on lines +299 to +304
{ #category : 'initialization' }
ReCompositeChange >> resetChanges [

changes := OrderedCollection new
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

as discussed, let's try to do it with new model for each update, instead of cleaning the model before generating new changes
we can compare them afterwards and pick better one

My precondition verifies that the new name is a valid variable name and not an existing instance or a class variable name
"
Class {
#name : 'ReRenameArgumentOrTemporaryRefactoring2',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What is different from original refactoring?
Or - what you needed to change and why? - could we use the existing refactoring instead?

]

{ #category : 'accessing' }
ReRenameArgumentOrTemporaryDriver2 >> gatherUserInput [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's try to clean the driver of methods it is not using, just so it's easier to understand. I'm even thinking of creating a superclass of InteractionDriver (like a Driver), and have just the entrypoint and minimal things we need - like runRefactoring and hooks we use. we can discuss this, it will remove noise for you here, and since it's new way of doing drivers, doesn't make sense to try to force it and avoid all existing defined API


"
Class {
#name : 'SycRefactoringPreviewPresenter2',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe rename this to SycRenameArgumentOrTemporaryPresenter or something similar, since this is now specific to this refactoring

@balsa-sarenac

balsa-sarenac commented Jul 26, 2026

Copy link
Copy Markdown
Member

@Biljcica we should change base branch (to which we merge) to Pharo15, as that is the new default, this will go in the next release.

@Biljcica
Biljcica changed the base branch from Pharo14 to Pharo15 July 28, 2026 11:41
@balsa-sarenac

Copy link
Copy Markdown
Member

@Biljcica For behavior-preserving precondition, we have: overriding instance/class variables with the same name.
What I suggest is to below applicability validation, we show breaking change validation:

[ field to insert new name ] [update button]
- applicability validation here -
- behavior-preserving validation here -

We just need to make it nicely visible, let's touch base after you do this to see how it works/behaves

@Biljcica

Copy link
Copy Markdown
Author

@balsa-sarenac I’ve implemented the behavior-preserving precondition and added the corresponding tests. I also fixed the affected tests. Let me know what you think! :)

@balsa-sarenac balsa-sarenac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice work! It's getting closer to its final shape! Let's iterate now to clean the code and get it ready for merging!

Comment on lines +265 to +275
{ #category : 'scripting api - executing' }
ReAbstractTransformation >> generateTransformChanges [
"Prepare, check the preconditions, perform the actual transformation (i.e., creating a list of changes that can be accessible using the changes message), and return the changes. This method should not be invoked from drivers since drivers usually check in finer grained mode the preconditions - and that this stage they already checked the preconditions."

self prepareForExecution.
self privateTransform.
^ self changes


]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what's missing in the current API that you need to do this? This is essentially avoiding preconditions - we had this before and removed it since it's dangerous in any place. If you want something like this -> do the steps yourself in the place you want to do it, then we can see how to improve and refactor so this might not be needed at all.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

similar question, why did we fork this refactoring? (the PR is about rename and this is remove?) anything different than the original?

previewUpdateDelay ifNotNil: [ previewUpdateDelay unschedule ].

previewUpdateDelay := Delay forMilliseconds: 350.
previewUpdateDelay := Delay forMilliseconds: 300.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

comment on why 300 would be nice

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

you've probably mistakenly removed these?

(definingNode exactNodeDefines: variableName) ifTrue: [
violators addIfNotPresent: variableName ].

"check if there is exting temp either above or below in AST"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
"check if there is exting temp either above or below in AST"
"check if there is existing temp either above or below in AST"

Comment on lines +396 to +400
ifFalse: [
(topLayout children includes: behaviorPanel)
ifTrue: [
topLayout remove: behaviorPanel.
self rebuildLayout ] ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe:

Suggested change
ifFalse: [
(topLayout children includes: behaviorPanel)
ifTrue: [
topLayout remove: behaviorPanel.
self rebuildLayout ] ]
ifFalse: [ self hideBehaviorPane ]

Comment on lines +391 to +395
ifTrue: [
behaviorMessageLabel label: driver checkBehaviorPreservingPreconditions.

(topLayout children includes: behaviorPanel)
ifFalse: [ topLayout add: behaviorPanel expand: false ] ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe:

Suggested change
ifTrue: [
behaviorMessageLabel label: driver checkBehaviorPreservingPreconditions.
(topLayout children includes: behaviorPanel)
ifFalse: [ topLayout add: behaviorPanel expand: false ] ]
ifTrue: [ self addBehaviorPane ]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

looks like this was mistakenly removed?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What's this file? An older version?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also this file looks like old version that is still here. can you do a pass and remove things you don't use that are still here, let's try not to bring noise and dead code in

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