diff --git a/pom.xml b/pom.xml index 83beb8bd1..3e9c1b90b 100644 --- a/pom.xml +++ b/pom.xml @@ -1155,7 +1155,6 @@ .*.checks.indentation.ArrayInitHandler87100 .*.checks.indentation.ElseHandler75100 .*.checks.indentation.AbstractExpressionHandler9197 - .*.checks.indentation.LineWrappingHandler8795 .*.checks.indentation.MethodCallLineWrapHandler00 .*.checks.indentation.ObjectBlockHandler75100 .*.checks.indentation.SynchronizedHandler100100 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 index 0c234f5b4..9752ce57e 100644 --- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/LineWrappingHandler.java +++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/LineWrappingHandler.java @@ -114,13 +114,6 @@ public class LineWrappingHandler { || currentType == TokenTypes.ARRAY_INIT) { logWarningMessage(node, firstNodeIndent); } - else if (currentType == TokenTypes.LITERAL_IF) { - final DetailAST parent = node.getParent(); - - if (parent.getType() == TokenTypes.LITERAL_ELSE) { - logWarningMessage(parent, currentIndent); - } - } else { logWarningMessage(node, currentIndent); } @@ -175,8 +168,7 @@ public class LineWrappingHandler { final DetailAST firstTokenOnLine = result.get(curNode.getLineNo()); if (firstTokenOnLine == null - || firstTokenOnLine != null - && firstTokenOnLine.getColumnNo() >= curNode.getColumnNo()) { + || firstTokenOnLine.getColumnNo() >= curNode.getColumnNo()) { result.put(curNode.getLineNo(), curNode); } curNode = getNextCurNode(curNode); @@ -195,7 +187,7 @@ public class LineWrappingHandler { DetailAST nodeToVisit = curNode.getFirstChild(); DetailAST currentNode = curNode; - while (currentNode != null && nodeToVisit == null) { + while (nodeToVisit == null) { nodeToVisit = currentNode.getNextSibling(); if (nodeToVisit == null) { currentNode = currentNode.getParent(); @@ -218,15 +210,13 @@ public class LineWrappingHandler { final Collection values = firstNodesOnLines.values(); final DetailAST lastAnnotationNode = getLastAnnotationNode(atNode); final int lastAnnotationLine = lastAnnotationNode.getLineNo(); - final int lastAnnotattionColumn = lastAnnotationNode.getColumnNo(); final Iterator itr = values.iterator(); - while (itr.hasNext() && firstNodesOnLines.size() > 1) { + while (firstNodesOnLines.size() > 1) { final DetailAST node = itr.next(); if (node.getLineNo() < lastAnnotationLine - || node.getLineNo() == lastAnnotationLine - && node.getColumnNo() <= lastAnnotattionColumn) { + || node.getLineNo() == lastAnnotationLine) { final DetailAST parentNode = node.getParent(); if (node.getType() == TokenTypes.AT && parentNode.getParent().getType() == TokenTypes.MODIFIERS) { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputValidArrayInitIndent.java b/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputValidArrayInitIndent.java index d819c6676..eb76a7864 100644 --- a/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputValidArrayInitIndent.java +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputValidArrayInitIndent.java @@ -112,6 +112,10 @@ public class InputValidArrayInitIndent { //indent:0 exp:0 func1(new int[] { //indent:8 exp:8 1, 2, 3 //indent:16 exp:16 }); //indent:8 exp:8 + for (String veryLongVariableName: new String[] //indent:8 exp:8 + {"this is text", "this is text"}) { //indent:8 exp:8 + if (hashCode() == 0) break; //indent:12 exp:12 + } //indent:8 exp:8 } //indent:4 exp:4 } //indent:0 exp:0