Skip to content

Commit

Permalink
[generator] Avoid 'error (…):' construct in diagnostic messages (#851)
Browse files Browse the repository at this point in the history
Context: #850

When a parsing issue is hit when importing Javadoc info, an "error"
is printed out like this:

	Error (31:41): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docroot}, {@inheritdoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, </tt>, </TT>, </i>, </I>, </p>, </P>, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @Serialdata, @serialField, @SInCE, @throws, @[unknown], @Version
	    {@link #getCurrentTrackSelections()}}.</li>

This is intended to be informational, but this output format triggers
the MSBuild error parsing regex, and is interpreted as an actual
error, causing the build to fail.

Avoid the error by prepending `JavadocImport-` to the
`LogMessage.Level` enum value, so that MSBuild doesn't interpret the
string as an error and the build can successfully complete:

	JavadocImport-Error (31:41): Syntax error, expected: #PCDATA, <tt>, <TT>, <i>, <I>, {@code, {@docroot}, {@inheritdoc}, {@link, {@linkplain, {@literal, {@value}, {@value, UnknownHtmlElementStart, </tt>, </TT>, </i>, </I>, </p>, </P>, <p>, <P>, <pre>, <PRE>, @author, @apiSince, @deprecated, @deprecatedSince, @exception, @param, @return, @see, @Serialdata, @serialField, @SInCE, @throws, @[unknown], @Version
	    {@link #getCurrentTrackSelections()}}.</li>
  • Loading branch information
jpobst authored Jun 15, 2021
1 parent 7c4f7db commit 95c9b79
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ static void PrintMessages (ParseTree tree, TextWriter writer)
{
var lines = GetLines (tree.SourceText);
foreach (var m in tree.ParserMessages) {
writer.WriteLine ($"{m.Level} {m.Location}: {m.Message}");
writer.WriteLine ($"JavadocImport-{m.Level} {m.Location}: {m.Message}");
writer.WriteLine (lines [m.Location.Line]);
writer.Write (new string (' ', m.Location.Column));
writer.WriteLine ("^");
Expand Down

0 comments on commit 95c9b79

Please sign in to comment.