Class MultipleVariableDeclarationsExtendedCheck

  • All Implemented Interfaces:
    com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

    public class MultipleVariableDeclarationsExtendedCheck
    extends com.puppycrawl.tools.checkstyle.api.AbstractCheck

    Checks that each variable declaration is in its own statement and on its own line.

    Rationale: the SUN Code conventions chapter 6.1 recommends that declarations should be one per line.

    An example of how to configure the check is:

     <module name="MultipleVariableDeclarations"/>
     
    Since:
    1.5.3
    Author:
    o_sukhodolsky
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

        com.puppycrawl.tools.checkstyle.api.AutomaticBean.OutputStreamOptions
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int[] getAcceptableTokens()  
      int[] getDefaultTokens()  
      int[] getRequiredTokens()  
      void setIgnoreCycles​(boolean value)
      Enable|Disable declaration checking in cycles.
      void setIgnoreMethods​(boolean value)
      Enable|Disable declaration checking in Methods.
      void visitToken​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)  
      void work​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
      Searches for wrong declarations and checks the their type.
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck

        beginTree, clearViolations, destroy, finishTree, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

        finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

        configure, contextualize, getConfiguration, setupChild
    • Constructor Detail

      • MultipleVariableDeclarationsExtendedCheck

        public MultipleVariableDeclarationsExtendedCheck()
    • Method Detail

      • setIgnoreCycles

        public void setIgnoreCycles​(boolean value)
        Enable|Disable declaration checking in cycles.
        Parameters:
        value - check declaration in Methods
      • setIgnoreMethods

        public void setIgnoreMethods​(boolean value)
        Enable|Disable declaration checking in Methods. *
        Parameters:
        value - check declaration in Methods
      • getDefaultTokens

        public int[] getDefaultTokens()
        Specified by:
        getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • getAcceptableTokens

        public int[] getAcceptableTokens()
        Specified by:
        getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • getRequiredTokens

        public int[] getRequiredTokens()
        Specified by:
        getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • work

        public void work​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
        Searches for wrong declarations and checks the their type.
        Parameters:
        ast - uses to get the parent or previous sibling token.
      • visitToken

        public void visitToken​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
        Overrides:
        visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheck