[java] Fix false positive in UnusedImport
- When referencing static inner members of imports, false positives would be reported. - Fixes #348
This commit is contained in:
@ -86,7 +86,14 @@ public class UnusedImportsRule extends AbstractJavaRule {
|
||||
if (s != null) {
|
||||
String[] params = s.split("\\s*,\\s*");
|
||||
for (String param : params) {
|
||||
imports.remove(new ImportWrapper(param, param, new DummyJavaNode(-1)));
|
||||
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)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -261,6 +261,21 @@ public interface Interface {
|
||||
*/
|
||||
void doSomething();
|
||||
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
<test-code>
|
||||
<description>#348 False Positive UnusedImports with javadoc for public static inner classes of imports</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
import javax.swing.GroupLayout;
|
||||
|
||||
public class Foo {
|
||||
|
||||
/**
|
||||
* {@link Bar#doSomething(GroupLayout.Group)}
|
||||
*/
|
||||
void doSomething();
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Reference in New Issue
Block a user