1 20 package com.puppycrawl.tools.checkstyle.checks.whitespace; 21 22 import com.puppycrawl.tools.checkstyle.api.DetailAST; 23 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 24 import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck; 25 26 50 public class EmptyForIteratorPadCheck 51 extends AbstractOptionCheck 52 { 53 56 public EmptyForIteratorPadCheck() 57 { 58 super(PadOption.NOSPACE); 59 } 60 61 62 public int[] getDefaultTokens() 63 { 64 return new int[] {TokenTypes.FOR_ITERATOR, 65 }; 66 } 67 68 69 public void visitToken(DetailAST aAST) 70 { 71 if (aAST.getChildCount() == 0) { 72 final DetailAST semi = aAST.getPreviousSibling(); 74 final String line = getLines()[semi.getLineNo() - 1]; 75 final int after = semi.getColumnNo() + 1; 76 if (after < line.length()) { 78 if ((PadOption.NOSPACE == getAbstractOption()) 79 && (Character.isWhitespace(line.charAt(after)))) 80 { 81 log(semi.getLineNo(), after, "ws.followed", ";"); 82 } 83 else if ((PadOption.SPACE == getAbstractOption()) 84 && !Character.isWhitespace(line.charAt(after))) 85 { 86 log(semi.getLineNo(), after, "ws.notFollowed", ";"); 87 } 88 } 89 } 90 } 91 } 92 | Popular Tags |