Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MJAVADOC-657] The fix operation duplicates annotations on private methods that have an annotation line between the method body and the javadoc comments. #52

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1052,9 +1052,13 @@ else if ( lineNumber == javaClass.getLineNumber() )
{
if ( lineNumber == method.getLineNumber() )
{
changeDetected |= fixMethodComment( stringWriter, originalContent, method, indent );

takeCareSingleComment( stringWriter, originalContent, method );
final boolean commentUpdated =
fixMethodComment( stringWriter, originalContent, method, indent );
if ( commentUpdated )
{
takeCareSingleComment( stringWriter, originalContent, method );
}
changeDetected |= commentUpdated;
}
}
}
Expand All @@ -1075,9 +1079,13 @@ else if ( lineNumber == javaClass.getLineNumber() )

if ( lineNumber == methodLineNumber )
{
changeDetected |= fixMethodComment( stringWriter, originalContent, method, indent );

takeCareSingleComment( stringWriter, originalContent, method );
final boolean commentUpdated =
fixMethodComment( stringWriter, originalContent, method, indent );
if ( commentUpdated )
{
takeCareSingleComment( stringWriter, originalContent, method );
}
changeDetected |= commentUpdated;
}
}

Expand Down
Expand Up @@ -25,6 +25,7 @@
* @author <a href="mailto:vsiveton@apache.org">vsiveton@apache.org</a>
* @version $Id: $
*/
@SuppressWarnings("SameReturnValue")
public class ClassWithJavadoc
implements InterfaceWithJavadoc
{
Expand All @@ -44,6 +45,25 @@ public ClassWithJavadoc( String aString )
{
}

/**
* public constructor with annotation
*
* @param b a {@link java.lang.Boolean} object.
XenoAmess marked this conversation as resolved.
Show resolved Hide resolved
* @since 1.1
*/
@SuppressWarnings("SameReturnValue")
public ClassWithJavadoc( Boolean b )
{
}

/**
* private constructor with annotation
*/
@SuppressWarnings("SameReturnValue")
private ClassWithJavadoc( Integer i )
{
}

/**
* Spaces in tags.
*
Expand Down Expand Up @@ -298,4 +318,52 @@ public static class MyRuntimeException
extends RuntimeException
{
}

/**
* private method with annotation
*/
@SuppressWarnings("SameReturnValue")
private void t000()
{
return;
}

/**
* private method with line comment
*/
//test comment
private void t001()
{
return;
}

/**
* public method with annotation
*
* @since 1.1
*/
@SuppressWarnings("SameReturnValue")
public void t010()
{
return;
}

/**
* public method with annotation
*
* @since 1.1
*/
//test comment
public void t011()
{
return;
}
}

/**
* To test package class
*/
@SuppressWarnings("SameReturnValue")
class PrivateTestClassWithJavadoc
{
}
Expand Up @@ -27,6 +27,7 @@
* @author <a href="mailto:vsiveton@apache.org">vsiveton@apache.org</a>
* @version $Id: $
*/
@SuppressWarnings("SameReturnValue")
public class ClassWithNoJavadoc
implements InterfaceWithNoJavadoc
{
Expand Down Expand Up @@ -69,6 +70,22 @@ public ClassWithNoJavadoc( String aString )
{
}

@SuppressWarnings("SameReturnValue")
/**
* <p>Constructor for ClassWithNoJavadoc.</p>
*
* @param b a {@link java.lang.Boolean} object.
* @since 1.1
XenoAmess marked this conversation as resolved.
Show resolved Hide resolved
*/
public ClassWithNoJavadoc( Boolean b )
{
}

@SuppressWarnings("SameReturnValue")
private ClassWithNoJavadoc( Integer i )
{
}

// take care of primitive
/**
* <p>missingJavadocTagsForPrimitives.</p>
Expand Down Expand Up @@ -154,4 +171,39 @@ public void nothing()
{
}
}

@SuppressWarnings("SameReturnValue")
private void t000() {
return;
}

//test comment
private void t001() {
return;
}

/**
* <p>t010.</p>
*
* @since 1.1
*/
@SuppressWarnings("SameReturnValue")
public void t010() {
return;
}

//test comment
/**
* <p>t011.</p>
*
* @since 1.1
*/
public void t011() {
return;
}
}

@SuppressWarnings("SameReturnValue")
class PrivateTestClassWithNoJavadoc
{
}
4 changes: 2 additions & 2 deletions src/test/resources/unit/fix-test/pom.xml
Expand Up @@ -27,8 +27,8 @@
<packaging>jar</packaging>

<properties>
<maven.compiler.source>1.4</maven.compiler.source>
<maven.compiler.target>1.4</maven.compiler.target>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>
</properties>

<build>
Expand Down
Expand Up @@ -22,6 +22,7 @@
/**
* To add default class tags.
*/
@SuppressWarnings("SameReturnValue")
public class ClassWithJavadoc
implements InterfaceWithJavadoc
{
Expand All @@ -39,6 +40,22 @@ public ClassWithJavadoc( String aString )
{
}

/**
* public constructor with annotation
*/
@SuppressWarnings("SameReturnValue")
public ClassWithJavadoc( Boolean b )
{
}

/**
* private constructor with annotation
*/
@SuppressWarnings("SameReturnValue")
private ClassWithJavadoc( Integer i )
{
}

/**
* Spaces in tags.
*
Expand Down Expand Up @@ -282,4 +299,48 @@ public static class MyRuntimeException
extends RuntimeException
{
}

/**
* private method with annotation
*/
@SuppressWarnings("SameReturnValue")
private void t000()
{
return;
}

/**
* private method with line comment
*/
//test comment
private void t001()
{
return;
}

/**
* public method with annotation
*/
@SuppressWarnings("SameReturnValue")
public void t010()
{
return;
}

/**
* public method with annotation
*/
//test comment
public void t011()
{
return;
}
}

/**
* To test package class
*/
@SuppressWarnings("SameReturnValue")
class PrivateTestClassWithJavadoc
{
}
Expand Up @@ -21,6 +21,7 @@

import java.util.Map;

@SuppressWarnings("SameReturnValue")
public class ClassWithNoJavadoc
implements InterfaceWithNoJavadoc
{
Expand Down Expand Up @@ -49,6 +50,16 @@ public ClassWithNoJavadoc( String aString )
{
}

@SuppressWarnings("SameReturnValue")
public ClassWithNoJavadoc( Boolean b )
{
}

@SuppressWarnings("SameReturnValue")
private ClassWithNoJavadoc( Integer i )
{
}

// take care of primitive
public void missingJavadocTagsForPrimitives( int i, byte b, float f, char c, short s, long l, double d, boolean bb )
{
Expand Down Expand Up @@ -106,4 +117,29 @@ public void nothing()
{
}
}

@SuppressWarnings("SameReturnValue")
private void t000() {
return;
}

//test comment
private void t001() {
return;
}

@SuppressWarnings("SameReturnValue")
public void t010() {
return;
}

//test comment
public void t011() {
return;
}
}

@SuppressWarnings("SameReturnValue")
class PrivateTestClassWithNoJavadoc
{
}