Fix exception in SuppressWarnings check on complex annotations. #1201
This commit is contained in:
parent
3dd97d4e85
commit
840034a6cb
|
|
@ -146,7 +146,8 @@ public class SuppressWarningsCheck extends AbstractFormatCheck {
|
|||
final DetailAST warningHolder =
|
||||
this.findWarningsHolder(annotation);
|
||||
|
||||
final DetailAST token = warningHolder.findFirstToken(TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR);
|
||||
final DetailAST token =
|
||||
warningHolder.findFirstToken(TokenTypes.ANNOTATION_MEMBER_VALUE_PAIR);
|
||||
DetailAST warning;
|
||||
|
||||
if (token != null) {
|
||||
|
|
@ -188,8 +189,8 @@ public class SuppressWarningsCheck extends AbstractFormatCheck {
|
|||
case TokenTypes.DOT:
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException("Should never get here, type: "
|
||||
+ fChild.getType() + " text: " + fChild.getText());
|
||||
// #1252 - cases like @SuppressWarnings("un" + "used") or
|
||||
// @SuppressWarnings((String) "unused")
|
||||
}
|
||||
}
|
||||
warning = warning.getNextSibling();
|
||||
|
|
|
|||
|
|
@ -826,4 +826,18 @@ public class SuppressWarningsCheckTest extends BaseCheckTestSupport {
|
|||
verify(checkConfig, getPath("annotation" + File.separator
|
||||
+ "SuppressWarningsValuePair.java"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWorkingProperlyOnComplexAnnotations() throws Exception {
|
||||
DefaultConfiguration checkConfig = createCheckConfig(SuppressWarningsCheck.class);
|
||||
|
||||
String[] expected = {
|
||||
"18:34: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""),
|
||||
"24:23: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""),
|
||||
"28:52: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""),
|
||||
"33:5: " + getCheckMessage(MSG_KEY_SUPPRESSED_WARNING_NOT_ALLOWED, ""),
|
||||
};
|
||||
|
||||
verify(checkConfig, getPath("InputSuppressWarningsHolder.java"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue