Skip to content

Commit 4cdee5d

Browse files
Include change from nickidw PR (Cater for end-of-file code blocks)
Including fix to format.scrub made by nickidw: jbarker7#14
1 parent 0c56bbf commit 4cdee5d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

SQLCC.Impl.MsSqlProvider/MsSqlDbTraceCodeFormatter.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,15 @@ public override string FormatCodeWithHighlights(string code, List<DbCodeSegment>
2525
{
2626
codeContents.Insert((lineOfCode.StartByte / 2) + offset, this.StartHighlightMarkUp);
2727
offset += this.StartHighlightMarkUp.Length;
28-
codeContents.Insert((lineOfCode.EndByte / 2) + offset, this.EndHighlightMarkUp);
29-
offset += this.EndHighlightMarkUp.Length;
28+
if (lineOfCode.EndByte == -1)
29+
{
30+
codeContents.Append(this.EndHighlightMarkUp);
31+
}
32+
else
33+
{
34+
codeContents.Insert((lineOfCode.EndByte / 2) + offset, this.EndHighlightMarkUp);
35+
offset += this.EndHighlightMarkUp.Length;
36+
}
3037
}
3138
return _dataScrubber.Scrub(codeContents.ToString(), "format.scrub");
3239
}

SQLCC/format.scrub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
([\s]*END(;)*[\s]*\z) {0}$1{1} Last end statement.
55
([\s]*BEGIN[\s]*)({0}) $2$1 If there is a BEGIN statement near the start of coverage, include BEGIN.
66
({1})([\s]*END[\s]*) $2$1 If there is an END statement near the end of coverage, include END.
7-
{1}([\s]*(--.*)*[\s]*(begin|end)*[\s]*(--.*)*[\s]*){0} $1 Include begin/end if it is surrounded by comments or just white-space. Also include comments.
7+
{1}([\s]*(--.*)[\s]*(begin|end)*[\s]*(--.*)[\s]*){0} $1 Include begin/end if it is surrounded by comments or just white-space. Also include comments.
88
(end)([\s]*(--.*)*[\s]*){0} $1{0}$2 Cover up until end statement.
99
(([\s]*ELSE[\s]*)[\s]*(--.*)*[\s]*){0} {0}$1 If there is an ELSE statemenet that was hit, cover this as well.
1010
{1}([\s]*(declare[\s]+.+)+[\n\r]+([\s]*declare[\s]+.+)*[\s]*) $1{1} DECLARE statements are not covered since profiler does not capture them if there is no default value.

0 commit comments

Comments
 (0)