1 package com.puppycrawl.tools.checkstyle.checks.whitespace; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 import com.puppycrawl.tools.checkstyle.api.Utils; 23 import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck; 24 25 33 abstract class AbstractParenPadCheck 34 extends AbstractOptionCheck 35 { 36 39 AbstractParenPadCheck() 40 { 41 super(PadOption.NOSPACE); 42 } 43 44 48 protected void processLeft(DetailAST aAST) 49 { 50 final String line = getLines()[aAST.getLineNo() - 1]; 51 final int after = aAST.getColumnNo() + 1; 52 if (after < line.length()) { 53 if ((PadOption.NOSPACE == getAbstractOption()) 54 && (Character.isWhitespace(line.charAt(after)))) 55 { 56 log(aAST.getLineNo(), after, "ws.followed", "("); 57 } 58 else if ((PadOption.SPACE == getAbstractOption()) 59 && !Character.isWhitespace(line.charAt(after)) 60 && (line.charAt(after) != ')')) 61 { 62 log(aAST.getLineNo(), after, "ws.notFollowed", "("); 63 } 64 } 65 } 66 67 71 protected void processRight(DetailAST aAST) 72 { 73 final String line = getLines()[aAST.getLineNo() - 1]; 74 final int before = aAST.getColumnNo() - 1; 75 if (before >= 0) { 76 if ((PadOption.NOSPACE == getAbstractOption()) 77 && Character.isWhitespace(line.charAt(before)) 78 && !Utils.whitespaceBefore(before, line)) 79 { 80 log(aAST.getLineNo(), before, "ws.preceded", ")"); 81 } 82 else if ((PadOption.SPACE == getAbstractOption()) 83 && !Character.isWhitespace(line.charAt(before)) 84 && (line.charAt(before) != '(')) 85 { 86 log(aAST.getLineNo(), aAST.getColumnNo(), 87 "ws.notPreceded", ")"); 88 } 89 } 90 } 91 } 92 | Popular Tags |