Palantír — Refactoring Risk Analyzer
"The palantíri were made so that those who had them could see far, and know the minds of men."
— J.R.R. Tolkien
Palantír is a VS Code extension that gives you the Blast Radius of any change — before you make it. It uses the Language Server Protocol (LSP) to analyze how many places in your codebase depend on a given method or function, and surfaces that information directly in your editor via CodeLens indicators above every method signature.
Stop guessing the impact of a refactoring. Let Palantír show you.
How It Works
Palantír hooks into VS Code's built-in LSP infrastructure. When you open a supported file, it:
- Discovers all methods, functions, and constructors using
DocumentSymbolProvider
- Counts their references across the entire project using
ReferenceProvider
- Renders a risk indicator directly above each method signature via CodeLens
No external servers. No indexing step. No configuration required.
Risk Indicators
Each method gets a color-coded Blast Radius label:
| Indicator |
References |
Meaning |
| 🟢 Low Impact |
< 5 |
Safe to refactor freely |
| 🟠 Medium Impact |
5 – 20 |
Review callers before changing |
| 🔴 HIGH RISK |
> 20 |
High coupling — proceed with caution |
Click any CodeLens label to jump to all references instantly.
Framework-Aware Context Badges
Palantír understands the frameworks you work with and adds contextual badges alongside the risk indicator:
Spring Boot (Java)
| Annotation |
Badge |
@GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping |
[REST] |
@RequestMapping |
[REST] |
@Scheduled |
[Scheduler] |
@EventListener, @TransactionalEventListener |
[Event] |
@Bean |
[Bean] |
@Transactional |
[Transactional] |
@Query |
[Query] |
@Around, @Before, @After, @AfterReturning, @AfterThrowing |
[AOP] |
NestJS (TypeScript)
| Decorator |
Badge |
@Get(), @Post(), @Put(), @Delete(), @Patch() |
[REST] |
@MessagePattern(), @EventPattern() |
[Microservice] |
@SubscribeMessage() |
[WebSocket] |
@UseGuards(), @UseInterceptors(), @UsePipes() |
[Guard/Pipe] |
@CommandHandler(), @QueryHandler() |
[CQRS] |
Angular (TypeScript)
| Decorator / Pattern |
Badge |
@HostListener() |
[DOM Event] |
ngOnInit, ngOnDestroy, ngOnChanges, ngAfterViewInit |
[Lifecycle] |
@ViewChild(), @ContentChild() |
[View Hook] |
createEffect() |
[NgRx Effect] |
Flutter / Dart
| Pattern |
Badge |
build(BuildContext) |
[Widget Build] |
initState, dispose, didChangeDependencies |
[Lifecycle] |
@override |
[override] |
Example output:
Palantir [REST]: 🟠 Medium Impact (9 refs) ← @GetMapping Spring Boot endpoint
Palantir [Transactional]: 🔴 HIGH RISK (23 refs) ← critical service method
Palantir [Lifecycle]: 🟢 Low Impact (1 refs) ← ngOnInit Angular hook
Palantir [Widget Build]: 🟢 Low Impact (1 refs) ← Flutter widget
Palantir: 🟢 Low Impact (2 refs) ← plain function, no framework
Supported Languages
| Language |
Supported |
Notes |
| TypeScript |
✅ |
Full support, NestJS & Angular aware |
TypeScript React (.tsx) |
✅ |
|
| JavaScript |
✅ |
|
JavaScript React (.jsx) |
✅ |
|
| Java |
✅ |
Spring Boot aware — requires LSP extension |
| Dart |
✅ |
Flutter lifecycle & widget aware |
Required Extensions (Language Servers)
Palantír relies on VS Code's LSP to find symbols and count references. For most languages, VS Code handles this natively. Java is the exception — it requires the official language server to be installed.
Java — Required
Language Support for Java™ by Red Hat
Extension ID: redhat.java
Without this extension, Palantír cannot discover Java symbols or count references. The Red Hat extension provides the full Java Language Server that powers symbol resolution, reference lookup, and project indexing.
Recommended companion extensions for Spring Boot:
| Extension |
ID |
Purpose |
| Spring Boot Extension Pack |
vmware.vscode-boot-dev-pack |
Full Spring tooling suite |
| Spring Boot Tools |
vmware.vscode-spring-boot |
Application properties & bean graph |
TypeScript / JavaScript — Built-in ✅
No additional extensions required. VS Code ships with a native TypeScript Language Server.
Dart / Flutter — Required
Dart
Extension ID: Dart-Code.dart-code
This extension provides the Dart Analyzer, which powers symbol resolution and reference lookup for both Dart and Flutter projects.
Getting Started
Running in Development
- Clone this repository
- Install dependencies:
npm install
- Start the build watcher:
npm run watch
- Press F5 to launch the Extension Development Host
- Open any supported file — CodeLens indicators will appear above each method
Installing from VSIX
npm run package
This generates a .vsix file. Install it via:
Extensions → ⋯ → Install from VSIX...
Architecture
src/
├── extension.ts # Entry point — registers the CodeLens provider
├── PalantirProvider.ts # Core CodeLens provider (symbol discovery + reference counting)
└── FrameworkDetector.ts # Framework pattern matcher (badges via regex)
| Component |
Responsibility |
extension.ts |
Activates on supported languages, wires up the provider |
PalantirProvider.ts |
Implements provideCodeLenses (symbol scan) and resolveCodeLens (LSP reference query) |
FrameworkDetector.ts |
Scans the ~8 lines above each symbol for framework decorators/annotations |
Requirements
- VS Code
^1.100.0 (or any compatible fork)
- Node.js
>=18
Author
Built with 🔭 by Kaxius to help developers see further.