1 package com.puppycrawl.tools.checkstyle.checks.coding; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 import com.puppycrawl.tools.checkstyle.api.FullIdent; 23 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 24 25 30 public final class IllegalThrowsCheck extends AbstractIllegalCheck 31 { 32 33 public IllegalThrowsCheck() 34 { 35 super(new String [] {"Error", 36 "RuntimeException", "Throwable", 37 "java.lang.Error", 38 "java.lang.RuntimeException", 39 "java.lang.Throwable", 40 }); 41 } 42 43 44 public int[] getDefaultTokens() 45 { 46 return new int[] {TokenTypes.LITERAL_THROWS}; 47 } 48 49 50 public int[] getRequiredTokens() 51 { 52 return getDefaultTokens(); 53 } 54 55 56 public void visitToken(DetailAST aDetailAST) 57 { 58 DetailAST token = (DetailAST) aDetailAST.getFirstChild(); 59 while (token != null) { 60 if (token.getType() != TokenTypes.COMMA) { 61 final FullIdent ident = FullIdent.createFullIdent(token); 62 if (isIllegalClassName(ident.getText())) { 63 log(token, "illegal.throw", ident.getText()); 64 } 65 } 66 67 token = (DetailAST) token.getNextSibling(); 68 } 69 } 70 } 71 | Popular Tags |