Skip to content

Commit 6e1bee4

Browse files
committed
Temporarily make variables with spaces that are not found hints, we used to not do anything here
1 parent ad4d342 commit 6e1bee4

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

src/Elastic.Markdown/Diagnostics/ProcessorDiagnosticExtensions.cs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,24 @@ public static class ProcessorDiagnosticExtensions
1414
{
1515
private static string CreateExceptionMessage(string message, Exception? e) => message + (e != null ? Environment.NewLine + e : string.Empty);
1616

17-
public static void EmitError(this InlineProcessor processor, int line, int column, int length, string message)
18-
{
19-
var context = processor.GetContext();
20-
if (context.SkipValidation)
21-
return;
22-
var d = new Diagnostic
23-
{
24-
Severity = Severity.Error,
25-
File = processor.GetContext().MarkdownSourcePath.FullName,
26-
Column = column,
27-
Line = line,
28-
Message = message,
29-
Length = length
30-
};
31-
context.Build.Collector.Write(d);
32-
}
17+
public static void EmitError(this InlineProcessor processor, int line, int column, int length, string message) =>
18+
processor.Emit(Severity.Error, line, column, length, message);
3319

3420

35-
public static void EmitWarning(this InlineProcessor processor, int line, int column, int length, string message)
21+
public static void EmitWarning(this InlineProcessor processor, int line, int column, int length, string message) =>
22+
processor.Emit(Severity.Warning, line, column, length, message);
23+
24+
public static void EmitHint(this InlineProcessor processor, int line, int column, int length, string message) =>
25+
processor.Emit(Severity.Hint, line, column, length, message);
26+
27+
public static void Emit(this InlineProcessor processor, Severity severity, int line, int column, int length, string message)
3628
{
3729
var context = processor.GetContext();
3830
if (context.SkipValidation)
3931
return;
4032
var d = new Diagnostic
4133
{
42-
Severity = Severity.Warning,
34+
Severity = severity,
4335
File = processor.GetContext().MarkdownSourcePath.FullName,
4436
Column = column,
4537
Line = line,

src/Elastic.Markdown/Myst/InlineParsers/Substitution/SubstitutionParser.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Text;
1010
using System.Text.Json;
1111
using Elastic.Documentation;
12+
using Elastic.Documentation.Diagnostics;
1213
using Elastic.Markdown.Diagnostics;
1314
using Markdig.Helpers;
1415
using Markdig.Parsers;
@@ -209,7 +210,8 @@ public override bool Match(InlineProcessor processor, ref StringSlice slice)
209210
};
210211

211212
if (!found)
212-
processor.EmitError(line + 1, column + 3, substitutionLeaf.Span.Length - 3, $"Substitution key {{{key}}} is undefined");
213+
// We temporarily diagnose variable spaces as hints. We used to not read this at all.
214+
processor.Emit(key.Contains(' ') ? Severity.Error : Severity.Hint, line + 1, column + 3, substitutionLeaf.Span.Length - 3, $"Substitution key {{{key}}} is undefined");
213215
else
214216
{
215217
List<SubstitutionMutation>? mutations = null;

0 commit comments

Comments
 (0)