Improve linting of weapon and trait yaml removals.

This commit is contained in:
Paul Chote
2019-05-04 18:39:09 +01:00
committed by abcdefg30
parent 2a7ea28b74
commit fb075dc803
2 changed files with 16 additions and 6 deletions

View File

@@ -32,10 +32,15 @@ namespace OpenRA.Mods.Common.Lint
{
foreach (var t in actor.Value.Nodes)
{
// Removals can never define children
if (t.Key.StartsWith("-", StringComparison.Ordinal) && t.Value.Nodes.Any())
// Removals can never define children or values
if (t.Key.StartsWith("-", StringComparison.Ordinal))
{
emitError("{0} defines child nodes, which are not valid for removals.".F(t.Location));
if (t.Value.Nodes.Any())
emitError("{0} {1} defines child nodes, which are not valid for removals.".F(t.Location, t.Key));
if (!string.IsNullOrEmpty(t.Value.Value))
emitError("{0} {1} defines a value, which is not valid for removals.".F(t.Location, t.Key));
continue;
}

View File

@@ -34,10 +34,15 @@ namespace OpenRA.Mods.Common.Lint
{
foreach (var field in weapon.Value.Nodes)
{
// Removals can never define children
if (field.Key.StartsWith("-", StringComparison.Ordinal) && field.Value.Nodes.Any())
// Removals can never define children or values
if (field.Key.StartsWith("-", StringComparison.Ordinal))
{
emitError("{0} has child nodes, which is not valid for removals.".F(field.Key));
if (field.Value.Nodes.Any())
emitError("{0} {1} defines child nodes, which is not valid for removals.".F(field.Location, field.Key));
if (!string.IsNullOrEmpty(field.Value.Value))
emitError("{0} {1} defines a value, which is not valid for removals.".F(field.Location, field.Key));
continue;
}