scancscode 1.0.35 → 1.0.36
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-string-expression-capture-range/checklist.md +7 -0
- package/.trae/specs/fix-string-expression-capture-range/spec.md +96 -0
- package/.trae/specs/fix-string-expression-capture-range/tasks.md +25 -0
- package/.trae/specs/handle-null-value/checklist.md +10 -0
- package/.trae/specs/handle-null-value/spec.md +57 -0
- package/.trae/specs/handle-null-value/tasks.md +40 -0
- package/.trae/specs/handle-right-value-expression/checklist.md +9 -0
- package/.trae/specs/handle-right-value-expression/spec.md +72 -0
- package/.trae/specs/handle-right-value-expression/tasks.md +53 -0
- package/.trae/specs/process-function-call-interpolated-strings/checklist.md +12 -0
- package/.trae/specs/process-function-call-interpolated-strings/spec.md +80 -0
- package/.trae/specs/process-function-call-interpolated-strings/tasks.md +73 -0
- package/dist/src/CSharpStringExtractor.js +547 -117
- package/dist/test/CSharpStringExtractor.test.js +174 -0
- package/package.json +1 -1
- package/src/CSharpStringExtractor.ts +581 -116
- package/test/CSharpStringExtractor.test.ts +185 -0
- package/dist/debug-arg.js +0 -30
- package/dist/debug-args.js +0 -34
- package/dist/debug-comment-5.js +0 -25
- package/dist/debug-comment-strings.js +0 -24
- package/dist/debug-full.js +0 -14
- package/dist/debug-template-issue.js +0 -33
- package/dist/debug-test-5.js +0 -23
- package/dist/debug-test.js +0 -21
- package/dist/debug.js +0 -15
- package/dist/simple-debug.js +0 -27
- package/dist/simple-test.js +0 -61
- package/dist/temp-original-source.js +0 -1
- package/dist/test-logic.js +0 -79
- package/dist/test-regex.js +0 -13
|
@@ -2491,4 +2491,189 @@ namespace FaBao.UI.MainUI
|
|
|
2491
2491
|
}
|
|
2492
2492
|
});
|
|
2493
2493
|
|
|
2494
|
+
// 处理字符串出现在赋值表达式的 `=` 左边(左值表达式)的情况
|
|
2495
|
+
test('should handle right value expression', () => {
|
|
2496
|
+
const code = `
|
|
2497
|
+
((GLoader)GetChild($"m_loader_dailyItem{i + 1}")).url = FUISys.Instance.GetIconUrl(ItemTable.GetConfigById(_cardConfig.EveryDayAwards[i].ResId).Icon);
|
|
2498
|
+
`;
|
|
2499
|
+
const snippets = extractor.extractStrings(code);
|
|
2500
|
+
{
|
|
2501
|
+
let targetSnippet = snippets[0];
|
|
2502
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"m_loader_dailyItem{i + 1}"`));
|
|
2503
|
+
expect(targetSnippet.originalCode).toBe(`$"m_loader_dailyItem{i + 1}"`); // 左边表达式函数调用参数中的字符串表达式
|
|
2504
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("m_loader_dailyItem{0}", i + 1)`);
|
|
2505
|
+
expect(targetSnippet.literals).toEqual([
|
|
2506
|
+
`m_loader_dailyItem{0}`
|
|
2507
|
+
]);
|
|
2508
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2509
|
+
}
|
|
2510
|
+
expect(snippets.length).toBe(1);
|
|
2511
|
+
});
|
|
2512
|
+
|
|
2513
|
+
// 支持处理字符串里出现各种特殊符号的情况
|
|
2514
|
+
test('should handle special characters in string 8', () => {
|
|
2515
|
+
const code = `
|
|
2516
|
+
m_btn_paid.text = $"<img src='ui://a0w66rlc7bhfusff'/ width = '70' height = '70'>{paidConfig.Quantity}";
|
|
2517
|
+
`;
|
|
2518
|
+
const snippets = extractor.extractStrings(code);
|
|
2519
|
+
{
|
|
2520
|
+
let targetSnippet = snippets[0];
|
|
2521
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"<img src='ui://a0w66rlc7bhfusff'/ width = '70' height = '70'>{paidConfig.Quantity}"`));
|
|
2522
|
+
expect(targetSnippet.originalCode).toBe(`$"<img src='ui://a0w66rlc7bhfusff'/ width = '70' height = '70'>{paidConfig.Quantity}"`);
|
|
2523
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("<img src='ui://a0w66rlc7bhfusff'/ width = '70' height = '70'>{0}", paidConfig.Quantity)`);
|
|
2524
|
+
expect(targetSnippet.literals).toEqual([
|
|
2525
|
+
`<img src='ui://a0w66rlc7bhfusff'/ width = '70' height = '70'>{0}`
|
|
2526
|
+
]);
|
|
2527
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2528
|
+
}
|
|
2529
|
+
expect(snippets.length).toBe(1);
|
|
2530
|
+
});
|
|
2531
|
+
|
|
2532
|
+
// 处理赋值表达式 `=` 左右两边(左值表达式和右值表达式)都存在字符串的情况
|
|
2533
|
+
test('should handle assignment expression with both sides strings', () => {
|
|
2534
|
+
const code = `
|
|
2535
|
+
((GTextField)GetChild($"m_text_dailyCount{i + 1}")).text = $"x{_cardConfig.EveryDayAwards[i].Count}";
|
|
2536
|
+
`;
|
|
2537
|
+
const snippets = extractor.extractStrings(code);
|
|
2538
|
+
{
|
|
2539
|
+
let targetSnippet = snippets[0];
|
|
2540
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"m_text_dailyCount{i + 1}"`));
|
|
2541
|
+
expect(targetSnippet.originalCode).toBe(`$"m_text_dailyCount{i + 1}"`);
|
|
2542
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("m_text_dailyCount{0}", i + 1)`);
|
|
2543
|
+
expect(targetSnippet.literals).toEqual([
|
|
2544
|
+
`m_text_dailyCount{0}`
|
|
2545
|
+
]);
|
|
2546
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2547
|
+
}
|
|
2548
|
+
{
|
|
2549
|
+
let targetSnippet = snippets[1];
|
|
2550
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"x{_cardConfig.EveryDayAwards[i].Count}"`));
|
|
2551
|
+
expect(targetSnippet.originalCode).toBe(`$"x{_cardConfig.EveryDayAwards[i].Count}"`);
|
|
2552
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("x{0}", _cardConfig.EveryDayAwards[i].Count)`);
|
|
2553
|
+
expect(targetSnippet.literals).toEqual([
|
|
2554
|
+
`x{0}`
|
|
2555
|
+
]);
|
|
2556
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2557
|
+
}
|
|
2558
|
+
expect(snippets.length).toBe(2);
|
|
2559
|
+
});
|
|
2560
|
+
|
|
2561
|
+
// 支持处理字符串里出现各种特殊符号的情况
|
|
2562
|
+
test('should handle special characters in string 8', () => {
|
|
2563
|
+
const code = `
|
|
2564
|
+
(GetChild($"m_textAnime{GetNextNumber()}") as TurtleTextAnimeComp)?.SetText(word);
|
|
2565
|
+
`;
|
|
2566
|
+
const snippets = extractor.extractStrings(code);
|
|
2567
|
+
{
|
|
2568
|
+
let targetSnippet = snippets[0];
|
|
2569
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"m_textAnime{GetNextNumber()}"`));
|
|
2570
|
+
expect(targetSnippet.originalCode).toBe(`$"m_textAnime{GetNextNumber()}"`);
|
|
2571
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("m_textAnime{0}", GetNextNumber())`);
|
|
2572
|
+
expect(targetSnippet.literals).toEqual([
|
|
2573
|
+
`m_textAnime{0}`
|
|
2574
|
+
]);
|
|
2575
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2576
|
+
}
|
|
2577
|
+
expect(snippets.length).toBe(1);
|
|
2578
|
+
});
|
|
2579
|
+
|
|
2580
|
+
// 支持处理字符串里出现各种特殊符号的情况
|
|
2581
|
+
test('should handle special characters in string 9', () => {
|
|
2582
|
+
const code = `
|
|
2583
|
+
(GetChild($"m_textAnime{GetNextNumber()}") as TurtleTextAnimeComp)?.SetText(word);
|
|
2584
|
+
`;
|
|
2585
|
+
const snippets = extractor.extractStrings(code);
|
|
2586
|
+
{
|
|
2587
|
+
let targetSnippet = snippets[0];
|
|
2588
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"m_textAnime{GetNextNumber()}"`));
|
|
2589
|
+
expect(targetSnippet.originalCode).toBe(`$"m_textAnime{GetNextNumber()}"`);
|
|
2590
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("m_textAnime{0}", GetNextNumber())`);
|
|
2591
|
+
expect(targetSnippet.literals).toEqual([
|
|
2592
|
+
`m_textAnime{0}`
|
|
2593
|
+
]);
|
|
2594
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2595
|
+
}
|
|
2596
|
+
expect(snippets.length).toBe(1);
|
|
2597
|
+
});
|
|
2598
|
+
|
|
2599
|
+
// 修正字符串表达式捕获范围
|
|
2600
|
+
test('should handle string expression capture range 1', () => {
|
|
2601
|
+
const code = `
|
|
2602
|
+
(GetChild($"vwvwe{index + 1}") as LargeLotterySpellCardComp)?.InitData(spellCardId, true);
|
|
2603
|
+
`;
|
|
2604
|
+
const snippets = extractor.extractStrings(code);
|
|
2605
|
+
{
|
|
2606
|
+
let targetSnippet = snippets[0];
|
|
2607
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"vwvwe{index + 1}"`));
|
|
2608
|
+
expect(targetSnippet.originalCode).toBe(`$"vwvwe{index + 1}"`);
|
|
2609
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("vwvwe{0}", index + 1)`);
|
|
2610
|
+
expect(targetSnippet.literals).toEqual([
|
|
2611
|
+
`vwvwe{0}`
|
|
2612
|
+
]);
|
|
2613
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2614
|
+
}
|
|
2615
|
+
expect(snippets.length).toBe(1);
|
|
2616
|
+
});
|
|
2617
|
+
|
|
2618
|
+
// 修正字符串表达式捕获范围
|
|
2619
|
+
test('should handle string expression capture range 2', () => {
|
|
2620
|
+
const code = `
|
|
2621
|
+
(GetChild($"brrr_{index + 1}") as LargeLotterySpellCardComp)?.InitData(spellCardId, true);
|
|
2622
|
+
`;
|
|
2623
|
+
const snippets = extractor.extractStrings(code);
|
|
2624
|
+
{
|
|
2625
|
+
let targetSnippet = snippets[0];
|
|
2626
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"brrr_{index + 1}"`));
|
|
2627
|
+
expect(targetSnippet.originalCode).toBe(`$"brrr_{index + 1}"`);
|
|
2628
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("brrr_{0}", index + 1)`);
|
|
2629
|
+
expect(targetSnippet.literals).toEqual([
|
|
2630
|
+
`brrr_{0}`
|
|
2631
|
+
]);
|
|
2632
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2633
|
+
}
|
|
2634
|
+
expect(snippets.length).toBe(1);
|
|
2635
|
+
});
|
|
2636
|
+
|
|
2637
|
+
// 修正字符串表达式捕获范围
|
|
2638
|
+
test('should handle string expression capture range 3', () => {
|
|
2639
|
+
const code = `
|
|
2640
|
+
(GetChild($"m_card_{index}") as LargeLotterySpellCardComp)?.PlayEff();
|
|
2641
|
+
`;
|
|
2642
|
+
const snippets = extractor.extractStrings(code);
|
|
2643
|
+
{
|
|
2644
|
+
let targetSnippet = snippets[0];
|
|
2645
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`$"m_card_{index}"`));
|
|
2646
|
+
expect(targetSnippet.originalCode).toBe(`$"m_card_{index}"`);
|
|
2647
|
+
expect(targetSnippet.convertedCode).toBe(`Tr.Format("m_card_{0}", index)`);
|
|
2648
|
+
expect(targetSnippet.literals).toEqual([
|
|
2649
|
+
`m_card_{0}`
|
|
2650
|
+
]);
|
|
2651
|
+
expect(targetSnippet.isChanged).toBe(true);
|
|
2652
|
+
}
|
|
2653
|
+
expect(snippets.length).toBe(1);
|
|
2654
|
+
});
|
|
2655
|
+
|
|
2656
|
+
// 字符串表达式字面量直接为null时, 无需转换null
|
|
2657
|
+
test('should handle null 1', () => {
|
|
2658
|
+
const code = `m_text_notice.text = null;`;
|
|
2659
|
+
const snippets = extractor.extractStrings(code);
|
|
2660
|
+
{
|
|
2661
|
+
let targetSnippet = snippets[0];
|
|
2662
|
+
expect(targetSnippet.originalIndex).toBe(code.indexOf(`null`));
|
|
2663
|
+
expect(targetSnippet.originalCode).toBe(`null`);
|
|
2664
|
+
expect(targetSnippet.convertedCode).toBe(`null`);
|
|
2665
|
+
expect(targetSnippet.literals).toEqual([
|
|
2666
|
+
]);
|
|
2667
|
+
expect(targetSnippet.isChanged).toBe(false);
|
|
2668
|
+
}
|
|
2669
|
+
expect(snippets.length).toBe(1);
|
|
2670
|
+
});
|
|
2671
|
+
|
|
2672
|
+
// 字符串表达式字面量直接为null时, 无需转换null
|
|
2673
|
+
test('should handle null 2', () => {
|
|
2674
|
+
const code = `m_text_notice.wfefe = null;`;
|
|
2675
|
+
const snippets = extractor.extractStrings(code);
|
|
2676
|
+
expect(snippets.length).toBe(0);
|
|
2677
|
+
});
|
|
2678
|
+
|
|
2494
2679
|
});
|
package/dist/debug-arg.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/debug-args.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
}
|
package/dist/debug-comment-5.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CSharpStringExtractor_1 = require("./src/CSharpStringExtractor");
|
|
4
|
-
const extractor = new CSharpStringExtractor_1.CSharpStringExtractor();
|
|
5
|
-
const code = `
|
|
6
|
-
//上锁
|
|
7
|
-
case (int)State.Lock:
|
|
8
|
-
Toast.Info($"灵田{_model.GetFarmLandUnlockLevel(_landId)}级解锁");
|
|
9
|
-
break;
|
|
10
|
-
`;
|
|
11
|
-
console.log('=== 开始调试 ===');
|
|
12
|
-
console.log('完整代码:', JSON.stringify(code));
|
|
13
|
-
console.log('\n内插字符串位置:', code.indexOf(`$"灵田{_model.GetFarmLandUnlockLevel(_landId)}级解锁"`));
|
|
14
|
-
const snippets = extractor.extractStrings(code);
|
|
15
|
-
console.log('\n=== 提取到的 snippet ===');
|
|
16
|
-
console.log(`数量: ${snippets.length}`);
|
|
17
|
-
snippets.forEach((snippet, index) => {
|
|
18
|
-
console.log(`\nSnippet ${index}:`);
|
|
19
|
-
console.log(` originalIndex: ${snippet.originalIndex}`);
|
|
20
|
-
console.log(` originalCode: ${JSON.stringify(snippet.originalCode)}`);
|
|
21
|
-
console.log(` convertedCode: ${JSON.stringify(snippet.convertedCode)}`);
|
|
22
|
-
console.log(` literals:`, snippet.literals);
|
|
23
|
-
console.log(` isChanged: ${snippet.isChanged}`);
|
|
24
|
-
console.log(` 对应代码片段:`, JSON.stringify(code.substring(snippet.originalIndex, snippet.originalIndex + snippet.originalCode.length)));
|
|
25
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CSharpStringExtractor_1 = require("./src/CSharpStringExtractor");
|
|
4
|
-
const extractor = new CSharpStringExtractor_1.CSharpStringExtractor();
|
|
5
|
-
// Test code 1
|
|
6
|
-
const code = `
|
|
7
|
-
protected override void OnShow(object param)
|
|
8
|
-
{
|
|
9
|
-
// Log.Info("AAA:ChooseSutraLayer显示1");
|
|
10
|
-
base.OnShow(param);
|
|
11
|
-
}`;
|
|
12
|
-
console.log('=== code.indexOf("AAA:Choose..."):', code.indexOf(`"AAA:ChooseSutraLayer显示1"`));
|
|
13
|
-
console.log('\n=== Full code (indices): ===');
|
|
14
|
-
for (let i = 0; i < code.length; i++) {
|
|
15
|
-
console.log(i, ':', JSON.stringify(code[i]));
|
|
16
|
-
}
|
|
17
|
-
console.log('\n=== Extracting snippets ===');
|
|
18
|
-
const snippets = extractor.extractStrings(code);
|
|
19
|
-
console.log(`\n=== Total snippets: ${snippets.length} ===`);
|
|
20
|
-
for (let i = 0; i < snippets.length; i++) {
|
|
21
|
-
console.log(`\n--- Snippet ${i} ---`);
|
|
22
|
-
console.log('Original Index:', snippets[i].originalIndex);
|
|
23
|
-
console.log('Original Code:', JSON.stringify(snippets[i].originalCode));
|
|
24
|
-
}
|
package/dist/debug-full.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CSharpStringExtractor_1 = require("./src/CSharpStringExtractor");
|
|
4
|
-
const extractor = new CSharpStringExtractor_1.CSharpStringExtractor();
|
|
5
|
-
const code = `infoStr += $"是否暴击: [b]{(_damageInfo.IsCritical ? "[color=#00B000]是[/color]" : "否")}[/b]\n";`;
|
|
6
|
-
console.log('Original code:', code);
|
|
7
|
-
console.log('\n---\n');
|
|
8
|
-
const snippet = new CSharpStringExtractor_1.CodeSnippet();
|
|
9
|
-
snippet.originalCode = code;
|
|
10
|
-
snippet.originalIndex = 0;
|
|
11
|
-
const result = extractor.processStringTemplates(code, snippet, 'Tr', 'Format');
|
|
12
|
-
console.log('Result:', result);
|
|
13
|
-
console.log('\n---\n');
|
|
14
|
-
console.log('Snippet converted code:', snippet.convertedCode);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const testCode = `infoStr += $"是否暴击: [b]{(_damageInfo.IsCritical ? "[color=#00B000]是[/color]" : "否")}[/b]\n";`;
|
|
3
|
-
const templateRegex = /(\$@?|@\$)"((?:[^"\\]|\\.)*)"/gs;
|
|
4
|
-
const match = templateRegex.exec(testCode);
|
|
5
|
-
if (match) {
|
|
6
|
-
console.log('Full match:', JSON.stringify(match[0]));
|
|
7
|
-
console.log('Content:', JSON.stringify(match[2]));
|
|
8
|
-
const content = match[2];
|
|
9
|
-
let templateIndex = 0;
|
|
10
|
-
console.log('\n=== Original code without string handling ===');
|
|
11
|
-
while (templateIndex < content.length) {
|
|
12
|
-
if (content[templateIndex] === '{') {
|
|
13
|
-
templateIndex++;
|
|
14
|
-
let exprStart = templateIndex;
|
|
15
|
-
let braceDepth = 1;
|
|
16
|
-
while (templateIndex < content.length && braceDepth > 0) {
|
|
17
|
-
if (content[templateIndex] === '{') {
|
|
18
|
-
braceDepth++;
|
|
19
|
-
}
|
|
20
|
-
else if (content[templateIndex] === '}') {
|
|
21
|
-
braceDepth--;
|
|
22
|
-
}
|
|
23
|
-
console.log(`Index ${templateIndex}: char '${content[templateIndex]}', depth: ${braceDepth}`);
|
|
24
|
-
templateIndex++;
|
|
25
|
-
}
|
|
26
|
-
const varExpr = content.substring(exprStart, templateIndex - 1);
|
|
27
|
-
console.log('Extracted variable expression:', JSON.stringify(varExpr));
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
templateIndex++;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
package/dist/debug-test-5.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CSharpStringExtractor_1 = require("./src/CSharpStringExtractor");
|
|
4
|
-
const extractor = new CSharpStringExtractor_1.CSharpStringExtractor();
|
|
5
|
-
const code = `
|
|
6
|
-
//上锁
|
|
7
|
-
case (int)State.Lock:
|
|
8
|
-
Toast.Info($"灵田{_model.GetFarmLandUnlockLevel(_landId)}级解锁");
|
|
9
|
-
break;
|
|
10
|
-
`;
|
|
11
|
-
console.log('=== code ===');
|
|
12
|
-
console.log(code);
|
|
13
|
-
console.log('\n=== Extracting snippets ===');
|
|
14
|
-
const snippets = extractor.extractStrings(code);
|
|
15
|
-
console.log(`\n=== snippets.length: ${snippets.length}`);
|
|
16
|
-
for (let i = 0; i < snippets.length; i++) {
|
|
17
|
-
console.log(`\n--- snippet ${i} ---`);
|
|
18
|
-
console.log('originalIndex:', snippets[i].originalIndex);
|
|
19
|
-
console.log('originalCode:', JSON.stringify(snippets[i].originalCode));
|
|
20
|
-
console.log('convertedCode:', JSON.stringify(snippets[i].convertedCode));
|
|
21
|
-
console.log('literals:', snippets[i].literals);
|
|
22
|
-
console.log('isChanged:', snippets[i].isChanged);
|
|
23
|
-
}
|
package/dist/debug-test.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const testCode = `
|
|
3
|
-
private void OnBtnIaa(EventContext context)
|
|
4
|
-
{
|
|
5
|
-
var iaaConfig = IAAConfigTable.GetConfigById((int)IAAId.境界失败_加速冷却);
|
|
6
|
-
if (iaaConfig == null)
|
|
7
|
-
{
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
string des = $"观看视频后\\n等待时间减少{iaaConfig.EffectValue / 60}分钟";
|
|
12
|
-
this.GetModel<IAAModel>().ShowAdWithDialog(IAAId.境界失败_加速冷却, "加速时间", des, null);
|
|
13
|
-
}
|
|
14
|
-
`;
|
|
15
|
-
console.log('Full test code:', testCode);
|
|
16
|
-
console.log('Index of "加速时间":', testCode.indexOf('"加速时间"'));
|
|
17
|
-
console.log('Index of "观看视频后":', testCode.indexOf('"观看视频后'));
|
|
18
|
-
console.log('\n--- Code around index 358 ---');
|
|
19
|
-
console.log(testCode.substring(350, 380));
|
|
20
|
-
console.log('\n--- Code around index 375 ---');
|
|
21
|
-
console.log(testCode.substring(360, 390));
|
package/dist/debug.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CSharpStringExtractor_1 = require("./src/CSharpStringExtractor");
|
|
4
|
-
const extractor = new CSharpStringExtractor_1.CSharpStringExtractor();
|
|
5
|
-
const code = `infoStr += $"是否暴击: [b]{(_damageInfo.IsCritical ? "[color=#00B000]是[/color]" : "否")}[/b]\n";`;
|
|
6
|
-
console.log('Testing code:', code);
|
|
7
|
-
console.log('-------------------');
|
|
8
|
-
const snippets = extractor.extractStrings(code);
|
|
9
|
-
console.log('Number of snippets:', snippets.length);
|
|
10
|
-
if (snippets.length > 0) {
|
|
11
|
-
const snippet = snippets[0];
|
|
12
|
-
console.log('Original code:', snippet.originalCode);
|
|
13
|
-
console.log('Converted code:', snippet.convertedCode);
|
|
14
|
-
console.log('Literals:', snippet.literals);
|
|
15
|
-
}
|
package/dist/simple-debug.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CSharpStringExtractor_1 = require("./src/CSharpStringExtractor");
|
|
4
|
-
const extractor = new CSharpStringExtractor_1.CSharpStringExtractor();
|
|
5
|
-
const code = `
|
|
6
|
-
protected override void OnShow(object param)
|
|
7
|
-
{
|
|
8
|
-
// Log.Info("AAA:ChooseSutraLayer显示1");
|
|
9
|
-
base.OnShow(param);
|
|
10
|
-
}`;
|
|
11
|
-
console.log('=== code.indexOf("AAA..."):', code.indexOf(`"AAA:ChooseSutraLayer显示1"`));
|
|
12
|
-
console.log('\n=== Code with indices: ===');
|
|
13
|
-
let idx = 0;
|
|
14
|
-
while (idx < code.length) {
|
|
15
|
-
console.log(idx, code.charCodeAt(idx), JSON.stringify(code[idx]));
|
|
16
|
-
idx++;
|
|
17
|
-
}
|
|
18
|
-
console.log('\n=== Extracting snippets ===');
|
|
19
|
-
const snippets = extractor.extractStrings(code);
|
|
20
|
-
console.log('\n=== snippets.length:', snippets.length);
|
|
21
|
-
let snippetIdx = 0;
|
|
22
|
-
while (snippetIdx < snippets.length) {
|
|
23
|
-
console.log('\n--- snippet', snippetIdx, '---');
|
|
24
|
-
console.log('originalIndex:', snippets[snippetIdx].originalIndex);
|
|
25
|
-
console.log('originalCode:', JSON.stringify(snippets[snippetIdx].originalCode));
|
|
26
|
-
snippetIdx++;
|
|
27
|
-
}
|
package/dist/simple-test.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const testCode = `infoStr += $"是否暴击: [b]{(_damageInfo.IsCritical ? "[color=#00B000]是[/color]" : "否")}[/b]\n";`;
|
|
3
|
-
console.log('Original code:', testCode);
|
|
4
|
-
console.log('\nLooking for interpolated string...');
|
|
5
|
-
let i = 0;
|
|
6
|
-
while (i < testCode.length - 1) {
|
|
7
|
-
let startIndex = -1;
|
|
8
|
-
let contentStart = -1;
|
|
9
|
-
if (i + 1 < testCode.length) {
|
|
10
|
-
console.log(`i=${i}, char1=${testCode[i]}, char2=${testCode[i + 1]}`);
|
|
11
|
-
if (testCode[i] === '$' && testCode[i + 1] === '"') {
|
|
12
|
-
console.log('→ Found $" at', i);
|
|
13
|
-
startIndex = i;
|
|
14
|
-
contentStart = i + 2;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (startIndex !== -1 && contentStart !== -1) {
|
|
18
|
-
console.log('startIndex:', startIndex, 'contentStart:', contentStart);
|
|
19
|
-
let braceDepth = 0;
|
|
20
|
-
let inString = false;
|
|
21
|
-
let escapeNext = false;
|
|
22
|
-
let stringDelimiter = '';
|
|
23
|
-
let j = contentStart;
|
|
24
|
-
let endFound = false;
|
|
25
|
-
while (j < testCode.length) {
|
|
26
|
-
const char = testCode[j];
|
|
27
|
-
console.log(` j=${j}, char=${JSON.stringify(char)}, inString=${inString}, stringDelimiter=${JSON.stringify(stringDelimiter)}, braceDepth=${braceDepth}`);
|
|
28
|
-
if (escapeNext) {
|
|
29
|
-
escapeNext = false;
|
|
30
|
-
}
|
|
31
|
-
else if (char === '\\') {
|
|
32
|
-
escapeNext = true;
|
|
33
|
-
}
|
|
34
|
-
else if (inString) {
|
|
35
|
-
if (char === stringDelimiter) {
|
|
36
|
-
inString = false;
|
|
37
|
-
stringDelimiter = '';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else if (char === '"' || char === "'") {
|
|
41
|
-
inString = true;
|
|
42
|
-
stringDelimiter = char;
|
|
43
|
-
}
|
|
44
|
-
else if (!inString && char === '{') {
|
|
45
|
-
braceDepth++;
|
|
46
|
-
}
|
|
47
|
-
else if (!inString && char === '}') {
|
|
48
|
-
braceDepth--;
|
|
49
|
-
}
|
|
50
|
-
else if (!inString && char === '"' && braceDepth === 0) {
|
|
51
|
-
console.log('→ Found closing " at', j);
|
|
52
|
-
endFound = true;
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
j++;
|
|
56
|
-
}
|
|
57
|
-
console.log('End loop');
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
i++;
|
|
61
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/test-logic.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// 测试我们的逻辑
|
|
3
|
-
const trimmedFullStatement = "case (int)State.Lock: Toast.Info($\"灵田{_model.GetFarmLandUnlockLevel(_landId)}级解锁\"); break;";
|
|
4
|
-
const trimmedProcessedStatement = "case (int)State.Lock: Toast.Info(Tr.Format(\"灵田{0}级解锁\", _model.GetFarmLandUnlockLevel(_landId))); break;";
|
|
5
|
-
console.log('=== trimmedFullStatement ===');
|
|
6
|
-
console.log(trimmedFullStatement);
|
|
7
|
-
console.log('=== trimmedProcessedStatement ===');
|
|
8
|
-
console.log(trimmedProcessedStatement);
|
|
9
|
-
let colonIndex = -1;
|
|
10
|
-
let inString = false;
|
|
11
|
-
let escapeNext = false;
|
|
12
|
-
let stringDelimiter = '';
|
|
13
|
-
let searchStart = 0;
|
|
14
|
-
console.log('\n=== Looking for colon in trimmedFullStatement ===');
|
|
15
|
-
for (let i = 0; i < trimmedFullStatement.length; i++) {
|
|
16
|
-
const char = trimmedFullStatement[i];
|
|
17
|
-
if (escapeNext) {
|
|
18
|
-
escapeNext = false;
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
if (char === '\\') {
|
|
22
|
-
escapeNext = true;
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
if (inString) {
|
|
26
|
-
if (char === stringDelimiter) {
|
|
27
|
-
inString = false;
|
|
28
|
-
stringDelimiter = '';
|
|
29
|
-
}
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (char === '"' || char === "'") {
|
|
33
|
-
inString = true;
|
|
34
|
-
stringDelimiter = char;
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
if (char === ':') {
|
|
38
|
-
colonIndex = i;
|
|
39
|
-
console.log(`Found colon at index ${i}`);
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (colonIndex !== -1) {
|
|
44
|
-
searchStart = colonIndex + 1;
|
|
45
|
-
}
|
|
46
|
-
console.log(`searchStart = ${searchStart}`);
|
|
47
|
-
let lastParenOpenIndex = -1;
|
|
48
|
-
inString = false;
|
|
49
|
-
escapeNext = false;
|
|
50
|
-
stringDelimiter = '';
|
|
51
|
-
console.log('\n=== Looking for last paren in trimmedProcessedStatement from searchStart ===');
|
|
52
|
-
for (let i = searchStart; i < trimmedProcessedStatement.length; i++) {
|
|
53
|
-
const char = trimmedProcessedStatement[i];
|
|
54
|
-
if (escapeNext) {
|
|
55
|
-
escapeNext = false;
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (char === '\\') {
|
|
59
|
-
escapeNext = true;
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
if (inString) {
|
|
63
|
-
if (char === stringDelimiter) {
|
|
64
|
-
inString = false;
|
|
65
|
-
stringDelimiter = '';
|
|
66
|
-
}
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
if (char === '"' || char === "'") {
|
|
70
|
-
inString = true;
|
|
71
|
-
stringDelimiter = char;
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (char === '(') {
|
|
75
|
-
lastParenOpenIndex = i;
|
|
76
|
-
console.log(`Found ( at index ${i}`);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
console.log(`lastParenOpenIndex = ${lastParenOpenIndex}`);
|
package/dist/test-regex.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const code = `infoStr += $"是否暴击: [b]{(_damageInfo.IsCritical ? "[color=#00B000]是[/color]" : "否")}[/b]\n";`;
|
|
3
|
-
const templateRegex = /(\$@?|@\$)"((?:[^"\\]|\\.)*)"/gs;
|
|
4
|
-
console.log('Testing regex...');
|
|
5
|
-
console.log('Code:', code);
|
|
6
|
-
let match;
|
|
7
|
-
while ((match = templateRegex.exec(code)) !== null) {
|
|
8
|
-
console.log('Match found:');
|
|
9
|
-
console.log('Full match:', match[0]);
|
|
10
|
-
console.log('Content:', match[2]);
|
|
11
|
-
console.log('Content length:', match[2].length);
|
|
12
|
-
console.log('---');
|
|
13
|
-
}
|