Make MiniYaml inherits and removal more flexible
- Previously the Inherits syntax was only resolved when used for top-level nodes. Now it is also resolved for nested nodes as well. - Previously the MiniYAML Merge feature supported the ability to remove nodes, but this only worked within the context of inherited nodes. Now, we allow node removal to work outside of the inheritance context.
This commit is contained in:
@@ -425,19 +425,23 @@ namespace OpenRA
|
||||
static void MergeIntoResolved(MiniYamlNode overrideNode, List<MiniYamlNode> existingNodes, HashSet<string> existingNodeKeys,
|
||||
Dictionary<string, MiniYaml> tree, ImmutableDictionary<string, MiniYamlNode.SourceLocation> inherited)
|
||||
{
|
||||
if (existingNodeKeys.Add(overrideNode.Key))
|
||||
var existingNodeIndex = -1;
|
||||
MiniYamlNode existingNode = null;
|
||||
if (!existingNodeKeys.Add(overrideNode.Key))
|
||||
{
|
||||
existingNodes.Add(overrideNode);
|
||||
return;
|
||||
existingNodeIndex = IndexOfKey(existingNodes, overrideNode.Key);
|
||||
existingNode = existingNodes[existingNodeIndex];
|
||||
}
|
||||
|
||||
var existingNodeIndex = IndexOfKey(existingNodes, overrideNode.Key);
|
||||
var existingNode = existingNodes[existingNodeIndex];
|
||||
var value = MergePartial(existingNode.Value, overrideNode.Value);
|
||||
var value = MergePartial(existingNode?.Value, overrideNode.Value);
|
||||
var nodes = ResolveInherits(value, tree, inherited);
|
||||
if (!value.Nodes.SequenceEqual(nodes))
|
||||
value = value.WithNodes(nodes);
|
||||
existingNodes[existingNodeIndex] = existingNode.WithValue(value);
|
||||
|
||||
if (existingNode != null)
|
||||
existingNodes[existingNodeIndex] = existingNode.WithValue(value);
|
||||
else
|
||||
existingNodes.Add(overrideNode.WithValue(value));
|
||||
}
|
||||
|
||||
static List<MiniYamlNode> ResolveInherits(MiniYaml node, Dictionary<string, MiniYaml> tree, ImmutableDictionary<string, MiniYamlNode.SourceLocation> inherited)
|
||||
|
||||
Reference in New Issue
Block a user