antgroup / antgroup/YASA-Engine
[OSS26] 按方法名读取方法源码 read_method_source_by_method_name
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 323
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
接口介绍
给定方法的全限定名(可选形参类型用于重载消歧),精准返回该方法的源码片段(可选携带 Javadoc 与注解),不带文件其他部分;有重载且未消歧时返回所有候选。
工具名
read_method_source_by_method_name
背景与目标
文件级读取(read_file_by_path)是文件级粒度,LLM Agent 拿到上百行整文件后还要自己定位方法,token 开销大。本工具按"方法"为单位返回源码,是程序分析的最小颗粒上下文。
输入参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
method_full_name |
string | 是 | 方法全限定名,如 com.example.UserController.getUser |
parameter_types |
string[] | 否 | 形参类型列表用于重载消歧;不填时:有重载则报错并返回所有候选 |
repository_path |
string | 是 | 仓库本地绝对路径 |
include_javadoc |
bool | 否 | 默认 true,是否带方法上方的 Javadoc 注释 |
include_annotations |
bool | 否 | 默认 true,是否带方法上的注解 |
输出结构
{
"method_full_name": "com.example.UserController.getUser",
"method_signature": "getUser(HttpServletRequest, String): ResponseEntity<User>",
"file_path": "src/main/java/com/example/UserController.java",
"start_line": 87,
"end_line": 105,
"containing_class": "com.example.UserController",
"source": "@GetMapping(\"/users/{id}\")\npublic ResponseEntity<User> getUser(HttpServletRequest req, @PathVariable String id) {\n ...\n}",
"javadoc": "/** Get a user by id */"
}
重载未消歧时:
{
"method_full_name": "com.example.UserController.getUser",
"found": false,
"ambiguous": true,
"candidates": [
"getUser(HttpServletRequest, String): ResponseEntity<User>",
"getUser(String): User"
]
}
验收标准
- 正确返回方法的完整源码,包括嵌套 lambda/匿名类
- 重载方法在不带
parameter_types时返回 ambiguous + 候选 - 注解、Javadoc 控制开关生效
- 单元测试覆盖:重载、嵌套类方法、构造器、静态初始化块、抽象方法只声明
- 中等仓库响应 < 3s
预估工作量
3-4 人日
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the existing read_file_by_path implementation and the UAST method-resolution entry points. Add coverage for overloads, nested classes, constructors, static initialization blocks, abstract declarations, nested lambdas or anonymous classes, and Javadoc or annotation switches. Done means the specified response shapes are returned and medium repositories respond within 3 seconds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100