Merge branch 'bug-1465' into pmd/5.4.x

This commit is contained in:
Andreas Dangel
2016-02-27 19:37:39 +01:00
4 changed files with 47 additions and 2 deletions

View File

@ -49,14 +49,15 @@ public class UnusedImportsRule extends AbstractJavaRule {
* @see package.class#member(param, param) label
* {@linkplain package.class#member(param, param) label}
* {@link package.class#member(param, param) label}
* {@link package.class#field}
* {@value package.class#field}
* @throws package.class label
*/
private static final Pattern SEE_PATTERN = Pattern.compile(
"@see\\s+(\\p{Alpha}\\p{Alnum}*)(?:#\\p{Alnum}*\\(([\\w\\s,]*)\\))?");
"@see\\s+(\\p{Alpha}\\p{Alnum}*)(?:#\\p{Alnum}*(?:\\(([\\w\\s,]*)\\))?)?");
private static final Pattern LINK_PATTERNS = Pattern.compile(
"\\{@link(?:plain)?\\s+(\\p{Alpha}\\p{Alnum}*)(?:#\\p{Alnum}*\\(([.\\w\\s,]*)\\))?[\\s\\}]");
"\\{@link(?:plain)?\\s+(\\p{Alpha}\\p{Alnum}*)(?:#\\p{Alnum}*(?:\\(([.\\w\\s,]*)\\))?)?[\\s\\}]");
private static final Pattern VALUE_PATTERN = Pattern.compile(
"\\{@value\\s+(\\p{Alpha}\\p{Alnum}*)[\\s#\\}]");

View File

@ -290,6 +290,27 @@ public class FooTest {
public static void main(String[] args) {
System.out.println(PI);
}
}
]]></code>
</test-code>
<test-code>
<description>#1465 False Positve UnusedImports with javadoc @link</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import a.b.c.d.AgentState;
import a.b.c.d.OtherState;
public interface Foo {
/**
* Gets all active AgentHandles.
* <p/>
* An agent is active if it has not posted a {@link AgentStateChangeEvent} containing {@link AgentState#TERMINATED}.
*
* @return agent handles.
* @see OtherState#TERMINATED
*/
Iterable<AgentHandle> getAgentHandles();
}
]]></code>
</test-code>

View File

@ -212,6 +212,27 @@ public class FooTest {
public static void main(String[] args) {
System.out.println(PI);
}
}
]]></code>
</test-code>
<test-code>
<description>#1465 False Positve UnusedImports with javadoc @link</description>
<expected-problems>0</expected-problems>
<code><![CDATA[
import a.b.c.d.AgentState;
import a.b.c.d.OtherState;
public interface Foo {
/**
* Gets all active AgentHandles.
* <p/>
* An agent is active if it has not posted a {@link AgentStateChangeEvent} containing {@link AgentState#TERMINATED}.
*
* @return agent handles.
* @see OtherState#TERMINATED
*/
Iterable<AgentHandle> getAgentHandles();
}
]]></code>
</test-code>