You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: package.json
+16-2Lines changed: 16 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -52,8 +52,15 @@
52
52
{
53
53
"name": "lsp_java_getFileStructure",
54
54
"toolReferenceName": "javaFileStructure",
55
-
"modelDescription": "Get the outline (classes, methods, fields) of a Java file with symbol kinds and line ranges.\n\nUse before read_file to find specific line ranges. For searching across files, use lsp_java_findSymbol instead.\n\nOnly use file paths confirmed from prior tool results or user input. If unsure, call lsp_java_findSymbol first.",
55
+
"modelDescription": "Get a known Java file's outline: classes, interfaces, methods, fields, symbol kinds, and line ranges, to pick a precise read_file range instead of reading the whole file.\n\nUse after lsp_java_findSymbol returns a file, or when the user gave a Java file path; do not guess paths. Not for workspace-wide search\u2014use lsp_java_findSymbol for that. Do not re-call for the same file unless the first result was empty.",
56
56
"displayName": "Java: Get File Structure",
57
+
"userDescription": "Get a Java file outline with classes, methods, fields, and line ranges.",
"modelDescription": "Search for Java symbol definitions (classes, interfaces, methods, fields) across the entire workspace by name. Returns precise locations in ~60 tokens vs ~500+ tokens from grep_search.\n\nWhen to use:\n- To find where a class, method, or field is defined — faster and more precise than grep_search\n- To discover file paths before using other tools\n- Supports partial matching (e.g. 'UserSvc' finds 'UserServiceImpl')\n\nWhen NOT to use:\n- For non-Java files\n- To search for string literals, comments, or non-symbol text (use grep_search)",
83
+
"modelDescription": "Find Java class, interface, method, or field definitions across the workspace by name or partial identifier. Prefer over grep_search, file_search, semantic_search, or search subagents for Java symbol lookup.\n\nOn relevant results, do not repeat with a similar query; continue with lsp_java_getFileStructure or read_file on the returned line range. The tool retries internally, so on an empty result do not re-search\u2014retry once only if it reports indexing in progress, otherwise use generic search.\n\nDo not use for non-Java files, literals, comments, build/XML files, or conceptual exploration.",
77
84
"displayName": "Java: Find Symbol",
85
+
"userDescription": "Find Java class, method, field, or interface definitions by name.",
description: REQUIRED for Java files. Provides compiler-accurate lsp_java_findSymbol and lsp_java_getFileStructure tools that replace grep_search, search_subagent, semantic_search, and file_search for Java symbol navigation.
2
+
description: Use Java LSP tools for precise Java symbol navigation. Prefer lsp_java_findSymbol and lsp_java_getFileStructure over generic search only when locating Java classes, methods, fields, or file outlines.
3
3
applyTo: '**/*.java'
4
4
---
5
5
6
-
For Java files, two compiler-accurate `lsp_java_*` tools are available and return structured results in ~50 tokens vs ~500+ from generic search:
6
+
For Java symbol navigation, two compiler-accurate `lsp_java_*` tools are available and return structured results with smaller, easier-to-interpret payloads than generic search:
7
7
8
8
-`lsp_java_findSymbol(query)` — find class/method/field definitions by name across the workspace
9
9
-`lsp_java_getFileStructure(uri)` — get file outline (classes, methods, fields) with line ranges
10
10
11
-
These are deferred tools. Load them with `tool_search_tool_regex` using pattern `lsp_java_` before first use.
11
+
If these tools are not already available in the current tool list, load them with `tool_search` using a query such as `Java LSP symbol navigation lsp_java`.
12
12
13
-
Prefer these over`grep_search`, `search_subagent`, `semantic_search`, `file_search`, or full-file `read_file` when navigating Java symbols. Always use `findSymbol` to discover file paths before passing them to `getFileStructure` — do not guess paths. Fall back to `grep_search` if a tool returns empty or errors.
13
+
Use `lsp_java_findSymbol` before`grep_search`, `search_subagent`, `semantic_search`, or `file_search` only when the task is to locate Java symbols by name or partial identifier. If it returns relevant symbols, do not call it again with the same or similar query; next use `lsp_java_getFileStructure` for the returned file or `read_file` on the smallest useful line range.
14
14
15
+
Use `lsp_java_getFileStructure` only with a path confirmed by the user or a previous tool result. Do not guess paths. Use generic search for string literals, comments, XML, Gradle/Maven files, non-Java files, or broad conceptual exploration. `findSymbol` already retries internally with a normalized identifier, so do not re-issue the same search on an empty result: if it reports indexing in progress, retry once after a short pause; otherwise fall back to generic search.
description: Compiler-accurate Java code navigation via the Java Language Server. Use lsp_java_findSymbol to locate symbols and lsp_java_getFileStructure to inspect file outlines. Prefer over grep_search for Java symbol navigation.
3
+
description: Compiler-accurate Java symbol navigation via the Java Language Server. Use lsp_java_findSymbol for Java identifiers and lsp_java_getFileStructure for known Java files; prefer them over generic search only for symbol/file-outline navigation.
4
4
---
5
5
6
6
# Java LSP Tools
7
7
8
-
Two compiler-accurate tools backed by the Java Language Server (jdtls). They return structured JSON with fewer tokens than `grep_search` or `read_file`.
8
+
Two compiler-accurate tools backed by the Java Language Server (jdtls). They return structured JSON that is easier to interpret than generic search results for Java symbol navigation.
9
9
10
10
## Tools
11
11
12
12
### `lsp_java_findSymbol`
13
13
Search for Java symbol definitions (classes, methods, fields) by name across the workspace. Supports partial matching.
14
14
- Input: `{ query, limit? }` — limit defaults to 20, max 50
15
-
- Output: `{ name, kind, location }` per result (~60 tokens)
16
-
-**Use instead of**`grep_search` when looking for where a class/method is defined
15
+
- Output: `{ results: [{ name, kind, container?, location, range }], total }` (~60 tokens); `range` is `L start-end`
16
+
-**Use instead of**`grep_search`, `file_search`, `semantic_search`, or `search_subagent` when looking for where a Java class/method/field is defined by identifier
17
+
- Do not repeat with the same or similar query after relevant results are returned
17
18
18
19
### `lsp_java_getFileStructure`
19
20
Get hierarchical outline of a Java file (classes, methods, fields) with line ranges.
20
21
- Input: `{ uri }` — workspace-relative path. Must be a known path from prior tool results or user input — do not guess
21
22
- Output: symbol tree with `L start-end` ranges (~100 tokens)
22
-
-**Use instead of**`read_file`full scan when you need to understand a file's layout
23
+
-**Use before**`read_file` when you need to choose a precise line range in a known Java file
If `findSymbol` returns relevant symbols, move forward to `getFileStructure` or `read_file`; do not call `findSymbol` again with the same or similar identifier.
40
+
37
41
## Fallback
38
42
39
-
-`findSymbol` returns empty → retry with shorter keyword, then fall back to `grep_search`
40
-
- Path error → use `findSymbol` to discover correct path first
43
+
-`findSymbol` returns empty → it already retried internally with a normalized identifier, so do not re-issue the same search. If the result says indexing is in progress, retry once after a short pause; otherwise fall back to `grep_search`
44
+
- Path error (`fileNotFound`) → use `findSymbol` to discover the correct path first; do not guess paths
41
45
- Tool error / jdtls not ready → fall back to `grep_search` + `read_file`, don't retry more than once
0 commit comments