ScalaFuncRefactor
ScalaFuncRefactor is a Visual Studio Code extension designed to assist developers in converting object-oriented Scala code into a more functional programming style. It leverages a Scala-based static analysis backend and provides refactoring suggestions directly in the IDE.
✨ Features
🚀 Real-time Refactoring (NEW!)
- Live Suggestions: Get refactoring suggestions as you type (1.5s debounce)
- Minimal Impact: Only processes changed content, uses intelligent caching
- Performance Optimized: Incremental processing with timeout protection
- Smart Detection: Automatically detects significant changes vs minor edits
🎯 Enhanced UI (NEW!)
- Modern Interface: Beautiful, responsive sidebar with statistics
- Quick Actions: Accept/reject individual suggestions or apply all at once
- Inline Suggestions: VS Code native inline completion support
- Quick Fixes: Ctrl+. for instant refactoring options
🔧 Core Features
- Detects 25+ Scala refactoring patterns (loops, conditionals, collections)
- Highlights suggestions with gutter icons and hover messages
- Automatic transformations with undo support
- Parallel processing using
.par for large collections
- Intelligent caching to avoid reprocessing unchanged code
- UI Panels:
- Enhanced Refactor Panel: Modern UI with statistics and quick actions
- Chat Panel: (Experimental) for interactive feedback or guidance
- Integrates with a Scala backend for static code analysis
- Commands available from Command Palette for quick access
🧩 Commands
Real-time Commands (NEW!)
| Command |
Description |
Pause Real-time Refactoring |
Temporarily disable real-time suggestions |
Resume Real-time Refactoring |
Re-enable real-time suggestions |
Apply All Suggestions |
Apply all current suggestions at once |
Show Current Suggestions |
Display count of current suggestions |
Core Commands
| Command |
Description |
Func Refactor |
Run the refactoring logic manually |
Add UI |
Launch the enhanced UI panel |
Remove Suggestions |
Clear the currently shown suggestions |
Start Chat |
Launch chat panel |
Open Sidebar |
Open the sidebar activity panel |
🚀 Getting Started
1. Install Extension
You can install it manually:
code --install-extension scala-func-refactor-0.0.1.vsix
Or install it from the Visual Studio Marketplace
2. Automatic Real-time Suggestions
The extension now works automatically! Just start typing Scala code and you'll see:
- ⚡ Gutter icons on lines with refactoring opportunities
- Hover messages with detailed suggestions
- Inline completion suggestions as you type
- Quick fixes available with Ctrl+.
3. Using the Enhanced UI
- Open the Enhanced Refactor Panel from the sidebar
- View real-time statistics of suggestions
- Accept/reject individual suggestions or apply all at once
- Use the modern interface for better productivity
2. Project Structure
.
├── extension.js # Main extension activation file
├── media/ # Icons for sidebar views
│ ├── chat.png
│ └── refactor.jpg
├── test/ # Test files
├── package.json # Extension manifest
└── README.md # This file
🛠 Development
- Clone the repo
- Run in VS Code using
F5 (Extension Development Host)
- Update
extension.js to connect to your Scala backend via a process or HTTP
- Rebuild
.vsix for distribution:
vsce package
📌 Requirements
- Node.js ≥ 18
- Scala backend running locally (e.g., via sbt or standalone jar)
- VS Code ≥ 1.77
💡 Future Development
These are planned enhancements:
- [ ] Refactoring preview with inline code actions
- [ ] Integration with Scala Language Server (LSP) for seamless AST access
- [ ] Automatic transformations with undo support
- [ ] UI improvements to support categorized suggestions (loops, conditionals, collections, etc.)
- [ ] Background task runner for continuous linting
- [ ] Chat-like explanation of suggestions (LLM-backed)
- [ ] Custom Rules for Refactoring
🧑💻 Author
Shiv Kiran Bagathi
GitHub: @Shiv-Kiran
VS Code Publisher: shivK
📃 License
MIT License — Feel free to fork, improve, and contribute!