A Visual Studio Code extension that sorts methods in Java classes to increase code readability.
- Sort methods in Java classes based on multiple criteria:
- Access level (public, protected, package, private)
- Constructor separation
- Invocation order (depth-first or breadth-first)
- Lexical (alphabetical) ordering
- Cluster overloaded methods together
- Cluster getter and setter methods together
- Shuffle methods randomly (for testing purposes)
- Context menu integration
- Keyboard shortcut support
- Open a Java source file
- Right-click in the editor and select tlcsdm → Sort Methods
- Or use the keyboard shortcut
Alt+S - Or run the command "Sort Methods" from the Command Palette (
Ctrl+Shift+P)
- Open a Java source file
- Right-click in the editor and select tlcsdm → Shuffle Methods Randomly
- Or run the command "Shuffle Methods Randomly" from the Command Palette
Configure the sorting behavior through VS Code settings:
| Setting | Description | Default |
|---|---|---|
tlcsdm.methodsorter.sortingStrategy |
Invocation ordering strategy: depth-first or breadth-first |
depth-first |
tlcsdm.methodsorter.applyWorkingListHeuristics |
Apply heuristics to determine start points | true |
tlcsdm.methodsorter.respectBeforeAfterRelation |
Respect before/after relation in method ordering | true |
tlcsdm.methodsorter.clusterOverloadedMethods |
Keep overloaded methods together | false |
tlcsdm.methodsorter.clusterGetterSetter |
Keep getter and setter methods together | false |
tlcsdm.methodsorter.separateByAccessLevel |
Separate methods by access level | true |
tlcsdm.methodsorter.separateConstructors |
Separate constructors from other methods | true |
tlcsdm.methodsorter.applyLexicalOrdering |
Apply lexical ordering as a secondary sort | true |
When all options are enabled, methods are sorted in the following order:
- Constructors - Constructors come first
- Static methods - Static methods are grouped together
- Access level - Methods are grouped by access level:
- Public methods
- Protected methods
- Package-private methods
- Private methods
- Invocation order - Methods that call other methods come before the methods they call
- Lexical order - Alphabetical ordering of method names
- Original position - Maintains original order when all other criteria are equal
- Open VS Code
- Go to Extensions (
Ctrl+Shift+X) - Search for "Translation"
- Click Install
- Download the
.vsixfile from Releases - In VS Code, open Command Palette (
Ctrl+Shift+P) - Search for "Extensions: Install from VSIX..."
- Select the downloaded
.vsixfile
Download from Jenkins
This project uses TypeScript and npm (Node.js 22).
# Install dependencies
npm install
# Compile
npm run compile
# Watch mode (for development)
npm run watch
# Lint
npm run lint
# Package
npx @vscode/vsce package
# Test
npm run testThis project is licensed under the MIT License - see the LICENSE file for details.