-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes/branch logic improvements #239
Changes from all commits
275a9f8
0cf2166
61cd634
b7d8e25
6fdb337
3e1b896
15cea07
95a139f
c3e440b
19fb20b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -11,7 +11,7 @@ | |||||||||
{ | ||||||||||
try | ||||||||||
{ | ||||||||||
var (diff, arrow_line) = DiffError(t, doc); | ||||||||||
var (diff, arrow_line) = DiffError(t, doc.SourceLines); | ||||||||||
if (diff is null && arrow_line is null) | ||||||||||
return ""; | ||||||||||
return $"\n\t[grey] {diff.EscapeMarkup().EscapeArgumentSymbols()} [/]\n\t[red] {arrow_line.EscapeMarkup().EscapeArgumentSymbols()} [/]"; | ||||||||||
|
@@ -22,15 +22,32 @@ | |||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
private static (string line, string arrow_line) NewDiffError(Transform t, DocumentDeclaration doc) | ||||||||||
public static string DiffErrorFull(this Transform t, FileInfo doc) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add missing import for The + using System.IO; Committable suggestion
Suggested change
ToolsGitHub Check: build_all (ubuntu-latest, linux-x64, true)
|
||||||||||
{ | ||||||||||
if (doc is null) | ||||||||||
try | ||||||||||
{ | ||||||||||
var (diff, arrow_line) = DiffError(t, doc.ReadAllLines()); | ||||||||||
if (diff is null && arrow_line is null) | ||||||||||
return ""; | ||||||||||
return $"\n\t[grey] {diff.EscapeMarkup().EscapeArgumentSymbols()} [/]\n\t[red] {arrow_line.EscapeMarkup().EscapeArgumentSymbols()} [/]"; | ||||||||||
} | ||||||||||
catch | ||||||||||
{ | ||||||||||
return ""; // TODO analytic | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
private static (string line, string arrow_line) NewDiffError(Transform t, string[] sourceLines) | ||||||||||
{ | ||||||||||
if (sourceLines is null) | ||||||||||
return default; | ||||||||||
if (sourceLines.Length == 0) | ||||||||||
return default; | ||||||||||
var line = doc.SourceLines[t.pos.Line].Length < t.len ? | ||||||||||
var line = sourceLines[t.pos.Line - 1].Length < t.len ? | ||||||||||
t.pos.Line : | ||||||||||
t.pos.Line - 1; | ||||||||||
|
||||||||||
var original = doc.SourceLines[line]; | ||||||||||
var original = sourceLines[line - 1]; | ||||||||||
|
||||||||||
int takeLen() | ||||||||||
{ | ||||||||||
|
@@ -48,25 +65,27 @@ | |||||||||
$"{new string(' ', space1.Length)}{new string('^', err_line.Length)}{new string(' ', space2.Length)}"); | ||||||||||
} | ||||||||||
|
||||||||||
public static (string line, string arrow_line) DiffError(this Transform t, DocumentDeclaration doc) | ||||||||||
public static (string line, string arrow_line) DiffError(this Transform t, string[] sourceLines) | ||||||||||
{ | ||||||||||
try | ||||||||||
{ | ||||||||||
return NewDiffError(t, doc); | ||||||||||
return NewDiffError(t, sourceLines); | ||||||||||
} | ||||||||||
catch { } | ||||||||||
|
||||||||||
var line = doc.SourceLines[t.pos.Line].Length < t.len ? | ||||||||||
var line = sourceLines[t.pos.Line].Length < t.len ? | ||||||||||
t.pos.Line - 1 : | ||||||||||
/*t.pos.Line*/throw new Exception("cannot detect line"); | ||||||||||
|
||||||||||
var original = doc.SourceLines[line]; | ||||||||||
var original = sourceLines[line]; | ||||||||||
var err_line = original[(t.pos.Column - 1)..]; | ||||||||||
var space1 = original[..(t.pos.Column - 1)]; | ||||||||||
var space2 = (t.pos.Column - 1) + t.len > original.Length ? "" : original[((t.pos.Column - 1) + t.len)..]; | ||||||||||
|
||||||||||
return (original, | ||||||||||
$"{new string(' ', space1.Length)}{new string('^', err_line.Length)}{new string(' ', space2.Length)}"); | ||||||||||
} | ||||||||||
|
||||||||||
|
||||||||||
} | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure consistent error handling.
The method
_print
is used in different ways, which could lead to inconsistencies in how logs are handled. Consider standardizing the input parameters and the way errors are logged.Committable suggestion