diff --git a/src/main/java/com/askimed/nf/test/core/TagQuery.java b/src/main/java/com/askimed/nf/test/core/TagQuery.java index b960b12f..802a0aae 100644 --- a/src/main/java/com/askimed/nf/test/core/TagQuery.java +++ b/src/main/java/com/askimed/nf/test/core/TagQuery.java @@ -34,12 +34,36 @@ public boolean matches(ITaggable taggable) { return true; } - if (tags.contains(taggable.getName().toLowerCase())) { + // Separate positive and negative tags + List positiveTags = new Vector(); + List negativeTags = new Vector(); + + for (String tag : tags) { + if (tag.startsWith("!")) { + negativeTags.add(tag.substring(1).toLowerCase()); // Remove '!' prefix for negative tags + } else { + positiveTags.add(tag.toLowerCase()); + } + } + + // Check for negative matches + if (negativeTags.contains(taggable.getName().toLowerCase())) { + return false; + } + + for (String tag : taggable.getTags()) { + if (negativeTags.contains(tag.toLowerCase())) { + return false; + } + } + + // Check for positive matches + if (positiveTags.contains(taggable.getName().toLowerCase())) { return true; } for (String tag : taggable.getTags()) { - if (tags.contains(tag.toLowerCase())) { + if (positiveTags.contains(tag.toLowerCase())) { return true; } } @@ -48,12 +72,11 @@ public boolean matches(ITaggable taggable) { return matches(taggable.getParent()); } - return false; + return !negativeTags.isEmpty(); } @Override public String toString() { return tags.toString(); } - }