diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java index fca5ee580..f687ddc92 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolder.java @@ -398,6 +398,8 @@ public class SuppressWarningsHolder return quotedText.substring(1, quotedText.length() - 1); case TokenTypes.IDENT: return firstChild.getText(); + case TokenTypes.DOT: + return firstChild.getLastChild().getText(); default: throw new IllegalArgumentException("String literal AST expected: " + firstChild); diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java new file mode 100644 index 000000000..8a11153d1 --- /dev/null +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/SuppressWarningsHolderTest.java @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +// checkstyle: Checks Java source code for adherence to a set of rules. +// Copyright (C) 2001-2015 the original author or authors. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//////////////////////////////////////////////////////////////////////////////// + +package com.puppycrawl.tools.checkstyle.checks; + +import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport; +import com.puppycrawl.tools.checkstyle.api.Configuration; +import org.junit.Test; + +public class SuppressWarningsHolderTest extends BaseCheckTestSupport { + @Test + public void testOnComplexAnnotations() throws Exception { + Configuration checkConfig = createCheckConfig(SuppressWarningsHolder.class); + + String[] expected = { + }; + + verify(checkConfig, getPath("InputSuppressWarningsHolder.java"), expected); + } +} \ No newline at end of file diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/InputSuppressWarningsHolder.java b/src/test/resources/com/puppycrawl/tools/checkstyle/InputSuppressWarningsHolder.java new file mode 100644 index 000000000..3413f83d1 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/InputSuppressWarningsHolder.java @@ -0,0 +1,18 @@ +package com.puppycrawl.tools.checkstyle; + +public class InputSuppressWarningsHolder { + static final String UNUSED = "unused"; + + @SuppressWarnings(UNUSED) + int a; + @SuppressWarnings(InputSuppressWarningsHolder.UNUSED) + int b; + @SuppressWarnings(com.puppycrawl.tools.checkstyle.InputSuppressWarningsHolder.UNUSED) + int c; + @SuppressWarnings(value = UNUSED) + int d; + @SuppressWarnings(value = InputSuppressWarningsHolder.UNUSED) + int e; + @SuppressWarnings(value = com.puppycrawl.tools.checkstyle.InputSuppressWarningsHolder.UNUSED) + int f; +}