use of net.sourceforge.pmd.lang.rule.ImportWrapper in project pmd by pmd.
the class UnusedImportsRule method visitComments.
private void visitComments(ASTCompilationUnit node) {
if (imports.isEmpty()) {
return;
}
for (Comment comment : node.getComments()) {
if (!(comment instanceof FormalComment)) {
continue;
}
for (Pattern p : PATTERNS) {
Matcher m = p.matcher(comment.getImage());
while (m.find()) {
String s = m.group(1);
imports.remove(new ImportWrapper(s, s, new DummyJavaNode(-1)));
if (m.groupCount() > 1) {
s = m.group(2);
if (s != null) {
String[] params = s.split("\\s*,\\s*");
for (String param : params) {
final int firstDot = param.indexOf('.');
final String expectedImportName;
if (firstDot == -1) {
expectedImportName = param;
} else {
expectedImportName = param.substring(0, firstDot);
}
imports.remove(new ImportWrapper(param, expectedImportName, new DummyJavaNode(-1)));
}
}
}
if (imports.isEmpty()) {
return;
}
}
}
}
}
Aggregations