scancscode 1.0.31 → 1.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.trae/specs/fix-doc-comment-boundary/checklist.md +7 -0
- package/.trae/specs/fix-doc-comment-boundary/spec.md +52 -0
- package/.trae/specs/fix-doc-comment-boundary/tasks.md +34 -0
- package/.trae/specs/fix-interpolated-string-nested-literals/checklist.md +7 -0
- package/.trae/specs/fix-interpolated-string-nested-literals/spec.md +55 -0
- package/.trae/specs/fix-interpolated-string-nested-literals/tasks.md +25 -0
- package/.trae/specs/fix-remaining-interpolated-string-index/checklist.md +9 -0
- package/.trae/specs/fix-remaining-interpolated-string-index/spec.md +59 -0
- package/.trae/specs/fix-remaining-interpolated-string-index/tasks.md +41 -0
- package/.trae/specs/fix-return-interpolated-string/checklist.md +8 -0
- package/.trae/specs/fix-return-interpolated-string/spec.md +60 -0
- package/.trae/specs/fix-return-interpolated-string/tasks.md +39 -0
- package/.trae/specs/handle-anonymous-function-strings/checklist.md +11 -0
- package/.trae/specs/handle-anonymous-function-strings/spec.md +137 -0
- package/.trae/specs/handle-anonymous-function-strings/tasks.md +65 -0
- package/.trae/specs/handle-interpolated-string-double-braces/checklist.md +9 -0
- package/.trae/specs/handle-interpolated-string-double-braces/spec.md +61 -0
- package/.trae/specs/handle-interpolated-string-double-braces/tasks.md +41 -0
- package/.trae/specs/handle-return-statement/checklist.md +11 -0
- package/.trae/specs/handle-return-statement/spec.md +76 -0
- package/.trae/specs/handle-return-statement/tasks.md +44 -0
- package/.trae/specs/handle-special-string-characters/checklist.md +13 -0
- package/.trae/specs/handle-special-string-characters/spec.md +94 -0
- package/.trae/specs/handle-special-string-characters/tasks.md +74 -0
- package/.trae/specs/unify-return-statement-string-extraction/checklist.md +10 -0
- package/.trae/specs/unify-return-statement-string-extraction/spec.md +70 -0
- package/.trae/specs/unify-return-statement-string-extraction/tasks.md +54 -0
- package/bin/scanliterals.js +3 -3
- package/bin/slimlangs.js +3 -3
- package/dist/debug-arg.js +30 -0
- package/dist/debug-args.js +34 -0
- package/dist/debug-comment-5.js +25 -0
- package/dist/debug-comment-strings.js +24 -0
- package/dist/debug-full.js +14 -0
- package/dist/debug-template-issue.js +33 -0
- package/dist/debug-test-5.js +23 -0
- package/dist/debug-test.js +21 -0
- package/dist/debug.js +15 -0
- package/dist/simple-debug.js +27 -0
- package/dist/simple-test.js +61 -0
- package/dist/src/CSharpStringExtractor.js +1791 -358
- package/dist/src/CmdExecutor.js +6 -8
- package/dist/temp-original-source.js +1 -0
- package/dist/test/CSharpStringExtractor.test.js +1587 -207
- package/dist/test-logic.js +79 -0
- package/dist/test-regex.js +13 -0
- package/docs/CSharpStringExtractor/344/273/243/347/240/201/347/224/237/346/210/220/346/217/220/347/244/272/350/257/215.txt +73 -0
- package/jest.config.js +9 -9
- package/package.json +1 -1
- package/src/CSCodeScanner.ts +305 -305
- package/src/CSVUtils.ts +181 -181
- package/src/CSharpStringExtractor.ts +2058 -479
- package/src/CmdExecutor.ts +107 -106
- package/src/LiteralCollector.ts +143 -143
- package/src/RunConvert.ts +3 -3
- package/src/RunSlimLangs.ts +3 -3
- package/src/TableScanner.ts +92 -92
- package/test/CSharpStringExtractor.test.ts +1673 -208
- package/test/KeeperDialog.cs +114 -0
- package/test/TestSpecialString.cs +24 -0
- package/tsconfig.json +109 -109
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
|
|
2
|
+
# 处理内插字符串中的双花括号 - Product Requirement Document
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
- **Summary**: 修复 CSharpStringExtractor 工具中内插字符串($"")处理双花括号 `{{` 和 `}}` 的逻辑,确保这些转义字符被正确地保持原样,而不是被错误地识别为多个独立的内插表达式
|
|
6
|
+
- **Purpose**: 解决内插字符串中包含 `{{` 和 `}}` 时,它们被错误地识别为多个独立内插表达式的问题,确保正确的转义处理
|
|
7
|
+
- **Target Users**: 使用 CSharpStringExtractor 工具来扫描和提取 C# 代码中字符串字面量的开发者
|
|
8
|
+
|
|
9
|
+
## Goals
|
|
10
|
+
- 修复 `should handle special characters in string expression 4` 测试用例的失败问题
|
|
11
|
+
- 确保内插字符串中的 `{{` 和 `}}` 被正确识别为转义字符,保持原样转换到 Tr.Format 中
|
|
12
|
+
- 确保单个 `{xxx}` 被正确识别为内插表达式并替换为 `{0}`, `{1}` 等
|
|
13
|
+
- 保持所有现有测试用例的通过状态
|
|
14
|
+
|
|
15
|
+
## Non-Goals (Out of Scope)
|
|
16
|
+
- 改变工具的整体架构或 API 接口
|
|
17
|
+
- 添加超出内插字符串处理之外的新功能
|
|
18
|
+
|
|
19
|
+
## Background & Context
|
|
20
|
+
- 目前 `processStringTemplates` 方法处理内插字符串时,没有正确处理 `{{` 和 `}}` 的转义情况
|
|
21
|
+
- 在内插字符串中,`{{` 表示单个 `{`,`}}` 表示单个 `}`,不应该被当作内插表达式处理
|
|
22
|
+
- 测试用例 `should handle special characters in string expression 4` 测试这个功能,但目前失败了
|
|
23
|
+
|
|
24
|
+
## Functional Requirements
|
|
25
|
+
- **FR-1**: 工具必须正确处理内插字符串中的 `{{` 转义序列,保持原样
|
|
26
|
+
- **FR-2**: 工具必须正确处理内插字符串中的 `}}` 转义序列,保持原样
|
|
27
|
+
- **FR-3**: 工具必须正确区分转义的 `{{`/`}}` 和单个 `{`/`}` 组成的内插表达式
|
|
28
|
+
- **FR-4**: 工具必须正确处理同时包含转义双花括号和普通内插表达式的情况
|
|
29
|
+
|
|
30
|
+
## Non-Functional Requirements
|
|
31
|
+
- **NFR-1**: 所有 79 个现有测试用例必须继续通过
|
|
32
|
+
- **NFR-2**: 修复不能降低工具的性能
|
|
33
|
+
- **NFR-3**: 代码必须遵循 TypeScript 语言规范
|
|
34
|
+
|
|
35
|
+
## Constraints
|
|
36
|
+
- **Technical**: 必须使用 TypeScript 编写,保持现有代码风格和架构
|
|
37
|
+
- **Dependencies**: 不添加任何新的依赖库
|
|
38
|
+
|
|
39
|
+
## Assumptions
|
|
40
|
+
- C# 内插字符串语法规则:`{{` → `{`, `}}` → `}`, `{expr}` → 内插表达式
|
|
41
|
+
- 用户期望的行为符合 C# 语言规范
|
|
42
|
+
|
|
43
|
+
## Acceptance Criteria
|
|
44
|
+
|
|
45
|
+
### AC-1: 内插字符串双花括号测试通过
|
|
46
|
+
- **Given**: 包含 `{{` 和 `}}` 的内插字符串测试用例
|
|
47
|
+
- **When**: 运行 `should handle special characters in string expression 4` 测试
|
|
48
|
+
- **Then**: 该测试用例应该成功通过,不出现任何错误
|
|
49
|
+
- **Verification**: `programmatic`
|
|
50
|
+
- **Notes**: 确保 `{{` 和 `}}` 在转换后的字符串中保持原样
|
|
51
|
+
|
|
52
|
+
### AC-2: 所有现有测试继续通过
|
|
53
|
+
- **Given**: 完整的测试套件
|
|
54
|
+
- **When**: 运行所有测试用例
|
|
55
|
+
- **Then**: 所有 79 个现有测试用例应该继续通过
|
|
56
|
+
- **Verification**: `programmatic`
|
|
57
|
+
- **Notes**: 保持向后兼容性
|
|
58
|
+
|
|
59
|
+
## Open Questions
|
|
60
|
+
- 无
|
|
61
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
# 处理内插字符串中的双花括号 - The Implementation Plan (Decomposed and Prioritized Task List)
|
|
3
|
+
|
|
4
|
+
## [x] 任务 1: 分析当前 processStringTemplates 方法的问题
|
|
5
|
+
- **Priority**: P0
|
|
6
|
+
- **Depends On**: None
|
|
7
|
+
- **Description**:
|
|
8
|
+
- 查看 `processStringTemplates` 方法的实现,分析为什么 `{{` 和 `}}` 被错误处理
|
|
9
|
+
- 了解当前正则表达式 `/\{([^}]*?)\}/g` 如何匹配内插表达式
|
|
10
|
+
- 理解为什么 `{{` 被当作两个独立的 `{` 处理
|
|
11
|
+
- **Acceptance Criteria Addressed**: [AC-1]
|
|
12
|
+
- **Test Requirements**:
|
|
13
|
+
- `programmatic` TR-1.1: 定位双花括号被错误处理的具体代码位置 ✓
|
|
14
|
+
- `human-judgement` TR-1.2: 理解当前逻辑中的问题所在 ✓
|
|
15
|
+
- **Notes**: 重点关注内插字符串模板匹配的正则表达式或手动解析逻辑
|
|
16
|
+
|
|
17
|
+
## [x] 任务 2: 修复 processStringTemplates 方法以正确处理双花括号
|
|
18
|
+
- **Priority**: P0
|
|
19
|
+
- **Depends On**: 任务 1
|
|
20
|
+
- **Description**:
|
|
21
|
+
- 重写或修改 `processStringTemplates` 方法中的内插表达式匹配逻辑
|
|
22
|
+
- 确保首先检查 `{{` 和 `}}` 转义序列并保持原样
|
|
23
|
+
- 然后再处理单个 `{expr}` 内插表达式
|
|
24
|
+
- **Acceptance Criteria Addressed**: [AC-1, AC-2]
|
|
25
|
+
- **Test Requirements**:
|
|
26
|
+
- `programmatic` TR-2.1: 修复后 `should handle special characters in string expression 4` 测试用例必须通过 ✓
|
|
27
|
+
- `programmatic` TR-2.2: 所有其他测试用例继续通过,无回归 ✓
|
|
28
|
+
- **Notes**: 确保修改不会影响普通内插表达式的处理
|
|
29
|
+
- **Modifications**: 重写了 `processStringTemplates` 方法(src/CSharpStringExtractor.ts:972-1055),采用手动解析方式,优先处理 {{ 和 }} 转义序列
|
|
30
|
+
|
|
31
|
+
## [x] 任务 3: 运行所有测试确保没有回归
|
|
32
|
+
- **Priority**: P0
|
|
33
|
+
- **Depends On**: 任务 2
|
|
34
|
+
- **Description**:
|
|
35
|
+
- 运行完整的测试套件,确保所有测试用例都能通过
|
|
36
|
+
- 检查是否有任何测试出现回归
|
|
37
|
+
- **Acceptance Criteria Addressed**: [AC-2]
|
|
38
|
+
- **Test Requirements**:
|
|
39
|
+
- `programmatic` TR-3.1: 运行 `npm test` 命令,所有 79 个测试用例必须通过 ✓
|
|
40
|
+
- **Notes**: 确保修复不会破坏任何现有功能
|
|
41
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# 处理 C# Return 语句 - Verification Checklist
|
|
2
|
+
|
|
3
|
+
- [x] isStatementToProcess 能正确识别包含字符串的 return 语句
|
|
4
|
+
- [x] isStatementToProcess 不会错误地识别不包含字符串的 return 语句
|
|
5
|
+
- [x] extractValueExpression 能正确从 return 语句中提取字符串表达式
|
|
6
|
+
- [x] 提取的字符串表达式不包含 "return" 关键字
|
|
7
|
+
- [x] valueExpressionIndex 正确指向字符串的起始位置
|
|
8
|
+
- [x] "should handle return statement" 测试通过
|
|
9
|
+
- [x] 所有现有测试用例都通过
|
|
10
|
+
- [x] 代码风格与项目保持一致
|
|
11
|
+
- [x] 没有引入新的语法错误或类型错误
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# 处理 C# Return 语句 - Product Requirement Document
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
- **Summary**: 修复 CSharpStringExtractor 无法处理 C# `return` 语句中字符串字面量的问题,确保 return 语句中的字符串表达式能够被正确提取
|
|
5
|
+
- **Purpose**: 解决 `return "参数错误";` 等语句中字符串字面量无法被提取和处理的问题
|
|
6
|
+
- **Target Users**: 使用 CSharpStringExtractor 进行 C# 代码字符串字面量提取和国际化处理的开发者
|
|
7
|
+
|
|
8
|
+
## Goals
|
|
9
|
+
- 修改 `isStatementToProcess` 函数,允许处理以 "return " 开头的语句
|
|
10
|
+
- 修改 `extractValueExpression` 函数,正确提取 return 语句中的字符串值表达式
|
|
11
|
+
- 确保提取的字符串表达式不包含 "return" 关键字本身
|
|
12
|
+
- 保持现有功能不被破坏
|
|
13
|
+
|
|
14
|
+
## Non-Goals (Out of Scope)
|
|
15
|
+
- 不修改其他语句类型的处理逻辑
|
|
16
|
+
- 不添加额外的新功能,只修复 return 语句的处理问题
|
|
17
|
+
- 不重构整个代码库
|
|
18
|
+
|
|
19
|
+
## Background & Context
|
|
20
|
+
- CSharpStringExtractor 是一个用于提取 C# 代码中字符串字面量的工具
|
|
21
|
+
- 当前版本在处理 `return "参数错误";` 语句时无法正确提取字符串
|
|
22
|
+
- 测试用例 `should handle return statement` 专门测试这个功能
|
|
23
|
+
- 需要保持与项目现有架构和编码规范一致
|
|
24
|
+
|
|
25
|
+
## Functional Requirements
|
|
26
|
+
- **FR-1**: `isStatementToProcess` 函数应能识别并允许处理以 "return " 开头的语句
|
|
27
|
+
- **FR-2**: `extractValueExpression` 函数应能从 return 语句中正确提取字符串值表达式
|
|
28
|
+
- **FR-3**: 提取的字符串表达式不应包含 "return" 关键字
|
|
29
|
+
- **FR-4**: return 语句的处理应与其他语句类型保持一致的行为
|
|
30
|
+
|
|
31
|
+
## Non-Functional Requirements
|
|
32
|
+
- **NFR-1**: 代码修改应保持可维护性和性能
|
|
33
|
+
- **NFR-2**: 修改不应影响现有功能
|
|
34
|
+
- **NFR-3**: 代码应与项目现有编码风格保持一致
|
|
35
|
+
|
|
36
|
+
## Constraints
|
|
37
|
+
- **Technical**: 使用 TypeScript,遵循现有代码架构
|
|
38
|
+
- **Business**: 需要通过现有所有测试用例,特别是 "should handle return statement" 测试
|
|
39
|
+
- **Dependencies**: 依赖现有的 CSharpStringExtractor.ts 代码结构
|
|
40
|
+
|
|
41
|
+
## Assumptions
|
|
42
|
+
- return 语句的结构是 "return " + 字符串表达式 + ";"
|
|
43
|
+
- return 语句中的字符串表达式不包含复杂的条件表达式(测试用例只覆盖简单情况)
|
|
44
|
+
- 现有代码结构是稳定的,可以在其基础上进行修改
|
|
45
|
+
|
|
46
|
+
## Acceptance Criteria
|
|
47
|
+
|
|
48
|
+
### AC-1: isStatementToProcess 能识别 return 语句
|
|
49
|
+
- **Given**: 一个包含 "return " 开头的语句字符串
|
|
50
|
+
- **When**: 调用 `isStatementToProcess` 函数检查该语句
|
|
51
|
+
- **Then**: 函数应返回 true,表明该语句需要处理
|
|
52
|
+
- **Verification**: `programmatic`
|
|
53
|
+
- **Notes**: 确保只识别 "return " 开头的语句,避免误识别其他以 "return" 开头的标识符
|
|
54
|
+
|
|
55
|
+
### AC-2: extractValueExpression 能正确提取 return 语句的字符串
|
|
56
|
+
- **Given**: 一个完整的 return 语句,如 `return "参数错误";`
|
|
57
|
+
- **When**: 调用 `extractValueExpression` 函数处理该语句
|
|
58
|
+
- **Then**: 函数应返回字符串表达式 `"参数错误"`,不包含 "return" 关键字
|
|
59
|
+
- **Verification**: `programmatic`
|
|
60
|
+
- **Notes**: 同时确保 valueExpressionIndex 指向字符串的起始位置
|
|
61
|
+
|
|
62
|
+
### AC-3: 完整的 return 语句处理流程正确
|
|
63
|
+
- **Given**: 代码字符串 `return "参数错误";`
|
|
64
|
+
- **When**: 调用 `extractStrings` 函数处理该代码
|
|
65
|
+
- **Then**: 返回的 snippets 数组应包含一个 snippet,其 originalCode 为 `"参数错误"`,originalIndex 为字符串在原代码中的起始位置
|
|
66
|
+
- **Verification**: `programmatic`
|
|
67
|
+
- **Notes**: 这就是测试用例 "should handle return statement" 的要求
|
|
68
|
+
|
|
69
|
+
### AC-4: 现有功能不受影响
|
|
70
|
+
- **Given**: 修改后的代码库
|
|
71
|
+
- **When**: 运行所有现有测试用例
|
|
72
|
+
- **Then**: 所有测试用例都应通过
|
|
73
|
+
- **Verification**: `programmatic`
|
|
74
|
+
|
|
75
|
+
## Open Questions
|
|
76
|
+
- 是否需要处理更复杂的 return 语句,如 `return condition ? "a" : "b";`?(测试用例未覆盖此场景)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# 处理 C# Return 语句 - The Implementation Plan (Decomposed and Prioritized Task List)
|
|
2
|
+
|
|
3
|
+
## [x] Task 1: 修改 isStatementToProcess 函数支持 return 语句
|
|
4
|
+
- **Priority**: P0
|
|
5
|
+
- **Depends On**: None
|
|
6
|
+
- **Description**:
|
|
7
|
+
- 修改 `isStatementToProcess` 函数,允许处理以 "return " 开头的语句
|
|
8
|
+
- 当前 blockKeywords 数组中不包含 "return",但需要特别处理
|
|
9
|
+
- 实现方式:检查 trimmedStatement 是否以 "return " 开头,如果是,并且包含字符串字面量,则返回 true
|
|
10
|
+
- **Acceptance Criteria Addressed**: AC-1
|
|
11
|
+
- **Test Requirements**:
|
|
12
|
+
- `programmatic` TR-1.1: `isStatementToProcess('return "参数错误";')` 应返回 true
|
|
13
|
+
- `programmatic` TR-1.2: `isStatementToProcess('return 123;')` 不应返回 true(无字符串字面量)
|
|
14
|
+
- `programmatic` TR-1.3: 现有其他语句类型的处理不应受影响
|
|
15
|
+
- **Notes**: 确保不会影响 case/default 等现有特殊语句的处理
|
|
16
|
+
|
|
17
|
+
## [x] Task 2: 修改 extractValueExpression 函数提取 return 语句的字符串
|
|
18
|
+
- **Priority**: P0
|
|
19
|
+
- **Depends On**: Task 1
|
|
20
|
+
- **Description**:
|
|
21
|
+
- 在 `extractValueExpression` 函数中添加对 return 语句的处理逻辑
|
|
22
|
+
- 在 text assignment、assignment、stringFormat 等检查之前,先检查是否以 "return " 开头
|
|
23
|
+
- 如果是 return 语句,提取 "return " 之后的部分作为 valuePart,然后使用 extractValueUntilSemicolon 提取值
|
|
24
|
+
- 确保返回的 valueExpression 不包含 "return" 关键字
|
|
25
|
+
- 正确计算 valueExpressionIndex,指向字符串的起始位置
|
|
26
|
+
- **Acceptance Criteria Addressed**: AC-2
|
|
27
|
+
- **Test Requirements**:
|
|
28
|
+
- `programmatic` TR-2.1: `extractValueExpression('return "参数错误";', 0, 'return "参数错误";')` 的 valueExpression 应为 `"参数错误"`
|
|
29
|
+
- `programmatic` TR-2.2: valueExpressionIndex 应正确指向字符串的起始位置
|
|
30
|
+
- `programmatic` TR-2.3: 其他语句类型(assignment、text assignment、stringFormat)的处理不应受影响
|
|
31
|
+
- **Notes**: 参考现有 text assignment 和 assignment 的处理模式
|
|
32
|
+
|
|
33
|
+
## [x] Task 3: 运行完整测试套件验证修复
|
|
34
|
+
- **Priority**: P0
|
|
35
|
+
- **Depends On**: Task 2
|
|
36
|
+
- **Description**:
|
|
37
|
+
- 运行 "should handle return statement" 测试,确保它通过
|
|
38
|
+
- 运行所有现有测试用例,确保没有回归
|
|
39
|
+
- 如有问题,修复代码直到所有测试通过
|
|
40
|
+
- **Acceptance Criteria Addressed**: AC-3, AC-4
|
|
41
|
+
- **Test Requirements**:
|
|
42
|
+
- `programmatic` TR-3.1: "should handle return statement" 测试通过
|
|
43
|
+
- `programmatic` TR-3.2: 所有现有测试用例都通过
|
|
44
|
+
- **Notes**: 先单独运行目标测试,再运行完整测试套件
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# C#字符串特殊字符处理 - Verification Checklist
|
|
2
|
+
|
|
3
|
+
- [ ] Checkpoint 1: 分析问题并定位到具体代码位置
|
|
4
|
+
- [ ] Checkpoint 2: 修改后的代码能够正确识别包含特殊字符的字符串边界
|
|
5
|
+
- [ ] Checkpoint 3: 字符串内部的`_+|:"<>?`等特殊字符不会被错误处理
|
|
6
|
+
- [ ] Checkpoint 4: 测试用例`snippets[0]`(对象初始化器字符串)正确处理
|
|
7
|
+
- [ ] Checkpoint 5: 测试用例`snippets[1]`(变量赋值字符串)正确处理
|
|
8
|
+
- [ ] Checkpoint 6: 测试用例`snippets[2]`(插值字符串)正确处理
|
|
9
|
+
- [ ] Checkpoint 7: 测试用例`snippets[3]`(函数调用参数字符串)正确处理
|
|
10
|
+
- [ ] Checkpoint 8: 测试用例`snippets[4]`(返回语句字符串)正确处理
|
|
11
|
+
- [ ] Checkpoint 9: 测试用例`snippets[5]`和`snippets[6]`(成员变量字符串)正确处理
|
|
12
|
+
- [ ] Checkpoint 10: 完整测试用例`should handle special characters in string expression 2`通过
|
|
13
|
+
- [ ] Checkpoint 11: 所有其他未被注释的测试都通过
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# C#字符串特殊字符处理 - Product Requirement Document
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
- **Summary**: 修复CSharpStringExtractor处理C#字符串中包含特殊字符时的边界识别和捕获问题
|
|
5
|
+
- **Purpose**: 解决工具在处理包含特殊字符(如`_+|:"<>?`)的C#字符串时错误地添加`.TR()`调用的问题,确保字符串边界识别的准确性
|
|
6
|
+
- **Target Users**: 使用UnityI18N工具扫描和转换C#代码的开发人员
|
|
7
|
+
|
|
8
|
+
## Goals
|
|
9
|
+
- 修复C#字符串中特殊字符导致错误添加`.TR()`的bug
|
|
10
|
+
- 确保所有类型的C#字符串(普通字符串、插值字符串等)中的特殊字符都能被正确处理
|
|
11
|
+
- 通过现有的测试用例 `should handle special characters in string expression 2`
|
|
12
|
+
|
|
13
|
+
## Non-Goals (Out of Scope)
|
|
14
|
+
- 不修改其他不相关的测试用例
|
|
15
|
+
- 不改变工具的整体架构
|
|
16
|
+
- 不添加新的转换功能
|
|
17
|
+
|
|
18
|
+
## Background & Context
|
|
19
|
+
- 当前工具在处理包含特殊字符(特别是`_+`模式)的C#字符串时,会错误地在字符串内部添加`.TR()`调用
|
|
20
|
+
- 测试用例中展示了在多种C#语句(对象初始化器、变量赋值、函数调用、返回语句、成员变量等)中的字符串都需要正确处理
|
|
21
|
+
- 问题可能出在字符串边界识别逻辑上,特殊字符被错误地识别为字符串结束或其他语法结构
|
|
22
|
+
|
|
23
|
+
## Functional Requirements
|
|
24
|
+
- **FR-1**: 正确识别包含所有特殊字符的C#字符串边界
|
|
25
|
+
- **FR-2**: 普通字符串(双引号包裹)中的所有特殊字符都能被正确保留
|
|
26
|
+
- **FR-3**: 插值字符串(`$"`)中的所有特殊字符都能被正确处理
|
|
27
|
+
- **FR-4**: 不应该在字符串内部错误地添加`.TR()`调用
|
|
28
|
+
|
|
29
|
+
## Non-Functional Requirements
|
|
30
|
+
- **NFR-1**: 所有现有测试用例继续通过(除被注释掉的)
|
|
31
|
+
- **NFR-2**: 保持工具的性能,不显著增加处理时间
|
|
32
|
+
|
|
33
|
+
## Constraints
|
|
34
|
+
- **Technical**: 必须使用TypeScript,保持与现有代码库风格一致
|
|
35
|
+
- **Dependencies**: 仅修改`CSharpStringExtractor.ts`文件
|
|
36
|
+
- **Business**: 必须在不破坏现有功能的情况下修复问题
|
|
37
|
+
|
|
38
|
+
## Assumptions
|
|
39
|
+
- 测试用例中的期望输出是正确的行为
|
|
40
|
+
- 问题仅出在字符串边界识别和处理逻辑中
|
|
41
|
+
- 不需要修改测试用例本身
|
|
42
|
+
|
|
43
|
+
## Acceptance Criteria
|
|
44
|
+
|
|
45
|
+
### AC-1: 正确处理普通字符串中的特殊字符
|
|
46
|
+
- **Given**: C#代码中包含带有各种特殊字符的普通字符串(如`_+|:"<>?`)
|
|
47
|
+
- **When**: CSharpStringExtractor处理该代码
|
|
48
|
+
- **Then**: 字符串被完整识别,不添加多余的`.TR()`调用
|
|
49
|
+
- **Verification**: `programmatic`
|
|
50
|
+
- **Notes**: 通过测试用例验证
|
|
51
|
+
|
|
52
|
+
### AC-2: 正确处理对象初始化器中的字符串
|
|
53
|
+
- **Given**: C#对象初始化器中的属性赋值包含特殊字符的字符串
|
|
54
|
+
- **When**: CSharpStringExtractor处理该代码
|
|
55
|
+
- **Then**: 字符串被正确提取和处理
|
|
56
|
+
- **Verification**: `programmatic`
|
|
57
|
+
- **Notes**: 测试用例中的第1个和第6、7个snippet
|
|
58
|
+
|
|
59
|
+
### AC-3: 正确处理变量赋值中的字符串
|
|
60
|
+
- **Given**: C#变量赋值语句包含特殊字符的字符串
|
|
61
|
+
- **When**: CSharpStringExtractor处理该代码
|
|
62
|
+
- **Then**: 字符串被正确处理
|
|
63
|
+
- **Verification**: `programmatic`
|
|
64
|
+
- **Notes**: 测试用例中的第2个snippet
|
|
65
|
+
|
|
66
|
+
### AC-4: 正确处理插值字符串
|
|
67
|
+
- **Given**: C#插值字符串(`$"`)包含变量和特殊字符
|
|
68
|
+
- **When**: CSharpStringExtractor处理该代码
|
|
69
|
+
- **Then**: 插值字符串被正确转换为Tr.Format
|
|
70
|
+
- **Verification**: `programmatic`
|
|
71
|
+
- **Notes**: 测试用例中的第3个snippet
|
|
72
|
+
|
|
73
|
+
### AC-5: 正确处理函数调用中的字符串
|
|
74
|
+
- **Given**: C#函数调用参数包含特殊字符的字符串
|
|
75
|
+
- **When**: CSharpStringExtractor处理该代码
|
|
76
|
+
- **Then**: 字符串被正确处理
|
|
77
|
+
- **Verification**: `programmatic`
|
|
78
|
+
- **Notes**: 测试用例中的第4个snippet
|
|
79
|
+
|
|
80
|
+
### AC-6: 正确处理返回语句中的字符串
|
|
81
|
+
- **Given**: C#返回语句包含特殊字符的字符串
|
|
82
|
+
- **When**: CSharpStringExtractor处理该代码
|
|
83
|
+
- **Then**: 字符串被正确处理
|
|
84
|
+
- **Verification**: `programmatic`
|
|
85
|
+
- **Notes**: 测试用例中的第5个snippet
|
|
86
|
+
|
|
87
|
+
### AC-7: 测试通过
|
|
88
|
+
- **Given**: 运行指定的测试用例
|
|
89
|
+
- **When**: 执行 `npx jest test/CSharpStringExtractor.test.ts -t "should handle special characters in string expression 2"`
|
|
90
|
+
- **Then**: 测试完全通过
|
|
91
|
+
- **Verification**: `programmatic`
|
|
92
|
+
|
|
93
|
+
## Open Questions
|
|
94
|
+
- 无
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# C#字符串特殊字符处理 - The Implementation Plan (Decomposed and Prioritized Task List)
|
|
2
|
+
|
|
3
|
+
## \[ ] Task 1: 分析问题并定位bug
|
|
4
|
+
|
|
5
|
+
* **Priority**: P0
|
|
6
|
+
|
|
7
|
+
* **Depends On**: None
|
|
8
|
+
|
|
9
|
+
* **Description**:
|
|
10
|
+
|
|
11
|
+
* 分析当前测试失败的原因,确认问题出现在哪个函数
|
|
12
|
+
|
|
13
|
+
* 查看`processStringConcatenation`和相关函数的实现,找出为什么`_+`被错误处理
|
|
14
|
+
|
|
15
|
+
* 确定需要修复的具体代码位置
|
|
16
|
+
|
|
17
|
+
* **Acceptance Criteria Addressed**: \[AC-1, AC-2, AC-3, AC-4, AC-5, AC-6]
|
|
18
|
+
|
|
19
|
+
* **Test Requirements**:
|
|
20
|
+
|
|
21
|
+
* `programmatic` TR-1.1: 确认测试失败的具体原因和位置
|
|
22
|
+
|
|
23
|
+
* **Notes**: 通过调试和代码审查确定问题根源
|
|
24
|
+
|
|
25
|
+
## \[ ] Task 2: 修复字符串处理逻辑中的bug
|
|
26
|
+
|
|
27
|
+
* **Priority**: P0
|
|
28
|
+
|
|
29
|
+
* **Depends On**: \[Task 1]
|
|
30
|
+
|
|
31
|
+
* **Description**:
|
|
32
|
+
|
|
33
|
+
* 修改`processStringConcatenation`或相关函数,确保在处理字符串时不会错误地在字符串内部添加`.TR()`
|
|
34
|
+
|
|
35
|
+
* 确保所有特殊字符都能被正确处理,特别是`_+|:"<>?`等组合
|
|
36
|
+
|
|
37
|
+
* 修改涉及字符串边界识别和`.TR()`添加逻辑的函数
|
|
38
|
+
|
|
39
|
+
* **Acceptance Criteria Addressed**: \[AC-1, AC-2, AC-3, AC-4, AC-5, AC-6]
|
|
40
|
+
|
|
41
|
+
* **Test Requirements**:
|
|
42
|
+
|
|
43
|
+
* `programmatic` TR-2.1: 修复后的代码能够正确识别字符串边界
|
|
44
|
+
|
|
45
|
+
* `programmatic` TR-2.2: 字符串内部的特殊字符不会被错误处理
|
|
46
|
+
|
|
47
|
+
* **Notes**: 只修改`CSharpStringExtractor.ts`,保持现有代码结构
|
|
48
|
+
|
|
49
|
+
## \[ ] Task 3: 运行测试并验证修复
|
|
50
|
+
|
|
51
|
+
* **Priority**: P0
|
|
52
|
+
|
|
53
|
+
* **Depends On**: \[Task 2]
|
|
54
|
+
|
|
55
|
+
* **Description**:
|
|
56
|
+
|
|
57
|
+
* 编译TypeScript代码
|
|
58
|
+
|
|
59
|
+
* 运行指定的测试用例`should handle special characters in string expression 2`
|
|
60
|
+
|
|
61
|
+
* 确保测试完全通过
|
|
62
|
+
|
|
63
|
+
* 运行所有其他测试,确保没有破坏现有功能
|
|
64
|
+
|
|
65
|
+
* **Acceptance Criteria Addressed**: \[AC-7]
|
|
66
|
+
|
|
67
|
+
* **Test Requirements**:
|
|
68
|
+
|
|
69
|
+
* `programmatic` TR-3.1: 测试`should handle special characters in string expression 2`通过
|
|
70
|
+
|
|
71
|
+
* `programmatic` TR-3.2: 所有未被注释的测试都通过
|
|
72
|
+
|
|
73
|
+
* **Notes**: 如果有其他测试失败,需要分析是否与此次修改相关
|
|
74
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
# 统一匹配 return 语句中的字符串表达式 - Verification Checklist
|
|
3
|
+
|
|
4
|
+
- [x] `should handle special characters in string expression of return sentence` 测试用例成功通过
|
|
5
|
+
- [x] 所有 75+ 个现有测试用例继续通过,无回归问题 (实际 78 个测试全部通过)
|
|
6
|
+
- [x] 代码严格符合 TypeScript 语言语法,不使用保留关键字作为变量名
|
|
7
|
+
- [x] return 语句能够被正确识别和处理
|
|
8
|
+
- [x] 包含特殊字符的字符串在 return 语句中能够被正确提取
|
|
9
|
+
- [x] 临时调试文件已清理,代码仓库保持整洁
|
|
10
|
+
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
|
|
2
|
+
# 统一匹配 return 语句中的字符串表达式 - Product Requirement Document
|
|
3
|
+
|
|
4
|
+
## Overview
|
|
5
|
+
- **Summary**: 修复 CSharpStringExtractor 工具中 return 语句字符串表达式的提取逻辑,确保正确识别和处理包含特殊字符的字符串边界
|
|
6
|
+
- **Purpose**: 解决现有工具在提取 return 语句中包含特殊字符的字符串时出现的错误,确保工具能够统一、正确地匹配和处理 return 语句中的字符串表达式
|
|
7
|
+
- **Target Users**: 使用 CSharpStringExtractor 工具来扫描和提取 C# 代码中字符串字面量的开发者
|
|
8
|
+
|
|
9
|
+
## Goals
|
|
10
|
+
- 修复 `should handle special characters in string expression of return sentence` 测试用例的失败问题
|
|
11
|
+
- 确保工具能够正确识别 return 语句中的字符串边界
|
|
12
|
+
- 确保工具能够正确处理包含特殊字符的字符串,包括但不限于:`{}`、`[]`、`;`、`"`、`'`、`\`、`<`、`>` 等
|
|
13
|
+
- 保持所有现有测试用例的通过状态
|
|
14
|
+
|
|
15
|
+
## Non-Goals (Out of Scope)
|
|
16
|
+
- 修改被注释掉的测试用例
|
|
17
|
+
- 改变工具的整体架构或 API 接口
|
|
18
|
+
- 添加超出字符串边界识别之外的新功能
|
|
19
|
+
|
|
20
|
+
## Background & Context
|
|
21
|
+
- 当前 CSharpStringExtractor 工具已经支持大部分 C# 语句类型的字符串提取
|
|
22
|
+
- 测试用例 `should handle special characters in string expression of return sentence` 目前失败,问题在于 return 语句中的特殊字符字符串无法被正确处理
|
|
23
|
+
- 工具需要能够正确处理插值字符串($""、$@""、@$"")、普通字符串和包含各种特殊字符的字符串
|
|
24
|
+
|
|
25
|
+
## Functional Requirements
|
|
26
|
+
- **FR-1**: 工具必须能够正确提取 return 语句中的字符串表达式
|
|
27
|
+
- **FR-2**: 工具必须能够正确识别包含特殊字符的字符串边界
|
|
28
|
+
- **FR-3**: 工具必须确保字符串内部的特殊字符不被错误地识别为语句边界
|
|
29
|
+
- **FR-4**: 工具必须能够处理普通字符串、插值字符串($""、$@""、@$"")和包含转义字符的字符串
|
|
30
|
+
|
|
31
|
+
## Non-Functional Requirements
|
|
32
|
+
- **NFR-1**: 所有 75+ 个现有测试用例必须继续通过
|
|
33
|
+
- **NFR-2**: 修复不能降低工具的性能,扫描速度保持在可接受范围
|
|
34
|
+
- **NFR-3**: 代码必须遵循 TypeScript 语言规范,不使用保留关键字作为变量名
|
|
35
|
+
|
|
36
|
+
## Constraints
|
|
37
|
+
- **Technical**: 必须使用 TypeScript 编写,保持现有代码风格和架构
|
|
38
|
+
- **Business**: 必须在保持所有现有功能正常工作的前提下修复该问题
|
|
39
|
+
- **Dependencies**: 不添加任何新的依赖库
|
|
40
|
+
|
|
41
|
+
## Assumptions
|
|
42
|
+
- 当前被注释掉的测试用例不需要考虑
|
|
43
|
+
- 工具的其他功能保持不变
|
|
44
|
+
- 用户期望修复的是 return 语句中的特殊字符字符串处理问题
|
|
45
|
+
|
|
46
|
+
## Acceptance Criteria
|
|
47
|
+
|
|
48
|
+
### AC-1: Return 语句特殊字符字符串测试通过
|
|
49
|
+
- **Given**: 包含特殊字符的 return 语句测试用例
|
|
50
|
+
- **When**: 运行 `should handle special characters in string expression of return sentence` 测试
|
|
51
|
+
- **Then**: 该测试用例应该成功通过,不出现任何错误
|
|
52
|
+
- **Verification**: `programmatic`
|
|
53
|
+
- **Notes**: 确保 return 语句中的特殊字符字符串被正确提取
|
|
54
|
+
|
|
55
|
+
### AC-2: 所有现有测试继续通过
|
|
56
|
+
- **Given**: 完整的测试套件
|
|
57
|
+
- **When**: 运行所有测试用例
|
|
58
|
+
- **Then**: 所有 75+ 个现有测试用例应该继续通过
|
|
59
|
+
- **Verification**: `programmatic`
|
|
60
|
+
- **Notes**: 保持向后兼容性
|
|
61
|
+
|
|
62
|
+
### AC-3: 代码符合 TypeScript 规范
|
|
63
|
+
- **Given**: 源代码文件
|
|
64
|
+
- **When**: 检查 TypeScript 语法和编码规范
|
|
65
|
+
- **Then**: 代码必须严格符合 TypeScript 语言语法,不使用保留关键字作为变量名
|
|
66
|
+
- **Verification**: `programmatic`
|
|
67
|
+
|
|
68
|
+
## Open Questions
|
|
69
|
+
- 无
|
|
70
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
|
|
2
|
+
# 统一匹配 return 语句中的字符串表达式 - The Implementation Plan (Decomposed and Prioritized Task List)
|
|
3
|
+
|
|
4
|
+
## [x] 任务 1: 分析当前代码和失败测试的问题
|
|
5
|
+
- **Priority**: P0
|
|
6
|
+
- **Depends On**: None
|
|
7
|
+
- **Description**:
|
|
8
|
+
- 查看当前失败的测试用例,分析 return 语句中的字符串为什么没有被正确提取
|
|
9
|
+
- 检查 `processStatementAndExtractValue` 和 `extractValueExpression` 方法中 return 语句的处理逻辑
|
|
10
|
+
- 查看 `extractValueUntilSemicolon` 等相关辅助方法的实现
|
|
11
|
+
- **Acceptance Criteria Addressed**: [AC-1]
|
|
12
|
+
- **Test Requirements**:
|
|
13
|
+
- `programmatic` TR-1.1: 定位 return 语句字符串提取错误的具体位置 ✓
|
|
14
|
+
- `human-judgement` TR-1.2: 理解当前逻辑中的问题所在 ✓
|
|
15
|
+
- **Notes**: 重点关注 return 语句中的特殊字符字符串处理
|
|
16
|
+
|
|
17
|
+
## [x] 任务 2: 修复 return 语句中的字符串提取逻辑
|
|
18
|
+
- **Priority**: P0
|
|
19
|
+
- **Depends On**: 任务 1
|
|
20
|
+
- **Description**:
|
|
21
|
+
- 修复 `processStatementAndExtractValue` 方法中处理 return 语句的逻辑
|
|
22
|
+
- 确保 return 语句能够正确地被识别和处理
|
|
23
|
+
- 确保 return 语句中的字符串边界能够正确识别
|
|
24
|
+
- **Acceptance Criteria Addressed**: [AC-1, AC-3]
|
|
25
|
+
- **Test Requirements**:
|
|
26
|
+
- `programmatic` TR-2.1: 修复后 `should handle special characters in string expression of return sentence` 测试用例必须通过 ✓
|
|
27
|
+
- `programmatic` TR-2.2: 代码符合 TypeScript 语法规范,不使用保留关键字作为变量名 ✓
|
|
28
|
+
- **Notes**: 确保修改不会影响其他语句类型的处理
|
|
29
|
+
- **Modifications**: 在 `src/CSharpStringExtractor.ts:1736-1765` 中添加了检查逻辑:当 fullStatement === processedFullStatement 时,直接使用原始的 valueExpression,而不是重新提取
|
|
30
|
+
|
|
31
|
+
## [x] 任务 3: 运行所有测试确保没有回归
|
|
32
|
+
- **Priority**: P0
|
|
33
|
+
- **Depends On**: 任务 2
|
|
34
|
+
- **Description**:
|
|
35
|
+
- 运行完整的测试套件,确保所有测试用例都能通过
|
|
36
|
+
- 检查是否有任何测试出现回归
|
|
37
|
+
- **Acceptance Criteria Addressed**: [AC-2]
|
|
38
|
+
- **Test Requirements**:
|
|
39
|
+
- `programmatic` TR-3.1: 运行 `npm test` 命令,所有 75+ 个测试用例必须通过 ✓ (78 个测试全部通过)
|
|
40
|
+
- `programmatic` TR-3.2: 检查 TypeScript 编译没有错误 ✓ (核心源代码无错误)
|
|
41
|
+
- **Notes**: 确保修复不会破坏任何现有功能
|
|
42
|
+
|
|
43
|
+
## [x] 任务 4: 清理临时调试文件
|
|
44
|
+
- **Priority**: P2
|
|
45
|
+
- **Depends On**: 任务 3
|
|
46
|
+
- **Description**:
|
|
47
|
+
- 删除所有临时创建的调试文件
|
|
48
|
+
- 确保代码仓库的整洁
|
|
49
|
+
- **Acceptance Criteria Addressed**: []
|
|
50
|
+
- **Test Requirements**:
|
|
51
|
+
- `human-judgement` TR-4.1: 代码仓库中不再有临时的调试文件 ✓
|
|
52
|
+
- **Notes**: 保持 git 仓库的整洁
|
|
53
|
+
- **Deleted Files**: 所有根目录下的 debug-*.ts 文件和临时文本文件
|
|
54
|
+
|
package/bin/scanliterals.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
require("../dist/src/RunConvert.js")
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require("../dist/src/RunConvert.js")
|
package/bin/slimlangs.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
require("../dist/src/RunSlimLangs.js")
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
require("../dist/src/RunSlimLangs.js")
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const { CSharpStringExtractor } = require('./dist/CSharpStringExtractor');
|
|
3
|
+
const extractor = new CSharpStringExtractor();
|
|
4
|
+
const code = `
|
|
5
|
+
private void OnBtnIaa(EventContext context)
|
|
6
|
+
{
|
|
7
|
+
var iaaConfig = IAAConfigTable.GetConfigById((int)IAAId.境界失败_加速冷却);
|
|
8
|
+
if (iaaConfig == null)
|
|
9
|
+
{
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
string des = $"观看视频后\\n等待时间减少{iaaConfig.EffectValue / 60}分钟";
|
|
14
|
+
this.GetModel<IAAModel>().ShowAdWithDialog(IAAId.境界失败_加速冷却, "加速时间", des, null);
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
console.log('code:', JSON.stringify(code));
|
|
18
|
+
console.log('code.indexOf("加速时间"):', code.indexOf('"加速时间"'));
|
|
19
|
+
console.log('code.indexOf("观看视频后"):', code.indexOf('"观看视频后"'));
|
|
20
|
+
console.log('\n--- Full code ---');
|
|
21
|
+
console.log(code);
|
|
22
|
+
console.log('\n--- Indices ---');
|
|
23
|
+
for (let i = 0; i & lt; code.length)
|
|
24
|
+
;
|
|
25
|
+
i++;
|
|
26
|
+
{
|
|
27
|
+
if (code[i] === '"') {
|
|
28
|
+
console.log(i, ':', code.substring(i, i + 10));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const CSharpStringExtractor_1 = require("./src/CSharpStringExtractor");
|
|
4
|
+
const code = `
|
|
5
|
+
private void OnBtnIaa(EventContext context)
|
|
6
|
+
{
|
|
7
|
+
var iaaConfig = IAAConfigTable.GetConfigById((int)IAAId.境界失败_加速冷却);
|
|
8
|
+
if (iaaConfig == null)
|
|
9
|
+
{
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
string des = $"观看视频后\\n等待时间减少{iaaConfig.EffectValue / 60}分钟";
|
|
14
|
+
this.GetModel<IAAModel>().ShowAdWithDialog(IAAId.境界失败_加速冷却, "加速时间", des, null);
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
const extractor = new CSharpStringExtractor_1.CSharpStringExtractor();
|
|
18
|
+
const snippets = extractor.extractStrings(code);
|
|
19
|
+
console.log('Total snippets:', snippets.length);
|
|
20
|
+
console.log('---');
|
|
21
|
+
for (let i = 0; i < snippets.length; i++) {
|
|
22
|
+
console.log(`Snippet ${i}:`);
|
|
23
|
+
console.log(' originalIndex:', snippets[i].originalIndex);
|
|
24
|
+
console.log(' originalCode:', JSON.stringify(snippets[i].originalCode));
|
|
25
|
+
console.log(' literals:', snippets[i].literals);
|
|
26
|
+
console.log('---');
|
|
27
|
+
}
|
|
28
|
+
// Find the snippet with "加速时间"
|
|
29
|
+
const targetSnippet = snippets.find(s => s.originalCode.includes('加速时间'));
|
|
30
|
+
if (targetSnippet) {
|
|
31
|
+
console.log('Target snippet found at index:', snippets.indexOf(targetSnippet));
|
|
32
|
+
console.log(' originalIndex:', targetSnippet.originalIndex);
|
|
33
|
+
console.log(' Expected index:', code.indexOf('"加速时间"'));
|
|
34
|
+
}
|