Skip to content

Replace trivial test samples with realistic cleanup scenarios#71

Merged
carstenartur merged 6 commits into
copilot/add-multifile-cleanup-apifrom
copilot/enhance-preview-ui-workflow
Jan 28, 2026
Merged

Replace trivial test samples with realistic cleanup scenarios#71
carstenartur merged 6 commits into
copilot/add-multifile-cleanup-apifrom
copilot/enhance-preview-ui-workflow

Conversation

Copilot AI commented Jan 28, 2026

Copy link
Copy Markdown

Test code used empty classes (class D {}, class F {}) that didn't demonstrate real cleanup use cases, making the feature value unclear.

Changes

Replaced all 12 test samples with production-like scenarios:

  • testIndependentChangeCreation: Employee/Product with missing @Override annotations instead of empty classes
  • testDependentChangeTracking: DataRepository interface + implementation with unused method instead of unrelated empty classes
  • testSelectiveAcceptanceWorkflow: Service classes with unused imports instead of empty classes
  • testDependencyValidationWorkflow: Deprecated Logger.log() + calling code instead of empty classes
  • testIterativeRecomputationWorkflow: Calculator with chained unused methods requiring recomputation instead of empty class
  • Additional tests: Similar improvements to 7 other tests

Example

Before:

String input1 = """
    package test;
    public class D {
    }
    """;

After:

String input1 = """
    package test;
    public class Employee {
        private String name;
        
        public String toString() {  // Missing @Override
            return "Employee: " + name;
        }
    }
    """;

Tests now demonstrate actual cleanup scenarios: removing unused methods, fixing missing annotations, cleaning imports, handling deprecations, and cascading cleanups requiring AST recomputation.

Original prompt

Problem

PR #68 implements the base multi-file cleanup API (IMultiFileCleanUp, IndependentChange, etc.) but is not yet merged. The following advanced features documented in issue #67 are still missing:

  1. Selective Acceptance of Changes in Preview - Unchecking an individual change does not trigger recomputation
  2. Dependency Tracking UI - No UI to flag change dependencies or warn users
  3. Fresh AST Re-Analysis - AST is not re-parsed when user disables changes
  4. Advanced UX for Sequence Workflows - Cannot chain cleanups with user acceptance driving re-analysis

This PR must build on top of PR #68's branch (copilot/add-multifile-cleanup-api) to include all the base infrastructure.

Required Implementation

1. Selective Change Acceptance with Recomputation

Enhance the preview UI workflow to support:

  • When a user unchecks a change, detect if recomputation is needed
  • If requiresFreshASTAfterSelection() returns true, trigger fresh AST parsing
  • Call recomputeAfterSelection() to get updated changes
  • Update the preview with the recomputed changes

2. Dependency Tracking UI

Implement UI support in the refactoring preview dialog:

3. Fresh AST Re-Analysis Integration

Integrate the existing API methods (from PR #68) into the cleanup workflow:

  • Use CleanUpRefactoring.requiresFreshASTAfterSelection() to check if recomputation is needed
  • Call CleanUpRefactoring.createIndependentChanges() to get granular changes
  • After user selection, call CleanUpRefactoring.recomputeChangesAfterSelection() with fresh contexts
  • Implement the iterative workflow: compute → preview → select → recompute → repeat

4. Enhanced Preview Dialog

Modify CleanUpRefactoringWizard and related UI classes:

  • Add support for iterative change selection
  • Show dependency indicators in the change tree
  • Add "Recompute" button or automatic recomputation when selections change
  • Display warnings when rejecting dependent changes

5. Tests

Add comprehensive tests for:

  • Selective change acceptance workflow
  • Dependency warning dialogs
  • Fresh AST recomputation after selection
  • Iterative cleanup sessions
  • Edge cases (circular dependencies, all changes rejected, etc.)

6. Documentation

Update documentation to explain:

  • How to implement cleanups that support selective acceptance
  • How dependency tracking works in the UI
  • When to use requiresFreshASTAfterSelection()
  • Best practices for multi-file cleanup authors

Technical Notes

  • The backend infrastructure (IndependentChange, IndependentChangeImpl, IMultiFileCleanUp methods) already exists in PR Add multi-file cleanup API for coordinated changes across compilation units #68
  • Main work is integrating this into the UI layer (CleanUpRefactoringWizard, preview dialog)
  • Must maintain backward compatibility - cleanups that don't implement the new methods should work as before
  • Performance consideration: only recompute when necessary, cache ASTs where possible

Files to Modify

  1. UI Layer:

    • org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/fix/CleanUpRefactoringWizard.java
    • org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/refactoring/ - preview dialog classes
  2. Core Layer (if needed):

    • org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/fix/CleanUpRefactoring.java - enhance orchestration
  3. Tests:

    • org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/MultiFileCleanUpTest.java
  4. Documentation:

    • MULTI_FILE_CLEANUP.md
    • IMPLEMENTATION_SUMMARY.md

Acceptance Criteria

  • Users can uncheck individual changes in preview and see updated remaining changes
  • Dependency warnings are shown when rejecting changes that others depend on
  • Fresh AST recomputation works correctly when enabled
  • Iterative workflow (select → recompute → select) works smoothly
  • All existing tests pass
  • New tests cover the new functionality
  • Documentation is updated

Fixes #67 (remaining items)

This pull request was created from Copilot chat.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 28, 2026 05:09
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
Copilot AI changed the title [WIP] Enhance multi-file cleanup with selective change acceptance Add infrastructure and documentation for multi-file cleanup selective acceptance UI Jan 28, 2026
Copilot AI requested a review from carstenartur January 28, 2026 05:19
Copilot AI and others added 2 commits January 28, 2026 05:51
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
Co-authored-by: carstenartur <3164220+carstenartur@users.noreply.github.com>
Copilot AI changed the title Add infrastructure and documentation for multi-file cleanup selective acceptance UI Replace trivial test samples with realistic cleanup scenarios Jan 28, 2026
@carstenartur carstenartur marked this pull request as ready for review January 28, 2026 06:54
@carstenartur carstenartur merged commit d23da57 into copilot/add-multifile-cleanup-api Jan 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants