1 package com.puppycrawl.tools.checkstyle.checks; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 23 import java.util.regex.Pattern ; 24 25 41 public class RequiredRegexpCheck extends AbstractFormatCheck 42 { 43 46 public RequiredRegexpCheck() 47 { 48 super("$^"); } 50 51 52 public int[] getDefaultTokens() 53 { 54 return new int[0]; 55 } 56 57 58 public void beginTree(DetailAST aRootAST) 59 { 60 final Pattern pattern = getRegexp(); 61 final String [] lines = getLines(); 62 for (int i = 0; i < lines.length; i++) { 63 64 final String line = lines[i]; 65 if (pattern.matcher(line).find()) { 66 return; 67 } 68 } 69 log(0, "required.regexp", getFormat()); 70 } 71 } 72 73 | Popular Tags |