V8: Split Class (Extract Class) refactoring - #394
Open
ericwinger wants to merge 6 commits into
Open
Conversation
Engine GsSplitClassRefactoring (reuses V6/V7's #classAdd + reversion machinery): extract a chosen set of the source's OWN instance variables -- and the methods that use them -- into a new component class; the source keeps a lazy accessor + a delegating stub per moved method; reversion the source + reparent its subtree. Clean-cut precondition declines straddling/super/retained-calling methods, descendant use of an extracted ivar, name collisions. All-or-nothing, no commit, no migration. SUnit 25/25 on BOTH 3.6.2 and 3.7.5; full engine suite 548/0/0 on 3.6.2. Client: splitClass command/preview/panel/panelHtml + previewSplitClass query builder + browserQueries wrappers + Explorer "Split Class..." command/menu wiring. Host-side double-apply latch, ensureRbSupport gate, no-false-success. 61 client unit tests; tsc + eslint clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-code removal - package.json: point the split-class hierarchy menu clause at the renamed view id gemstoneExplorerClassHierarchy (a main-merge artifact; caught by explorerViewRegistration). - splitClassCommand: toast when the ivar pick is confirmed with nothing selected, so it does not read as a crash; an Escape/cancel stays silent. - Engine: delete the unreachable applyMethodRemove: method + the #methodRemove branch in applyChange:, and correct the buildChangeSet docstring (the copy-forward already omits moved methods, so nothing stages #methodRemove). Payloads rebuilt (manifest 59->58 methods). NOT reinstalled or re-tested here -- retest in the review session. - Tests: new refactoringSplitClass.integration.test.ts (apply-path survival both sides, pagination, expired token) and new splitClassPanelHtml.test.ts; extend the preview/command/ panel/query unit tests to cover the defensive parse throws, command error paths, panel guards, and name validation. Engine SUnit +8 (binary/keyword delegators, pagination + expired session, previewJsonString, analyzeClass: convenience, clearToken) = 33/33 both boundaries. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- HIGH: computeAnalysis self-send guard no longer treats an Object-understood selector as safe to leave behind when the SOURCE overrides it (a movable method self-sending e.g. #printString would move and silently resolve to the component's inherited Object impl, losing the override). Guard is now: the selector moves too, OR Object understands it AND the source does not override it. Adds a decline test + a non-override control (negative-control verified red against the old guard). - MED: gate both split-class context-menu entries on gemstone.rbSupportAvailable, matching every sibling in the 3_refactor group. - MED: drop the divergent local asCount for the shared previewCounts asCount (Math.trunc truncation, not pass-through); adds a truncation-contract test. - LOW: add class-side method survival coverage (metaclass copy-forward on the reversioned source + reparented subclass). Engine SUnit 36/36 on BOTH 3.6.2 and 3.7.5; full client suite green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
V8 of the server-side RB refactoring catalog (#252): Split Class / Extract Class. Extract a cohesive subset of a class's own instance variables — and the methods that use them — into a new component class, leaving the source holding a lazy reference to it (a has-a relationship). Classic Fowler Extract Class, non-committing, previewed and applied through the same engine/panel machinery as the rest of the family.
Explorer class-row / hierarchy command "Split Class…": pick the ivars to extract → name the new class → pre-flight → paginated preview → apply (server-side, all-or-nothing, never commits).
How it works
GsSplitClassRefactoringreuses V6/V7's#classAddchange kind and the reversion-by-newVersionOf:machinery. Given source S and extract set E, the movable methods are S's instance methods that touch an E ivar. Apply: create component N carrying E + the movable methods; reversion S to drop E, add a component ivar + a lazy accessor (n ^n ifNil: [n := N new]) + a delegating stub per moved method (so S's external API is unchanged); reparent S's descendant subtree onto the freshly-versioned S.super, or self-sends a method that stays behind; a descendant that references an extracted ivar; name / component-ivar collisions; empty or invalid inputs. (The self-send guard correctly declines even when the self-sent selector is understood byObjectbut overridden on the source — otherwise the moved method would silently resolve toObject's implementation.)Tests
GsSplitClassRefactoringTest— analysis, every decline, preview staging, apply-path survival (component and source both sides, behavior preserved through the delegators incl. keyword-argument weaving, retained-method + class-side survival, subclass reparent), pagination + expired session, no-commit. 36 / 36 on 3.6.2 AND 3.7.5 (topaz stage + run + abort).refactoringSplitClass.integration.test.ts— asserts applied stone state on both sides (including a retained method no change set mentions, and the reparented subclass's own methods), pagination across byte-bounded pages, and expired-token handling; engine-gated viarequireServerPluginFeature, so it runs in the plugin CI pass and skips-with-reason on a bare stone.Full client suite green;
lint/format:check/compileclean.Follow-ups (deferred to their own PRs)
Verification
🤖 Generated with Claude Code