antgroup / antgroup/YASA-Engine

[OSS26] 按签名模式搜代码 search_code_by_signature_pattern

Open
#134 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

OSS26-Good First Issue
Dominant language
TypeScript
Stars
323
Forks
40
PR merge metrics
No merged PRs in 30d

Description

接口介绍

用正则模式匹配代码元素(方法/类/字段)的签名,例如"所有形参含 HttpServletRequest 的 public 方法"或"所有以 queryselectload 开头的方法",返回命中位置和签名片段。

工具名

search_code_by_signature_pattern

背景与目标

普通关键词搜只能匹配字符串本身,常被注释、字符串字面量、变量名干扰。本工具收紧到"代码元素签名级别":

  • 找所有形如 public ResponseEntity<*> *(...HttpServletRequest...) 的 Controller 方法
  • 找所有继承 Abstract*Filter 的类
  • 找所有以 queryselectload 开头的方法

适合作为入门级"结构化搜索"工具。

输入参数
参数 类型 必填 说明
pattern string 正则模式,如 public\s+\w+\s+\w+\s*\([^)]*HttpServletRequest
element_kind enum(method, class, field, any) 匹配的代码元素类型
repository_path string 仓库本地绝对路径
language string 默认 java
max_results int 默认 100
输出结构
{
  "pattern": "public\\s+\\w+\\s+\\w+\\s*\\([^)]*HttpServletRequest",
  "element_kind": "method",
  "total_matches": 18,
  "results": [
    {
      "file_path": "src/main/java/com/example/UserController.java",
      "line_number": 87,
      "matched_signature": "public ResponseEntity<User> getUser(HttpServletRequest req, @PathVariable String id)",
      "containing_class": "com.example.UserController"
    }
  ]
}
验收标准
  • 在 Java 项目上能匹配方法、类、字段三种签名
  • 跳过注释、字符串字面量内的伪命中(基础版可不做,加分项)
  • 单元测试覆盖:方法/类/字段三种 element_kind、找不到、大量结果截断
  • 中等仓库响应 < 3s
预估工作量

1-2 人日(line-based 实现可控)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing tool entry point and its unit-test conventions in the repository, then trace how Java code elements are represented and searched. Implement the pattern search for method, class, and field signatures, and add tests for each kind, no matches, and max-results truncation; done means the acceptance cases pass within the stated response target.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
Domain
devtools
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.