JetBrains: add jet_brains_find_unused_code tool#1535
Open
MischaPanch wants to merge 1 commit into
Open
Conversation
Add the jet_brains_find_unused_code tool (JetBrainsFindUnusedCodeTool) backed by a new find_unused_code plugin-client method that calls the plugin's /findUnusedCode endpoint, and enable it in the jetbrains internal mode. It reports code symbols (classes, methods, fields, ...) declared in a file that have no references in the project - a usage-based heuristic for finding likely-dead code. Requires Serena JetBrains plugin version 2023.2.17+. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new JetBrains-backend tool,
jet_brains_find_unused_code, which reports code symbols(classes, methods, fields, …) declared in a file that have no references anywhere in the project —
i.e. code that is likely unused/dead.
It is a thin client over a new
/findUnusedCodeendpoint in the Serena JetBrains plugin: the pluginwalks the IDE's structure-view declaration tree and flags each declaration whose PSI reference search
comes back empty.
Changes
jetbrains/jetbrains_plugin_client.py: newfind_unused_code(relative_path, include_quick_info)client method (calls
/findUnusedCode; version-gated to plugin 2023.2.17+).tools/jetbrains_tools.py: newJetBrainsFindUnusedCodeTool(ToolMarkerSymbolicRead,ToolMarkerOptional,ToolMarkerBeta); groups results by file/type, or returns a "none found" message.resources/config/internal_modes/jetbrains.yml: registerjet_brains_find_unused_codeinincluded_optional_tools(so theJetBrainslanguage backend exposes it) and mention it in the mode prompt.CHANGELOG.md: entry under Unreleased → JetBrains.Caveats (documented in the tool description)
This is a usage-based heuristic via the IDE's reference search:
mainmethods, public API consumed outside the project) and reflective/frameworkusages are not accounted for and may produce false positives;
So results should be reviewed before deletion.
Requirements
Requires the Serena JetBrains plugin 2023.2.17+ (which adds the
/findUnusedCodeendpoint). Theclient raises a clear "update the plugin" error against older versions.
Testing
Verified end-to-end against the plugin's headless Docker harness (the serena MCP server built from this
checkout, driving the plugin in IntelliJ): on a sample project the tool reports the one unused private
method and omits the used members, via the full round-trip
MCP client → serena → plugin /findUnusedCode → IntelliJ PSI.poe formatandpoe type-checkpass.🤖 Generated with Claude Code