-
Notifications
You must be signed in to change notification settings - Fork 1
Refactoring
Sevhena Walker edited this page Apr 4, 2025
·
3 revisions
EcoOptimizers provides multiple pathways to initiate code improvements:
-
From the Editor:
When you hover over a highlighted code smell in your source file, a detailed tooltip appears showing:- The exact nature of the smell
- The proposed refactoring solution
- Two action buttons:
- "Refactor Smell" (targets only the current instance)
- "Refactor All of this [Type]" (applies to all occurrences in the file)

-
From the Sidebar:
In the Code Smells panel:- Click a smell's wrench icon to refactor that specific instance
- Click a file's wrench icon to see a menu of all smell types present in that file, then select which type to refactor comprehensively

-
From the Command Palette:
Use "Eco: Refactor All of this [Type]" to initiate bulk refactoring after selecting a target file through the subsequent prompt.
When you initiate any refactoring operation, EcoOptimizers enters a special review mode:
-
The main editor area splits to show a diff view comparing original and refactored code
-
The Refactoring Details panel activates to show:
- The specific smell type being addressed
- Detailed explanation of the changes
- Estimated energy savings (in kg CO₂ equivalent)
- Tree view of all affected files (primary file plus any dependencies)
-
The VS Code status bar displays action buttons:
- "Accept" (checkmark icon): Apply the changes
- "Reject" (X icon): Abandon the refactoring
During this review phase, you can:
- Click any file in the affected files tree to view its changes
- Scroll through the diff to examine modifications in detail
- Use standard VS Code diff navigation shortcuts
Upon accepting changes, the extension:
- Updates all affected files
- Records the carbon savings in the Metrics panel
- Refreshes the Code Smells panel to reflect the improved state