Skip to content

Commit ab4ed10

Browse files
committed
Store ranges in LineInfos, not Positions
1 parent f355ba3 commit ab4ed10

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1212

1313
- Complexity scoring for `when:` headers no longer counts `not` operations. This means that `when: $x` and `when: not $x` have the same score of 1.
1414
- `VirtualMachine.ContentSaliencyStrategy` now defaults to `RandomBestLeastRecentlyViewed`, not `First`
15+
- `NodeDebugInfo.LineInfo` now stores ranges of text, rather than just the start position.
1516

1617
### Removed
1718

YarnSpinner.Compiler/DebugInfo.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,13 @@ internal void AddLabel(string label, int instructionIndex)
139139
/// number of instructions present in the node.</exception>
140140
public LineInfo GetLineInfo(int instructionNumber)
141141
{
142-
if (this.LineRanges.TryGetValue(instructionNumber, out var info))
142+
if (this.LineRanges.TryGetValue(instructionNumber, out var range))
143143
{
144144
return new LineInfo
145145
{
146146
FileName = this.FileName,
147147
NodeName = this.NodeName,
148-
Position = new Position(
149-
info.Start.Line,
150-
info.Start.Character
151-
),
148+
Range = range,
152149
};
153150
}
154151
else
@@ -175,10 +172,10 @@ public struct LineInfo
175172
public string NodeName;
176173

177174
/// <summary>
178-
/// The position in <see cref="FileName"/> that contains the
175+
/// The range in <see cref="FileName"/> that contains the
179176
/// statement or expression that this line was produced from.
180177
/// </summary>
181-
public Position Position;
178+
public Range Range;
182179
}
183180
}
184181
}

YarnSpinner.Tests/ProjectTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,8 @@ public void TestDebugOutputIsProduced()
406406

407407
firstLineInfo.FileName.Should().Be("input");
408408
firstLineInfo.NodeName.Should().Be("DebugTesting");
409-
firstLineInfo.Position.Line.Should().Be(2);
410-
firstLineInfo.Position.Character.Should().Be(0);
409+
firstLineInfo.Range.Start.Line.Should().Be(2);
410+
firstLineInfo.Range.Start.Character.Should().Be(0);
411411
}
412412
}
413413
}

0 commit comments

Comments
 (0)