Refactor Transform nested types to remove inner class boilerplate#3221
Merged
HeikoKlare merged 1 commit intoeclipse-platform:masterfrom Apr 11, 2026
Merged
Conversation
Convert SetElementsOperation and TranslateOperation from non-static inner classes to records, making their dependency on the device explicit via a constructor parameter rather than capturing the outer instance implicitly. Make MultiplyOperation a static nested class for the same reason. Also extract a destroyAllHandles() helper to eliminate duplicated code, simplify getTransformHandle() with Map.computeIfAbsent(), collapse a single-expression block lambda in isIdentity(), and remove unnecessary local handle aliases inside the operation apply() methods. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR cleans up the Win32
Transformclass by eliminating unnecessary boilerplate in its private nested types and a few helper methods.Changes
Inner classes converted to static nested types
SetElementsOperationandTranslateOperationwere non-static inner classes, causing them to hold an implicit reference to the enclosingTransforminstance. They are now records with theDrawable devicepassed explicitly as a constructor argument, making the dependency visible and breaking the implicit outer-instance capture.MultiplyOperationwas converted to astaticnested class for the same reason, since it already uses afloat[]field which makes it unsuitable for a record.Removal of local variable aliases
Several
apply()implementations introduced unnecessary local variables likelong handle = transformHandle.handleorint zoom = transformHandle.zoom. These have been removed in favour of direct field access on the record, reducing noise without any semantic change.Extracted
destroyAllHandles()helperdestroy()anddestroyHandlesExcept()contained identical two-line sequences to iterate and clearzoomToHandle. This is now delegated to a privatedestroyAllHandles()method.getTransformHandle()simplified withcomputeIfAbsentThe previous
containsKey/get/putpattern performing three map lookups was replaced with a singleMap.computeIfAbsent()call.Lambda simplification in
isIdentity()A single-expression block lambda was collapsed into an expression lambda.
Variable naming in
newTransformHandle()A local variable named
newTransformHandleshadowed the method of the same name. It has been renamed totransformHandlefor clarity.This PR was created with the help of GitHub Copilot.