MCPcopy Create free account
hub / github.com/FSoft-AI4Code/HyperAgent / _run

Method _run

src/hyperagent/tools/nav_tools.py:168–198  ·  view source on GitHub ↗

Run the tool to find all references of a target symbol. Args: word (str): The target symbol to find references for. line (int): The line number where the target symbol is located. relative_path (str): The relative path of the file containing the

(self, word: str, relative_file_path: str, line: Optional[int] = None, num_results: int = 10)

Source from the content-addressed store, hash-verified

166 self.lsptoolkit = LSPToolKit(path, language)
167
168 def _run(self, word: str, relative_file_path: str, line: Optional[int] = None, num_results: int = 10):
169 """
170 Run the tool to find all references of a target symbol.
171
172 Args:
173 word (str): The target symbol to find references for.
174 line (int): The line number where the target symbol is located.
175 relative_path (str): The relative path of the file containing the target symbol.
176 query (str, optional): The query used for reranking. Defaults to "".
177
178 Returns:
179 Union[str, List[str]]: The list of references or an error message if an exception occurs.
180 """
181 if relative_file_path is None:
182 return "Please specify the relative file path"
183 # if "/" not in relative_file_path:
184 # return "Invalid relative file path, please check the path again"
185
186 abs_path = os.path.join(self.path, relative_file_path)
187
188 is_dir = os.path.isdir(abs_path)
189 if is_dir:
190 return "The relative path is a folder, please specify the file path instead. Consider using get_tree_structure to find the file name then use this tool one file path at a time"
191
192 file_exists = os.path.exists(abs_path)
193 if not file_exists:
194 return "The file is not found, please check the path again. If you want to find the file, consider using get_tree_structure to find the file name then use this tool one file path at a time or recall your memory."
195
196 results = self.lsptoolkit.get_references(word, relative_file_path, line, verbose=True)
197
198 return results[:num_results]
199
200class GetAllSymbolsArgs(BaseModel):
201 path_to_file: str = Field(..., description="The path of the python file we want extract all symbols from.")

Callers

nothing calls this directly

Calls 1

get_referencesMethod · 0.80

Tested by

no test coverage detected