Skip to content

Conversation

@bgilbert6
Copy link

@bgilbert6 bgilbert6 commented May 15, 2025

This is still a work in progress with several issues and testing needed

Overview

This PR implements two new code analysis tools that enhance Roo's ability to understand and navigate codebases:

  1. find_references - Finds all references to a specific symbol across the workspace using VS Code's language services
  2. read_function - Reads a specific function definition from a file by name

These tools work together to create a powerful workflow for exploring code:

  • Use find_references to locate all references to a function across the codebase
  • See each reference with its containing function header for context
  • Use read_function to read the entire implementation of any function of interest

Key Features

find_references Tool

  • Uses VS Code's language services for language-aware reference finding
  • Shows function headers above each reference for better context
  • Groups references by file and function to avoid duplication
  • Displays workspace-relative paths for better readability
  • Includes line numbers in function headers for easier navigation
  • Handles overloaded methods by finding references across all overloads
  • Implements reference count threshold (50) with user approval for large results

read_function Tool

  • Extracts exact function definitions without reading entire files
  • Shows complete function implementation with line numbers
  • Returns all overloads of a function when multiple implementations exist
  • Clearly separates and numbers each overload for better readability
  • Maintains backward compatibility with a wrapper function

Technical Implementation

  • Created new service modules:

    • language-services - Core utilities for working with VS Code's language services
    • references - Service for finding and formatting references
    • function-reader - Service for reading and formatting function definitions
  • Added specialized C# support:

    • Implemented proper handling of method attributes using selectionRange
    • Added detailed logging for debugging C# reference issues
    • Enhanced support for overloaded methods
  • Enhanced output formatting:

    • Removed XML wrapping for cleaner output
    • Used Markdown formatting for better readability
    • Added workspace-relative paths instead of just filenames
    • Included line numbers in function headers

Testing

Documentation

Added detailed documentation in cline_docs/enhanced-code-reference-tools.md that includes:

  • Implementation plan and motivation
  • Tool descriptions and parameters
  • Example outputs and usage workflows
  • Potential issues and solutions

Related GitHub Issue

Closes: #

Description

Test Procedure

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

Documentation Updates

Additional Notes

- Fixed C# findReferences tool to use selectionRange instead of range
- Enhanced readFunction tool to handle overloaded functions
- Improved output formatting for both tools
- Added support for finding references across multiple overloads
- Fixed function context display in reference results
- Added workspace-relative paths to output
@changeset-bot
Copy link

changeset-bot bot commented May 15, 2025

⚠️ No Changeset found

Latest commit: 8bc3b2e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@samhvw8
Copy link
Contributor

samhvw8 commented May 15, 2025

cool, btw should read_function to read_symbol ?

@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 16, 2025
@bgilbert6 bgilbert6 changed the title Add tools find_references and read_function Add tool "find references" May 16, 2025
@hannesrudolph hannesrudolph moved this from New to PR [Draft/WIP] in Roo Code Roadmap May 20, 2025
@hannesrudolph hannesrudolph moved this from PR [Draft / In Progress] to TEMP in Roo Code Roadmap May 26, 2025
@daniel-lxs
Copy link
Member

Hey @bgilbert6,
Thank you for your contribution, We noticed this PR is stale and will be closed. If you plan to revisit this, please create an issue first as required by our issue-first approach before opening a new PR.

@daniel-lxs daniel-lxs closed this May 26, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft/WIP] to Done in Roo Code Roadmap May 26, 2025
@github-project-automation github-project-automation bot moved this from TEMP to Done in Roo Code Roadmap May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants