Fix for 3429775: DeclarationOrder should handle ignoreModifiers correctly (all fields should be before ctors and methods)
This commit is contained in:
parent
b07beaaae4
commit
b30ed9fc87
|
|
@ -158,7 +158,9 @@ public class DeclarationOrderCheck extends Check
|
|||
state = mScopeStates.peek();
|
||||
if (aAST.findFirstToken(TokenTypes.LITERAL_STATIC) != null) {
|
||||
if (state.mScopeState > STATE_STATIC_VARIABLE_DEF) {
|
||||
if (!mIgnoreModifiers) {
|
||||
if (!mIgnoreModifiers
|
||||
|| state.mScopeState > STATE_INSTANCE_VARIABLE_DEF)
|
||||
{
|
||||
log(aAST, "declaration.order.static");
|
||||
}
|
||||
}
|
||||
|
|
@ -168,9 +170,7 @@ public class DeclarationOrderCheck extends Check
|
|||
}
|
||||
else {
|
||||
if (state.mScopeState > STATE_INSTANCE_VARIABLE_DEF) {
|
||||
if (!mIgnoreModifiers) {
|
||||
log(aAST, "declaration.order.instance");
|
||||
}
|
||||
log(aAST, "declaration.order.instance");
|
||||
}
|
||||
else if (state.mScopeState == STATE_STATIC_VARIABLE_DEF) {
|
||||
state.mDeclarationAccess = Scope.PUBLIC;
|
||||
|
|
|
|||
|
|
@ -72,8 +72,13 @@ public class DeclarationOrderCheckTest
|
|||
checkConfig.addAttribute("ignoreModifiers", "true");
|
||||
|
||||
final String[] expected = {
|
||||
"45:9: Static variable definition in wrong order.",
|
||||
"54:5: Constructor definition in wrong order.",
|
||||
"80:5: Instance variable definition in wrong order.",
|
||||
"100:9: Static variable definition in wrong order.",
|
||||
"143:9: Static variable definition in wrong order.",
|
||||
"152:5: Constructor definition in wrong order.",
|
||||
"178:5: Instance variable definition in wrong order.",
|
||||
};
|
||||
verify(checkConfig, getPath("coding/InputDeclarationOrder.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,11 @@
|
|||
</ul>
|
||||
<p>Bug fixes:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="config_conding.html#DeclarationOrder">DeclarationOrder</a>
|
||||
handles ignoreModifiers correctly (all fields should be before
|
||||
ctors and methods)(bug #3429775)
|
||||
</li>
|
||||
<li>
|
||||
<a href="config_conding.html#InnerAssignment">Inner assignment</a>
|
||||
is now allowed in try-with-resources (bug #3441097)
|
||||
|
|
|
|||
Loading…
Reference in New Issue