antgroup / antgroup/YASA-Engine
[OSS26] 获取类型继承层级 get_type_hierarchy_by_class_name
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 323
- Forks
- 40
- PR merge metrics
- No merged PRs in 30d
Description
接口介绍
给定一个类或接口的全限定名,返回其完整继承/实现层级树 — 向上链(父类、父接口),向下链(子类、所有实现),含每一跳的关系类型(extends / implements)与类型种类(class / interface / abstract_class)。
工具名
get_type_hierarchy_by_class_name
背景与目标
类型层级是程序分析中很多推理的基础:
- 多态分析:看到
validator.validate(...)想知道validator可能是哪些子类 - 安全审计:发现一个
BaseFilter,需要看它的所有子 Filter 是否都正确处理了输入 - 重构分析:删一个父类前看影响面
也是调用图分析(callees / 上游链路)的多态展开依赖。
输入参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
class_full_name |
string | 是 | 类/接口全限定名 |
repository_path |
string | 是 | 仓库本地绝对路径 |
direction |
enum(up, down, both) | 否 | 默认 both。up=父类/接口链,down=子类/实现链 |
max_depth |
int | 否 | 默认 -1(不限) |
include_jdk_types |
bool | 否 | 默认 false。是否在向上链里把 java.lang.Object 等标准库类型也列上 |
输出结构
{
"root": "com.example.RequestValidator",
"kind": "interface",
"direction": "both",
"ancestors": [
{
"full_name": "com.example.Validator",
"kind": "interface",
"depth": 1,
"relation": "extends"
}
],
"descendants": [
{
"full_name": "com.example.impl.JsonRequestValidator",
"kind": "class",
"depth": 1,
"relation": "implements",
"is_abstract": false
},
{
"full_name": "com.example.impl.AbstractValidator",
"kind": "abstract_class",
"depth": 1,
"relation": "implements",
"is_abstract": true
},
{
"full_name": "com.example.impl.specialized.AbConcreteValidator",
"kind": "class",
"depth": 2,
"relation": "extends",
"parent_in_chain": "com.example.impl.AbstractValidator"
}
],
"total_ancestors": 1,
"total_descendants": 3
}
验收标准
- 正确处理多重接口实现(Java 类只能 extends 一个,但能 implements 多个)
- 正确处理接口继承接口(可能多个父接口)
- direction=up/down/both 三种模式输出对齐
- 检测循环继承(异常情况)并标记
- 单元测试覆盖:深层继承(>5 层)、多接口实现、抽象类、内部类层级
- 中等仓库响应 < 5s
- 索引可被调用图分析复用
预估工作量
7-10 人日
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
No implementation file or entry point is named. Start by locating the existing TypeScript analysis and indexing APIs and the unit-test layout relevant to the Java type hierarchy tool, then map the requested up/down/both outputs to those structures. Done means the listed inheritance cases, cycle handling, call-graph reuse, and medium-repository response target are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, typescript
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100