Fixed bug where enum constants were causing NPE in Javadoc style check because enum constants have no explicit modifiers.

This commit is contained in:
Michael Studman 2004-12-19 23:05:21 +00:00
parent 06b377b34c
commit c83b8eeeac
3 changed files with 30 additions and 2 deletions

View File

@ -138,8 +138,17 @@ public class JavadocStyleCheck
return false;
}
final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS);
final Scope declaredScope = ScopeUtils.getScopeFromMods(mods);
final Scope declaredScope;
if (aAST.getType() == TokenTypes.ENUM_CONSTANT_DEF)
{
declaredScope = Scope.PUBLIC;
}
else
{
declaredScope = ScopeUtils.getScopeFromMods(
aAST.findFirstToken(TokenTypes.MODIFIERS));
}
final Scope scope =
ScopeUtils.inInterfaceOrAnnotationBlock(aAST)
? Scope.PUBLIC : declaredScope;

View File

@ -231,4 +231,18 @@ public class InputJavadocStyleCheck
public void method19()
{ // should report empty javadoc (no text before see tag)
}
public enum Test
//Should complain about no javadoc
{
/**
* Value 1 without a period
*/
value1,
/**
* Value 2 with a period.
*/
value2,
}
}

View File

@ -29,6 +29,7 @@ public class JavadocStyleCheckTest
"109:39: Extra HTML tag found: </img>",
"186:8: Unclosed HTML tag found: <blockquote>",
"193: First sentence should end with a period.",
"238: First sentence should end with a period.",
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -48,6 +49,7 @@ public class JavadocStyleCheckTest
"81: First sentence should end with a period.",
"88: First sentence should end with a period.",
"193: First sentence should end with a period.",
"238: First sentence should end with a period.",
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -90,6 +92,7 @@ public class JavadocStyleCheckTest
"90: Incomplete HTML tag found: * should fail <",
"205: Javadoc has empty description section.",
"230: Javadoc has empty description section.",
"238: First sentence should end with a period.",
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -114,6 +117,7 @@ public class JavadocStyleCheckTest
"205: Javadoc has empty description section.",
"211: Javadoc has empty description section.",
"230: Javadoc has empty description section.",
"238: First sentence should end with a period.",
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);
@ -141,6 +145,7 @@ public class JavadocStyleCheckTest
"211: Javadoc has empty description section.",
"218: Javadoc has empty description section.",
"230: Javadoc has empty description section.",
"238: First sentence should end with a period.",
};
verify(checkConfig, getPath("InputJavadocStyleCheck.java"), expected);