use of edu.umd.cs.findbugs.filter.CompoundMatcher in project spotbugs by spotbugs.
the class SAXBugCollectionHandler method addMatcher.
private void addMatcher(Matcher m) {
if (m == null) {
throw new IllegalArgumentException("matcher must not be null");
}
CompoundMatcher peek = matcherStack.peek();
if (peek == null) {
throw new NullPointerException("Top of stack is null");
}
peek.addChild(m);
if (nextMatchedIsDisabled) {
if (peek instanceof Filter) {
((Filter) peek).disable(m);
} else {
assert false;
}
nextMatchedIsDisabled = false;
}
}
use of edu.umd.cs.findbugs.filter.CompoundMatcher in project spotbugs by spotbugs.
the class SAXBugCollectionHandler method parseMatcher.
private void parseMatcher(String qName, Attributes attributes) throws SAXException {
if (DEBUG) {
System.out.println(elementStack + " " + qName + " " + matcherStack);
}
String disabled = getOptionalAttribute(attributes, "disabled");
nextMatchedIsDisabled = "true".equals(disabled);
if ("Bug".equals(qName)) {
addMatcher(new BugMatcher(getOptionalAttribute(attributes, "code"), getOptionalAttribute(attributes, "pattern"), getOptionalAttribute(attributes, "category")));
} else if ("Class".equals(qName)) {
String role = getOptionalAttribute(attributes, "role");
addMatcher(new ClassMatcher(getRequiredAttribute(attributes, "name", qName), role));
} else if ("Type".equals(qName)) {
String role = getOptionalAttribute(attributes, "role");
String typeParameters = getOptionalAttribute(attributes, "typeParameters");
addMatcher(new TypeMatcher(getRequiredAttribute(attributes, "descriptor", qName), role, typeParameters));
} else if ("FirstVersion".equals(qName)) {
addMatcher(new FirstVersionMatcher(getRequiredAttribute(attributes, "value", qName), getRequiredAttribute(attributes, "relOp", qName)));
} else if ("LastVersion".equals(qName)) {
addMatcher(new LastVersionMatcher(getRequiredAttribute(attributes, "value", qName), getRequiredAttribute(attributes, "relOp", qName)));
} else if ("BugCode".equals(qName)) {
addMatcher(new BugMatcher(getRequiredAttribute(attributes, "name", qName), "", ""));
} else if ("Local".equals(qName)) {
addMatcher(new LocalMatcher(getRequiredAttribute(attributes, "name", qName)));
} else if ("BugPattern".equals(qName)) {
addMatcher(new BugMatcher("", getRequiredAttribute(attributes, "name", qName), ""));
} else if ("Priority".equals(qName)) {
addMatcher(new PriorityMatcher(getRequiredAttribute(attributes, "value", qName)));
} else if ("Confidence".equals(qName)) {
addMatcher(new ConfidenceMatcher(getRequiredAttribute(attributes, "value", qName)));
} else if ("Rank".equals(qName)) {
addMatcher(new RankMatcher(getRequiredAttribute(attributes, "value", qName)));
} else if ("Package".equals(qName)) {
String pName = getRequiredAttribute(attributes, "name", qName);
pName = pName.startsWith("~") ? pName : "~" + pName.replace(".", "\\.");
addMatcher(new ClassMatcher(pName + "\\.[^.]+"));
} else if ("Method".equals(qName)) {
String name = getOptionalAttribute(attributes, "name");
String params = getOptionalAttribute(attributes, "params");
String returns = getOptionalAttribute(attributes, "returns");
String role = getOptionalAttribute(attributes, "role");
addMatcher(new MethodMatcher(name, params, returns, role));
} else if ("Field".equals(qName)) {
String name = getOptionalAttribute(attributes, "name");
String type = getOptionalAttribute(attributes, "type");
String role = getOptionalAttribute(attributes, "role");
addMatcher(new FieldMatcher(name, type, role));
} else if ("Or".equals(qName)) {
CompoundMatcher matcher = new OrMatcher();
pushCompoundMatcherAsChild(matcher);
} else if ("And".equals(qName) || "Match".equals(qName)) {
AndMatcher matcher = new AndMatcher();
pushCompoundMatcherAsChild(matcher);
if ("Match".equals(qName)) {
String classregex = getOptionalAttribute(attributes, "classregex");
String classMatch = getOptionalAttribute(attributes, "class");
if (classregex != null) {
addMatcher(new ClassMatcher("~" + classregex));
} else if (classMatch != null) {
addMatcher(new ClassMatcher(classMatch));
}
}
} else if ("Not".equals(qName)) {
NotMatcher matcher = new NotMatcher();
pushCompoundMatcherAsChild(matcher);
} else if ("Source".equals(qName)) {
addMatcher(new SourceMatcher(getRequiredAttribute(attributes, "name", qName)));
}
nextMatchedIsDisabled = false;
}
Aggregations