Skip to content

Commit a4bb4d8

Browse files
committed
tweaks in support of better node groups in VSCode
1 parent c10f0f6 commit a4bb4d8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

YarnSpinner.Compiler/NodeMetadata.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@ public class NodeMetadata
1616
/// </summary>
1717
public string Title { get; set; } = string.Empty;
1818

19+
/// <summary>
20+
/// the original title as written in source (before any rewriting by NodeGroupVisitor)
21+
/// </summary>
22+
public string? SourceTitle { get; set; } = null;
23+
24+
/// <summary>
25+
/// the rewritten unique title (e.g. "Meeting.happy" or "Meeting.checksum"), set by NodeGroupVisitor
26+
/// </summary>
27+
public string? UniqueTitle { get; set; } = null;
28+
29+
/// <summary>
30+
/// the node group name (equals sourceTitle when when: headers exist, null otherwise)
31+
/// </summary>
32+
public string? NodeGroup { get; set; } = null;
33+
1934
/// <summary>
2035
/// the subtitle of the node (optional)
2136
/// </summary>

YarnSpinner.Compiler/Visitors/NodeMetadataVisitor.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ public override object VisitNode([NotNull] YarnSpinnerParser.NodeContext context
7878
// Visit children to extract all the metadata.
7979
base.VisitNode(context);
8080

81+
// Populate node group fields from the parse context.
82+
// NodeGroupVisitor runs before NodeMetadataVisitor, so these are already set.
83+
currentNode.SourceTitle = currentNode.Title; // Always the original title: header value
84+
currentNode.UniqueTitle = context.NodeTitle; // Rewritten by NodeGroupVisitor
85+
currentNode.NodeGroup = context.NodeGroup; // Set by NodeGroupVisitor (null if not grouped)
86+
8187
// Only add nodes that have a title.
8288
if (!string.IsNullOrWhiteSpace(currentNode.Title))
8389
{

0 commit comments

Comments
 (0)