From 5801982113bd4434baf5bb84e928c3c82485db20 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 22 Dec 2025 13:29:02 +0700 Subject: [PATCH] Docstrings, minor fixes [ci skip] --- src/serena/tools/jetbrains_plugin_client.py | 5 ++--- src/serena/tools/jetbrains_tools.py | 2 +- src/serena/tools/symbol_tools.py | 11 +---------- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/serena/tools/jetbrains_plugin_client.py b/src/serena/tools/jetbrains_plugin_client.py index a02d4600..7a3c6f38 100644 --- a/src/serena/tools/jetbrains_plugin_client.py +++ b/src/serena/tools/jetbrains_plugin_client.py @@ -174,13 +174,12 @@ class JetBrainsPluginClient(ToStringMixin): request_data = {"namePath": name_path, "relativePath": relative_path} return self._make_request("POST", "/findReferences", request_data) - def get_symbols_overview(self, relative_path: str, depth: int, exclude_imports: bool = True) -> dict[str, Any]: + def get_symbols_overview(self, relative_path: str, depth: int) -> dict[str, Any]: """ :param relative_path: the relative path to a source file :param depth: the depth of children to include (0 = no children) - :param exclude_imports: whether to exclude import statements from the overview """ - request_data = {"relativePath": relative_path, "depth": depth, "excludeImports": exclude_imports} + request_data = {"relativePath": relative_path, "depth": depth} return self._make_request("POST", "/getSymbolsOverview", request_data) def rename_symbol( diff --git a/src/serena/tools/jetbrains_tools.py b/src/serena/tools/jetbrains_tools.py index afe3113e..a14a9402 100644 --- a/src/serena/tools/jetbrains_tools.py +++ b/src/serena/tools/jetbrains_tools.py @@ -147,7 +147,7 @@ class JetBrainsGetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOp :param depth: depth up to which descendants shall be retrieved (e.g., use 1 to also retrieve immediate children). :param max_answer_chars: max characters for the JSON result. If exceeded, no content is returned. -1 means the default value from the config will be used. - :return: a JSON object containing the symbols + :return: a JSON object containing the symbols grouped by kind in a compact format. """ with JetBrainsPluginClient.from_project(self.project) as client: response_dict = client.get_symbols_overview(relative_path=relative_path, depth=depth) diff --git a/src/serena/tools/symbol_tools.py b/src/serena/tools/symbol_tools.py index 64261874..bcd244a5 100644 --- a/src/serena/tools/symbol_tools.py +++ b/src/serena/tools/symbol_tools.py @@ -3,12 +3,11 @@ Language server-related tools """ import os +from collections import defaultdict from collections.abc import Sequence from copy import copy from typing import Any -from black.trans import defaultdict - from serena.tools import ( SUCCESS_RESULT, Tool, @@ -64,14 +63,6 @@ class GetSymbolsOverviewTool(Tool, ToolMarkerSymbolicRead): no content will be returned. -1 means the default value from the config will be used. Don't adjust unless there is really no other way to get the content required for the task. :return: a JSON object containing symbols grouped by kind in a compact format. - - For depth=0, the structure is: {"Kind1": ["name1", "name2"], "Kind2": ["name3"]} - For depth>0, symbols with children use nested dicts: {"Class": [{"ClassName": {"Method": ["method1", "method2"]}}]} - - The name_path for any symbol can be inferred from the structure: - - Top-level symbols: name_path = name - - Nested symbols: name_path = parent_name + "/" + name - Example: "method1" under class "ClassName" has name_path "ClassName/method1" """ symbol_retriever = self.create_language_server_symbol_retriever() file_path = os.path.join(self.project.project_root, relative_path)