This repository was archived by the owner on Sep 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Add chained method calls to Dialect for fluent code navigation #34
Copy link
Copy link
Open
Labels
ai-managedAI is permitted to update this issue OP and add commentsAI is permitted to update this issue OP and add commentsenhancementNew feature or requestNew feature or request
Description
Objective
Add support for chained method calls in Dialect to enable more expressive and readable code navigation queries.
Problem
Current Dialect syntax is limited to simple function calls, making complex location queries verbose or impossible:
// Current - limited expressiveness
findDefinition(`User`)
search(`*.rs`, `TODO:`)
Solution
Implement chained method calls for fluent API-style navigation:
// Proposed - fluent and expressive
findDefinition(`User`).methods().named('validate')
search(`*.rs`, `TODO:`).limit(5).inFile('auth')
findReferences(`validate_token`).filter(f => f.path.includes('test')).first()
Implementation Ideas
Core Method Categories
Filtering methods:
.filter(predicate)- Filter results by condition.named(pattern)- Filter by name matching.inFile(pattern)- Filter by file path.inDirectory(path)- Filter by directory
Selection methods:
.first()- Take first result.last()- Take last result.limit(n)- Take first n results.at(index)- Take result at index
Symbol-specific methods:
.methods()- Get methods of a class/struct.fields()- Get fields of a class/struct.implementations()- Get trait implementations.usages()- Get usage sites
Location methods:
.line(n)- Move to specific line in same file.range(start, end)- Expand to line range
Example Use Cases
Find specific method in class:
findDefinition(`TokenValidator`).methods().named('validate')
Find TODO comments in auth module:
search(`src/auth/**/*.rs`, `TODO:`).limit(10)
Find test usages of a function:
findReferences(`validate_token`).inDirectory('tests').first()
Find struct fields:
findDefinition(`User`).fields().named('email')
Benefits
- More readable - Natural language-like queries
- More powerful - Complex filtering and selection
- Better UX - Easier for LLMs to generate correct expressions
- Extensible - Easy to add new methods over time
Implementation Notes
- Maintain backward compatibility with current simple function calls
- Consider lazy evaluation for performance
- Add comprehensive error messages for invalid chains
- Document method availability per result type
Context
This enhancement supports the new markdown+XML walkthrough format (#30) by making location expressions more natural and powerful for AI assistants to generate.
Metadata
Metadata
Assignees
Labels
ai-managedAI is permitted to update this issue OP and add commentsAI is permitted to update this issue OP and add commentsenhancementNew feature or requestNew feature or request