1 package com.puppycrawl.tools.checkstyle.checks.coding; 20 21 import com.puppycrawl.tools.checkstyle.api.Check; 22 import com.puppycrawl.tools.checkstyle.api.DetailAST; 23 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 24 25 43 public class DefaultComesLastCheck extends Check 44 { 45 46 public DefaultComesLastCheck() 47 { 48 } 50 51 52 public int[] getDefaultTokens() 53 { 54 return new int[] { 55 TokenTypes.LITERAL_DEFAULT, 56 }; 57 } 58 59 60 public int[] getAcceptableTokens() 61 { 62 return getDefaultTokens(); 63 } 64 65 66 public void visitToken(DetailAST aAST) 67 { 68 final DetailAST defaultGroupAST = aAST.getParent(); 69 if (defaultGroupAST.getType() != TokenTypes.ANNOTATION_FIELD_DEF) { 72 final DetailAST switchAST = defaultGroupAST.getParent(); 73 final DetailAST lastGroupAST = 74 switchAST.getLastChild().getPreviousSibling(); 75 76 if ((defaultGroupAST.getLineNo() != lastGroupAST.getLineNo()) 77 || (defaultGroupAST.getColumnNo() 78 != lastGroupAST.getColumnNo())) 79 { 80 log(aAST, "default.comes.last"); 81 } 82 } 83 } 84 } 85 | Popular Tags |