Repository: checkstyle/checkstyle

Problem statement:
Indentation on annotation parameters is wrong
When using `<property name="tabWidth" value="4"/><module name="Indentation"/>`, during build checkstyle 6.8.1 complains about:

```
    @Cascade(
        org.hibernate.annotations.CascadeType.DELETE_ORPHAN
    )
```

with:

```
ClickConfig.java:77: ')' have incorrect indentation level 4, expected level should be 8.
```

But it should accept such formatting as the right parenthes closes a block that started on indentation level 4, so it should also be on 4, not on 8.



Hints:

Patch:
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/LineWrappingHandler.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/LineWrappingHandler.java
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/LineWrappingHandler.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/LineWrappingHandler.java
@@ -33,7 +33,7 @@
  * lineWrappingIndentation parameter.
  *
  * @author maxvetrenko
- *
+ * @author <a href="mailto:piotr.listkiewicz@gmail.com">liscju</a>
  */
 public class LineWrappingHandler {
 
@@ -222,10 +222,13 @@ private void checkAnnotationIndentation(DetailAST atNode,
         while (firstNodesOnLines.size() > 1) {
             final DetailAST node = itr.next();
 
-            if (node.getLineNo() < lastAnnotationLine
-                    || node.getLineNo() == lastAnnotationLine) {
+            if (node.getLineNo() <= lastAnnotationLine) {
                 final DetailAST parentNode = node.getParent();
-                if (node.getType() == TokenTypes.AT
+                final boolean isCurrentNodeCloseAnnotationAloneInLine =
+                        node.getLineNo() == lastAnnotationLine
+                        && node.equals(lastAnnotationNode);
+                if (isCurrentNodeCloseAnnotationAloneInLine
+                        || node.getType() == TokenTypes.AT
                         && parentNode.getParent().getType() == TokenTypes.MODIFIERS) {
                     logWarningMessage(node, firstNodeIndent);
                 }


Test patch:
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java
@@ -331,6 +331,24 @@ public void testDifficultAnnotations() throws Exception {
         verifyWarns(checkConfig, getPath("InputDifficultAnnotations.java"), expected);
     }
 
+    @Test
+    public void testAnnotationClosingParenthesisEndsInSameIndentationAsOpening() throws Exception {
+        final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class);
+
+        checkConfig.addAttribute("basicOffset", "4");
+        checkConfig.addAttribute("forceStrictCondition", "true");
+        checkConfig.addAttribute("tabWidth", "4");
+
+        final String[] expected = {
+            "19: " + getCheckMessage(MSG_ERROR, ")", 16, 0),
+            "22: " + getCheckMessage(MSG_ERROR, ")",  8, 4),
+        };
+
+        verifyWarns(checkConfig,
+                getPath("InputAnnotationClosingParenthesisEndsInSameIndentationAsOpening.java"),
+                expected);
+    }
+
     @Test
     public void testAnonClassesFromGuava() throws Exception {
         final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class);
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputAnnotationClosingParenthesisEndsInSameIndentationAsOpening.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputAnnotationClosingParenthesisEndsInSameIndentationAsOpening.java
new file mode 100644
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/indentation/InputAnnotationClosingParenthesisEndsInSameIndentationAsOpening.java
@@ -0,0 +1,24 @@
+package com.puppycrawl.tools.checkstyle.checks.indentation; //indent:0 exp:0
+
+@interface SimpleType { //indent:0 exp:0
+    Class<?> value(); //indent:4 exp:4
+} //indent:0 exp:0
+
+@SimpleType( //indent:0 exp:0
+    value = Boolean.class //indent:4 exp:4
+) //indent:0 exp:0
+public class InputAnnotationClosingParenthesisEndsInSameIndentationAsOpening { //indent:0 exp:0
+} //indent:0 exp:0
+
+@SimpleType( value = Boolean.class //indent:0 exp:0
+) //indent:0 exp:0
+class InputAnnotationClosingParenthesisJustLineAfterOpeningSameIndentationAsOpening { //indent:0 exp:0
+} //indent:0 exp:0
+
+@SimpleType( value = Boolean.class //indent:0 exp:0
+                ) //indent:16 exp:0 warn
+class InputAnnotationClosingParenthesHasBadIndentation { //indent:0 exp:0
+    @SimpleType( value = Boolean.class //indent:4 exp:4
+        ) //indent:8 exp:4 warn
+    Boolean booleanField; //indent:4 exp:4
+} //indent:0 exp:0
\ No newline at end of file