Skip to content

Commit 20db679

Browse files
committed
Merge feature/step-into-call-template into main
2 parents 9716cc6 + 1998cbb commit 20db679

14 files changed

Lines changed: 1615 additions & 411 deletions

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22

33
All notable changes to the XSLT Debugger extension will be documented in this file.
44

5+
## [0.6.0] - 2025
6+
7+
### Added
8+
9+
- Paired `template-entry`/`template-exit` instrumentation in both engines so call depth is tracked reliably.
10+
- Interactive console `StepIntoTest` highlights template markers while stepping through call-template scenarios.
11+
- Dedicated `StepIntoTests` suite covering step-into, step-over, and step-out flows for compiled and Saxon engines (115 tests total).
12+
13+
### Changed
14+
15+
- Step mode controller records the originating stop location to decide when `Step Over` and `Step Out` should halt.
16+
- Saxon instrumentation always emits probes for `xsl:call-template`, even when sibling probes exist, ensuring the line after the call is reachable.
17+
- Documentation references the 0.6.0 VSIX packages and explains the new stepping behaviour.
18+
19+
### Fixed
20+
21+
- `Step Over` no longer runs the Saxon engine to completion after an `xsl:call-template`; execution now pauses on the next statement.
22+
- `Step Out` consistently returns to the caller template thanks to call-depth unwinding and exit probes.
23+
524
## [0.0.3] - 2025
625

726
### Fixed

README.md

Lines changed: 72 additions & 323 deletions
Large diffs are not rendered by default.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet version="1.0"
3+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4+
5+
<xsl:output method="xml" indent="yes"/>
6+
7+
<!-- Main template that calls other templates -->
8+
<xsl:template match="/">
9+
<root>
10+
<xsl:text>Starting transformation</xsl:text>
11+
12+
<!-- Call first template -->
13+
<xsl:call-template name="processOrder"/>
14+
15+
<xsl:text>Completed transformation</xsl:text>
16+
</root>
17+
</xsl:template>
18+
19+
<!-- Named template 1: processOrder -->
20+
<xsl:template name="processOrder">
21+
<order>
22+
<xsl:text>Processing order...</xsl:text>
23+
24+
<!-- Call nested template -->
25+
<xsl:call-template name="calculateTotal"/>
26+
27+
<xsl:text>Order processed</xsl:text>
28+
</order>
29+
</xsl:template>
30+
31+
<!-- Named template 2: calculateTotal (nested call) -->
32+
<xsl:template name="calculateTotal">
33+
<total>
34+
<xsl:text>Calculating total...</xsl:text>
35+
36+
<!-- Call another nested template -->
37+
<xsl:call-template name="formatOutput"/>
38+
39+
<xsl:text>Total calculated</xsl:text>
40+
</total>
41+
</xsl:template>
42+
43+
<!-- Named template 3: formatOutput (deeply nested) -->
44+
<xsl:template name="formatOutput">
45+
<formatted>
46+
<xsl:text>Output formatted</xsl:text>
47+
</formatted>
48+
</xsl:template>
49+
50+
</xsl:stylesheet>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<data>
3+
<message>Test data for step-into functionality</message>
4+
</data>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<xsl:stylesheet version="1.0"
3+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4+
5+
<xsl:output method="xml" indent="yes" />
6+
7+
<xsl:template match="/">
8+
<root>
9+
<xsl:text>Starting transformation</xsl:text>
10+
<xsl:call-template name="processOrder" />
11+
<xsl:text>Completed transformation</xsl:text>
12+
</root>
13+
</xsl:template>
14+
15+
<xsl:template name="processOrder">
16+
<order>
17+
<xsl:text>Processing order...</xsl:text>
18+
<xsl:call-template name="calculateTotal">
19+
<xsl:with-param name="pAmount" select="100" />
20+
</xsl:call-template>
21+
<xsl:text>Order processed</xsl:text>
22+
</order>
23+
</xsl:template>
24+
25+
<xsl:template name="calculateTotal">
26+
<!-- params MUST be first children inside the template -->
27+
<xsl:param name="pAmount" />
28+
<!-- keep math in a local variable -->
29+
<xsl:variable name="vTotal" select="$pAmount * 1.1" />
30+
<total>
31+
<xsl:text>Calculating total...</xsl:text>
32+
<value>
33+
<xsl:value-of select="$vTotal" />
34+
</value>
35+
<xsl:call-template name="formatCurrency">
36+
<xsl:with-param name="pValue" select="$vTotal" />
37+
</xsl:call-template>
38+
</total>
39+
</xsl:template>
40+
41+
<xsl:template name="formatCurrency">
42+
<xsl:param name="pValue" />
43+
<formatted>
44+
<xsl:text>$</xsl:text>
45+
<xsl:value-of select="format-number($pValue, '0.00')" />
46+
</formatted>
47+
</xsl:template>
48+
49+
<xsl:template name="helperFunction">
50+
<helper>
51+
<xsl:text>This is a helper that should be skipped with step-over</xsl:text>
52+
</helper>
53+
</xsl:template>
54+
</xsl:stylesheet>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.IO;
3+
using System.Threading.Tasks;
4+
using XsltDebugger.DebugAdapter;
5+
6+
namespace XsltDebugger.ConsoleTest;
7+
8+
/// <summary>
9+
/// Quick automated test to verify step-into functionality
10+
/// </summary>
11+
class QuickStepTest
12+
{
13+
static async Task Main(string[] args)
14+
{
15+
Console.WriteLine("=== Quick Step-Into Verification Test ===\n");
16+
17+
// Create a simple XSLT in-memory for testing
18+
var testDir = Path.Combine(Path.GetTempPath(), "xslt-step-test");
19+
Directory.CreateDirectory(testDir);
20+
21+
var xsltPath = Path.Combine(testDir, "test.xslt");
22+
var xmlPath = Path.Combine(testDir, "test.xml");
23+
24+
// Simple XSLT with nested templates (NO params/variables to avoid instrumentation issues)
25+
File.WriteAllText(xsltPath, @"<?xml version=""1.0""?>
26+
<xsl:stylesheet version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
27+
<xsl:output method=""xml"" indent=""yes""/>
28+
29+
<xsl:template match=""/"">
30+
<root>
31+
<xsl:call-template name=""level1""/>
32+
</root>
33+
</xsl:template>
34+
35+
<xsl:template name=""level1"">
36+
<level1>
37+
<xsl:call-template name=""level2""/>
38+
</level1>
39+
</xsl:template>
40+
41+
<xsl:template name=""level2"">
42+
<level2>Done</level2>
43+
</xsl:template>
44+
</xsl:stylesheet>");
45+
46+
File.WriteAllText(xmlPath, @"<?xml version=""1.0""?><data/>");
47+
48+
Console.WriteLine($"✓ Created test files in {testDir}\n");
49+
50+
// Test both engines
51+
await TestEngine("Compiled", new XsltCompiledEngine(), xsltPath, xmlPath);
52+
Console.WriteLine();
53+
await TestEngine("Saxon", new SaxonEngine(), xsltPath, xmlPath);
54+
55+
// Cleanup
56+
try { Directory.Delete(testDir, true); } catch { }
57+
58+
Console.WriteLine("\n=== TEST COMPLETE ===");
59+
}
60+
61+
static async Task TestEngine(string name, IXsltEngine engine, string xsltPath, string xmlPath)
62+
{
63+
Console.WriteLine($"Testing {name} Engine:");
64+
Console.WriteLine("─────────────────────────");
65+
66+
XsltEngineManager.SetDebugFlags(debug: true, LogLevel.Trace);
67+
68+
var stopCount = 0;
69+
var templateEntries = 0;
70+
71+
XsltEngineManager.EngineOutput += (output) =>
72+
{
73+
if (output.Contains("[template-entry]"))
74+
{
75+
templateEntries++;
76+
Console.WriteLine($" ✓ Template entry detected (count: {templateEntries})");
77+
}
78+
};
79+
80+
XsltEngineManager.EngineStopped += async (file, line, reason) =>
81+
{
82+
stopCount++;
83+
Console.WriteLine($" → Stop #{stopCount} at line {line} (reason: {reason})");
84+
85+
// Simulate step-into by continuing
86+
await engine.StepInAsync();
87+
};
88+
89+
await engine.StartAsync(xsltPath, xmlPath, stopOnEntry: true);
90+
await Task.Delay(500);
91+
92+
Console.WriteLine($"\n Result:");
93+
Console.WriteLine($" Total stops: {stopCount}");
94+
Console.WriteLine($" Template entries: {templateEntries}");
95+
96+
if (templateEntries >= 2)
97+
{
98+
Console.ForegroundColor = ConsoleColor.Green;
99+
Console.WriteLine($" ✓ PASS - Step-into is working!");
100+
Console.ResetColor();
101+
}
102+
else
103+
{
104+
Console.ForegroundColor = ConsoleColor.Red;
105+
Console.WriteLine($" ✗ FAIL - No template entries detected");
106+
Console.ResetColor();
107+
}
108+
}
109+
}

0 commit comments

Comments
 (0)