name: eclipse-analyze description: Analyze Java code using Eclipse JDT tools — type hierarchy, find references, call hierarchy, compilation errors, quick fixes, and import suggestions. Use this to understand code structure before making changes. argument-hint: [class or element to analyze] allowed-tools: mcp__eclipse-ide__getClassOutline, mcp__eclipse-ide__getMethodSource, mcp__eclipse-ide__getFilteredSource, mcp__eclipse-ide__getTypeHierarchy, mcp__eclipse-ide__findReferences, mcp__eclipse-ide__getMethodCallHierarchy, mcp__eclipse-ide__getCompilationErrors, mcp__eclipse-ide__getQuickFixes, mcp__eclipse-ide__getImportSuggestions, mcp__eclipse-ide__getJavaDoc, mcp__eclipse-ide__getSource, mcp__eclipse-ide__getProjectLayout, mcp__eclipse-ide__getProjectProperties, mcp__eclipse-ide__readProjectResource, mcp__eclipse-ide__listProjects, mcp__eclipse-ide__getCurrentlyOpenedFile, mcp__eclipse-ide__getEditorSelection, mcp__eclipse-ide__fileSearch, mcp__eclipse-ide__fileSearchRegExp, mcp__eclipse-ide__findFiles, mcp__eclipse-ide__getProjectDependencies
Eclipse Code Analysis
Analyze Java code using Eclipse's JDT (Java Development Tools) infrastructure. These tools provide accurate, compiler-level analysis — not text-based guessing.
Reading Code Efficiently
These tools are designed to minimize context window usage. Follow the outline-first pattern:
getClassOutline — Start here. Returns class declaration, field declarations, method signatures (no bodies), and inner types — all with line numbers. A 500-line class becomes ~30 lines. Provide
fullyQualifiedClassName. SetincludeFields=falseto omit fields.getMethodSource — After seeing the outline, read only the methods you need. Accepts comma-separated
methodNames(e.g.,"save,findById,delete"). Returns source with line numbers. SetincludeJavadoc=falseto skip doc comments. UsemethodSignatureto disambiguate overloads (e.g.,"String"matches methods with a String parameter).getFilteredSource — Middle ground: returns the full source but collapses methods you don't need to their signatures. Provide
methodNamesto expand specific methods; all others are shown as one-line signatures with line ranges. SetexcludeImports=true(the default) to collapse the import block. Line numbers always match the original file for accurate editing.getSource — Full source dump. Use only for small classes or when you need everything. Prefer the tools above to save context.
readProjectResource — Read any file by path. Supports
startLine/endLinefor ranges,showLineNumbers=truefor editing, andexcludeImports=trueto collapse Java import blocks.
Choosing the Right Tool
| Scenario | Tool | Why |
|---|---|---|
| Understand class structure | getClassOutline |
Signatures only, ~90% smaller |
| Read 1-3 specific methods | getMethodSource |
Surgical reads with line numbers |
| Read class but focus on 2 methods | getFilteredSource |
Full context, collapsed noise |
| Small class (<100 lines) | getSource |
Overhead not worth optimizing |
| Non-Java file or specific line range | readProjectResource |
Works with any file type |
Navigation & Understanding
- getTypeHierarchy — Show supertypes, implemented interfaces, and subtypes for a class.
- findReferences — Find all usages of a type, method, or field across the workspace. Essential before renaming or deleting.
- getMethodCallHierarchy — Show callers and callees of a method. Use
methodSignaturefor overloaded methods. - getJavaDoc — Get JavaDoc for a compilation unit by fully qualified name.
Error Analysis
- getCompilationErrors — Get all compilation errors/warnings. Filter by
projectNameandseverity(ERROR, WARNING, ALL). - getQuickFixes — Get available quick fixes for errors in a file. Optionally filter by
lineNumber. - getImportSuggestions — Find import candidates for unresolved types.
Project Navigation
- getProjectLayout — File/folder structure. Use
scopePathandmaxDepthfor large projects. - getProjectProperties — Java version, source folders, output location, natures.
- listProjects — All workspace projects with their natures.
- getProjectDependencies — Maven dependencies for a project.
Search
- fileSearch — Plain text search across workspace files. Filter with
fileNamePatterns. - fileSearchRegExp — Regex search across workspace files.
- findFiles — Find files by glob patterns (e.g.,
*.xml,pom.xml).
Editor Context
- getCurrentlyOpenedFile — Get the file currently active in the Eclipse editor.
- getEditorSelection — Get the currently selected text/lines in the active editor.
Recommended Workflow
- Orient:
listProjectsorgetProjectLayoutto find what you need - Outline:
getClassOutlineto understand class structure - Focus:
getMethodSourceto read specific methods, orgetFilteredSourcefor full-but-collapsed view - Analyze:
getTypeHierarchy,findReferences,getMethodCallHierarchyas needed - After edits:
getCompilationErrorsto verify, thengetQuickFixesorgetImportSuggestionsto resolve