refactor(impact): CodeParser 多语言就绪——语言适配器注册表(仅 Java,行为不变)
- BaseLanguageParser 抽象基类 + JavaLanguageParser(迁移全部 Java 正则,输出逐字节一致) - LANGUAGE_PARSERS 注册表 + register_language_parser 扩展点(新增语言=加适配器类并注册,下游零改动) - CodeParser 分发器:parse(root, language=None) 自动按扩展名探测 / 显式语言覆盖 / 多语言合并(language 逗号连接)/ 无源码或语言不支持抛 CodeParseError - source_aggregator 新增 existing_system_language 透传;config.py 探测扩展名补 .py/.ts/.go/.cs - 删除自动探测下不可达死分支;全量 362 passed / 99.28%(基线 351/99.27%) - 门禁复跑 PASS:summary 与 MVP 基线一致(16/5/8/3/50/0),概要设计书 13 章
This commit is contained in:
@@ -199,3 +199,31 @@ def test_parse_existing_system_path_without_java_raises(tmp_path):
|
||||
empty.mkdir()
|
||||
with pytest.raises(CodeParseError):
|
||||
SourceParser().parse(requirement_paths=[xlsx], existing_system_path=empty)
|
||||
|
||||
|
||||
# ---------- 多语言预备重构:existing_system_language 透传 ----------
|
||||
|
||||
def test_parse_existing_system_language_explicit(tmp_path):
|
||||
xlsx = _xlsx(tmp_path)
|
||||
existing = _java_project(tmp_path)
|
||||
|
||||
result = SourceParser().parse(
|
||||
requirement_paths=[xlsx],
|
||||
existing_system_path=existing,
|
||||
existing_system_language="java",
|
||||
)
|
||||
|
||||
assert result.existing_system is not None
|
||||
assert {c.class_name for c in result.existing_system.controller_layer} == {"OrderController"}
|
||||
|
||||
|
||||
def test_parse_existing_system_language_unsupported_raises(tmp_path):
|
||||
xlsx = _xlsx(tmp_path)
|
||||
existing = _java_project(tmp_path)
|
||||
|
||||
with pytest.raises(CodeParseError):
|
||||
SourceParser().parse(
|
||||
requirement_paths=[xlsx],
|
||||
existing_system_path=existing,
|
||||
existing_system_language="kotlin",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user