Suppress Warnings Holder - fixed throwing exception if annotation uses constant value, issue #539
This commit is contained in:
parent
e6638c3344
commit
98684b95a5
|
|
@ -395,13 +395,17 @@ public class SuppressWarningsHolder
|
|||
{
|
||||
if (aAST != null && aAST.getType() == TokenTypes.EXPR) {
|
||||
final DetailAST firstChild = aAST.getFirstChild();
|
||||
if (firstChild.getType() == TokenTypes.STRING_LITERAL) {
|
||||
switch (firstChild.getType()) {
|
||||
case TokenTypes.STRING_LITERAL:
|
||||
// NOTE: escaped characters are not unescaped
|
||||
final String quotedText = firstChild.getText();
|
||||
return quotedText.substring(1, quotedText.length() - 1);
|
||||
case TokenTypes.IDENT:
|
||||
return firstChild.getText();
|
||||
default:
|
||||
throw new IllegalArgumentException("String literal AST expected: "
|
||||
+ firstChild);
|
||||
}
|
||||
throw new IllegalArgumentException("String literal AST expected: "
|
||||
+ firstChild);
|
||||
}
|
||||
throw new IllegalArgumentException("Expression AST expected: " + aAST);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,4 +62,9 @@ class InputSuppressWarningsFilter
|
|||
@SuppressWarnings("rawtypes")
|
||||
ELEMENT;
|
||||
}
|
||||
private static final String UNUSED="UnusedDeclaration";
|
||||
|
||||
@SuppressWarnings(UNUSED)
|
||||
public void annotationUsingStringConstantValue(){
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue