Improve UI for rename argument/temporary variable and add tests - #19846
Improve UI for rename argument/temporary variable and add tests#19846Biljcica wants to merge 11 commits into
Conversation
|
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. |
|
Thanks! Feel free to update description and explain what you did and optionally why! |
|
@Ducasse we want to leave this for Pharo15, right? |
This is my impression like that less stress :) |
|
I will change the branch when it is ready so that we have less git magic. |
balsa-sarenac
left a comment
There was a problem hiding this comment.
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)
| | temp | | ||
| temp := 35. | ||
| | tmp1 | | ||
| tmp1 := 35. | ||
|
|
||
| ^ temp | ||
| ^ tmp1 |
| { #category : 'initialization' } | ||
| ReCompositeChange >> resetChanges [ | ||
|
|
||
| changes := OrderedCollection new | ||
| ] | ||
|
|
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
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 [ |
There was a problem hiding this comment.
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', |
There was a problem hiding this comment.
maybe rename this to SycRenameArgumentOrTemporaryPresenter or something similar, since this is now specific to this refactoring
|
@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. |
… and model on each rename
|
@Biljcica For behavior-preserving precondition, we have: overriding instance/class variables with the same name. |
|
@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
left a comment
There was a problem hiding this comment.
Nice work! It's getting closer to its final shape! Let's iterate now to clean the code and get it ready for merging!
| { #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 | ||
|
|
||
|
|
||
| ] | ||
|
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
comment on why 300 would be nice
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
| "check if there is exting temp either above or below in AST" | |
| "check if there is existing temp either above or below in AST" |
| ifFalse: [ | ||
| (topLayout children includes: behaviorPanel) | ||
| ifTrue: [ | ||
| topLayout remove: behaviorPanel. | ||
| self rebuildLayout ] ] |
There was a problem hiding this comment.
Maybe:
| ifFalse: [ | |
| (topLayout children includes: behaviorPanel) | |
| ifTrue: [ | |
| topLayout remove: behaviorPanel. | |
| self rebuildLayout ] ] | |
| ifFalse: [ self hideBehaviorPane ] |
| ifTrue: [ | ||
| behaviorMessageLabel label: driver checkBehaviorPreservingPreconditions. | ||
|
|
||
| (topLayout children includes: behaviorPanel) | ||
| ifFalse: [ topLayout add: behaviorPanel expand: false ] ] |
There was a problem hiding this comment.
maybe:
| ifTrue: [ | |
| behaviorMessageLabel label: driver checkBehaviorPreservingPreconditions. | |
| (topLayout children includes: behaviorPanel) | |
| ifFalse: [ topLayout add: behaviorPanel expand: false ] ] | |
| ifTrue: [ self addBehaviorPane ] |
There was a problem hiding this comment.
looks like this was mistakenly removed?
There was a problem hiding this comment.
What's this file? An older version?
There was a problem hiding this comment.
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
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.