Suppress Warnings Holder - fixed throwing exception if annotation uses constant value, issue #539

This commit is contained in:
alexkravin 2014-12-30 13:08:38 +04:00 committed by Roman Ivanov
parent e6638c3344
commit 98684b95a5
2 changed files with 12 additions and 3 deletions

View File

@ -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);
}

View File

@ -62,4 +62,9 @@ class InputSuppressWarningsFilter
@SuppressWarnings("rawtypes")
ELEMENT;
}
private static final String UNUSED="UnusedDeclaration";
@SuppressWarnings(UNUSED)
public void annotationUsingStringConstantValue(){
}
}