|
| 1 | +# Language Tool Ideas for ElixirLS |
| 2 | + |
| 3 | +## Overview |
| 4 | +These are language tool ideas that would be particularly useful for LLMs working with Elixir codebases. The focus is on information that is difficult to obtain via command-line tools but readily available through the language server's compiled beam files and AST analysis. |
| 5 | + |
| 6 | +## High-Priority Tools |
| 7 | + |
| 8 | +### 1. **Module Dependency Graph Tool** |
| 9 | +**Problem**: LLMs struggle to understand complex module relationships, especially with aliases, imports, and use statements. |
| 10 | +**Solution**: Return a graph of module dependencies showing: |
| 11 | +- Which modules a given module depends on |
| 12 | +- Which modules depend on a given module |
| 13 | +- Transitive dependencies |
| 14 | +- Alias mappings in context |
| 15 | + |
| 16 | +### 2. **Behaviour Implementation Finder** |
| 17 | +**Problem**: Finding all modules that implement a specific behaviour requires searching through entire codebases. |
| 18 | +**Solution**: Given a behaviour module (e.g., `GenServer`), return all modules that implement it with: |
| 19 | +- Module name and location |
| 20 | +- Which callbacks are implemented |
| 21 | +- Which callbacks are missing/using defaults |
| 22 | + |
| 23 | +### 3. **Function Call Hierarchy Tool** |
| 24 | +**Problem**: Understanding which functions call a given function is nearly impossible via CLI. |
| 25 | +**Solution**: Provide bidirectional call information: |
| 26 | +- All callers of a function |
| 27 | +- All functions called by a function |
| 28 | +- Call sites with line numbers |
| 29 | +- Distinguishes between local and remote calls |
| 30 | + |
| 31 | +### 4. **Type Information Extractor** |
| 32 | +**Problem**: Getting complete type information including specs, types, and Dialyzer inferences. |
| 33 | +**Solution**: For a given function/module, return: |
| 34 | +- @spec definitions |
| 35 | +- @type definitions |
| 36 | +- Dialyzer's inferred types |
| 37 | +- Parameter names with their types |
| 38 | +- Return type information |
| 39 | + |
| 40 | +### 5. **OTP Supervision Tree Analyzer** |
| 41 | +**Problem**: Understanding GenServer/Supervisor relationships in running systems. |
| 42 | +**Solution**: Extract and visualize: |
| 43 | +- Supervisor hierarchy |
| 44 | +- Child specifications |
| 45 | +- Restart strategies |
| 46 | +- Process registration names |
| 47 | +- GenServer state structure |
| 48 | + |
| 49 | +## Medium-Priority Tools |
| 50 | + |
| 51 | +### 6. **Protocol Implementation Finder** |
| 52 | +**Problem**: Finding all implementations of a protocol across the codebase. |
| 53 | +**Solution**: Given a protocol, return: |
| 54 | +- All implementing modules |
| 55 | +- Implementation details |
| 56 | +- Consolidated status |
| 57 | + |
| 58 | +### 7. **Compile-Time Dependency Analyzer** |
| 59 | +**Problem**: Understanding what will trigger recompilation. |
| 60 | +**Solution**: Show: |
| 61 | +- Compile-time dependencies between modules |
| 62 | +- Runtime-only dependencies |
| 63 | +- Modules that will recompile if a given module changes |
| 64 | + |
| 65 | +### 8. **Mix Task Inspector** |
| 66 | +**Problem**: Discovering and understanding project-specific Mix tasks. |
| 67 | +**Solution**: List all available Mix tasks with: |
| 68 | +- Task name and module |
| 69 | +- Documentation |
| 70 | +- Required arguments |
| 71 | +- Task dependencies |
| 72 | + |
| 73 | +### 9. **Module Documentation Aggregator** |
| 74 | +**Problem**: Getting comprehensive documentation beyond just function docs. |
| 75 | +**Solution**: Extract: |
| 76 | +- @moduledoc |
| 77 | +- All @doc entries |
| 78 | +- @typedoc entries |
| 79 | +- Examples from docs |
| 80 | +- Related modules mentioned in docs |
| 81 | + |
| 82 | +### 10. **Function Arity Explorer** |
| 83 | +**Problem**: Understanding all versions of overloaded functions. |
| 84 | +**Solution**: Given a function name, return: |
| 85 | +- All arities with their specs |
| 86 | +- Default arguments expansion |
| 87 | +- Clause patterns |
| 88 | +- Guard conditions |
| 89 | + |
| 90 | +## Lower-Priority Tools |
| 91 | + |
| 92 | +### 11. **Test Coverage Mapper** |
| 93 | +**Problem**: Understanding which tests cover specific functions. |
| 94 | +**Solution**: Map between: |
| 95 | +- Functions and their test files |
| 96 | +- Test names that exercise specific code |
| 97 | +- Uncovered functions |
| 98 | + |
| 99 | +### 12. **Message Flow Tracer** |
| 100 | +**Problem**: Understanding inter-process communication. |
| 101 | +**Solution**: Analyze: |
| 102 | +- send/receive patterns |
| 103 | +- GenServer call/cast usage |
| 104 | +- Message types between processes |
| 105 | + |
| 106 | +### 13. **Configuration Explorer** |
| 107 | +**Problem**: Understanding application configuration. |
| 108 | +**Solution**: Extract: |
| 109 | +- Config values for all environments |
| 110 | +- Config dependencies |
| 111 | +- Runtime vs compile-time config |
| 112 | + |
| 113 | +### 14. **Macro Usage Analyzer** |
| 114 | +**Problem**: Understanding where and how macros are used. |
| 115 | +**Solution**: For a given macro: |
| 116 | +- All usage sites |
| 117 | +- Expanded forms at each site |
| 118 | +- Import/require chains |
| 119 | + |
| 120 | +## Implementation Considerations |
| 121 | + |
| 122 | +### Advantages of Language Server Implementation: |
| 123 | +1. **Already compiled code**: Access to beam files with debug info |
| 124 | +2. **AST availability**: Parsed and analyzed code ready for querying |
| 125 | +3. **Incremental updates**: Changes tracked in real-time |
| 126 | +4. **Cross-reference data**: Xref information already maintained |
| 127 | +5. **Type information**: Dialyzer PLTs already built |
| 128 | + |
| 129 | +### Why These Are Hard via CLI: |
| 130 | +1. Would require repeated compilation/parsing |
| 131 | +2. No persistent state between queries |
| 132 | +3. Complex grep patterns miss context |
| 133 | +4. No semantic understanding |
| 134 | +5. Can't follow compile-time transformations |
| 135 | + |
| 136 | +### Priority Rationale: |
| 137 | +- **High**: Fundamental to understanding code structure |
| 138 | +- **Medium**: Useful for specific tasks but not always needed |
| 139 | +- **Lower**: Nice to have but can be worked around |
| 140 | + |
| 141 | +## Next Steps |
| 142 | +1. Start with Module Dependency Graph as it provides the most value |
| 143 | +2. Implement Type Information Extractor to help with code generation |
| 144 | +3. Add Function Call Hierarchy for refactoring support |
| 145 | +4. Build on existing ElixirLS infrastructure (e.g., Xref, Dialyzer integration) |
0 commit comments