1 package com.puppycrawl.tools.checkstyle.checks.usage; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 import com.puppycrawl.tools.checkstyle.api.Scope; 23 import com.puppycrawl.tools.checkstyle.api.ScopeUtils; 24 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 25 26 27 39 public class UnusedPrivateFieldCheck 40 extends AbstractUsageCheck 41 { 42 43 public int[] getDefaultTokens() 44 { 45 return new int[] { 46 TokenTypes.VARIABLE_DEF, 47 }; 48 } 49 50 51 public String getErrorKey() 52 { 53 return "unused.field"; 54 } 55 56 57 public boolean mustCheckReferenceCount(DetailAST aAST) 58 { 59 final DetailAST mods = aAST.findFirstToken(TokenTypes.MODIFIERS); 60 return ((mods != null) 61 && (ScopeUtils.getScopeFromMods(mods) == Scope.PRIVATE)); 62 } 63 } 64 | Popular Tags |