1 package com.puppycrawl.tools.checkstyle.checks.coding; 20 21 import com.puppycrawl.tools.checkstyle.api.Check; 22 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 23 import com.puppycrawl.tools.checkstyle.api.DetailAST; 24 25 41 public class ArrayTrailingCommaCheck extends Check 42 { 43 44 public int[] getDefaultTokens() 45 { 46 return new int[] {TokenTypes.ARRAY_INIT}; 47 } 48 49 50 public void visitToken(DetailAST aArrayInit) 51 { 52 final DetailAST rcurly = aArrayInit.findFirstToken(TokenTypes.RCURLY); 53 54 if ((aArrayInit.getLineNo() == rcurly.getLineNo()) 57 || (aArrayInit.getChildCount() == 1)) 58 { 59 return; 60 } 61 62 final DetailAST prev = rcurly.getPreviousSibling(); 63 if (prev.getType() != TokenTypes.COMMA) { 64 log(rcurly.getLineNo(), "array.trailing.comma"); 65 } 66 } 67 } 68 | Popular Tags |