Skip to content

Commit 5ba168f

Browse files
committed
Add a ctor overload in Range. Adjust ctor parameter order in Diagnostic.
1 parent df56ee4 commit 5ba168f

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

DemoLanguageServer/DiagnosticProvider.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public ICollection<Diagnostic> LintDocument(TextDocument document, int maxNumber
2626
{
2727
diag.Add(new Diagnostic(DiagnosticSeverity.Hint,
2828
new Range(new Position(0, 0), document.PositionAt(content?.Length ?? 0)),
29-
"DLS0001", "Empty document. Try typing something, such as \".net core\".", "DLS"));
29+
"DLS", "DLS0001", "Empty document. Try typing something, such as \".net core\"."));
3030
return diag;
3131
}
3232
foreach (var kw in Keywords)
@@ -43,13 +43,11 @@ public ICollection<Diagnostic> LintDocument(TextDocument document, int maxNumber
4343
if (inputKw != kw)
4444
{
4545
diag.Add(new Diagnostic(DiagnosticSeverity.Warning,
46-
new Range(document.PositionAt(pos), document.PositionAt(separatorPos)),
47-
"DLS1001", $"\"{inputKw}\" should be \"{kw}\".", "DLS"));
46+
new Range(document.PositionAt(pos), document.PositionAt(separatorPos)), "DLS", "DLS1001", $"\"{inputKw}\" should be \"{kw}\"."));
4847
if (diag.Count >= maxNumberOfProblems)
4948
{
5049
diag.Add(new Diagnostic(DiagnosticSeverity.Information,
51-
new Range(document.PositionAt(pos), document.PositionAt(separatorPos)),
52-
"DLS2001", "Too many messages, exiting…", "DLS"));
50+
new Range(document.PositionAt(pos), document.PositionAt(separatorPos)), "DLS", "DLS2001", "Too many messages, exiting…"));
5351
return diag;
5452
}
5553
}

LanguageServer.VsCode/Contracts/Diagnostic.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ public Diagnostic()
4747
{
4848
}
4949

50-
public Diagnostic(DiagnosticSeverity severity, Range range, string code, string message) : this(severity, range, code, message, null)
50+
public Diagnostic(DiagnosticSeverity severity, Range range, string source, string message) : this(severity, range, source, null, message)
5151
{
5252
}
5353

54-
public Diagnostic(DiagnosticSeverity severity, Range range, string code, string message, string source)
54+
public Diagnostic(DiagnosticSeverity severity, Range range, string source, string code, string message)
5555
{
5656
Severity = severity;
5757
Range = range;
58+
Source = source;
5859
Code = code;
5960
Message = message;
60-
Source = source;
6161
}
6262

6363
/// <summary>

LanguageServer.VsCode/Contracts/Location.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ public Range(Position start, Position end)
5757
End = end;
5858
}
5959

60+
public Range(int startLine, int startCharacter, int endLine, int endCharacter)
61+
{
62+
Start = new Position(startLine, startCharacter);
63+
End = new Position(endLine, endCharacter);
64+
}
65+
6066
public Position Start { get; set; }
6167

6268
public Position End { get; set; }

0 commit comments

Comments
 (0)