query method
Implementation
dynamic query(NodeQuery query, {int? maxDepth}) {
NodeV3? k = this;
int currentDepth = 0;
while (k != null) {
if (k.tag != null) {
if (query.includedTypes.contains(QueryType.tag)) {
if (query.includedValues.contains(k.tag!.name)) {
return k.tag!.name;
}
}
if (query.includedTypes.contains(QueryType.property)) {
List<String> intersection = List<String>.from(query.includedValues);
intersection.removeWhere(
(element) => !k!.tag!.properties.containsKey(element),
);
if (intersection.isNotEmpty) {
return k.tag!.properties[intersection.first];
}
}
if (query.includedTypes.contains(QueryType.styleProperty)) {
List<String> intersection = List<String>.from(query.includedValues);
intersection.removeWhere(
(element) => !k!.tag!.styleProperties.containsKey(element),
);
if (intersection.isNotEmpty) {
return k.tag!.styleProperties[intersection.first];
}
}
}
k = k.parent;
currentDepth++;
if (currentDepth == maxDepth) {
return null;
}
}
}