## com.puppycrawl.tools.checkstyle.checks.indentation
Class ExpressionHandler

    java.lang.Object
      com.puppycrawl.tools.checkstyle.checks.indentation.ExpressionHandler

Direct Known Subclasses:
  BlockParentHandler, CaseHandler, ImportHandler, LabelHandler, MemberDefHandler, MethodCallHandler, NewHandler, PackageDefHandler, PrimordialHandler

    public abstract class ExpressionHandler

extends Object

Abstract base class for all handlers.

Author:
  jrichard

Constructor Summary
`ExpressionHandler(IndentationCheck aIndentCheck, String aTypeName, DetailAST aExpr, ExpressionHandler aParent)` Construct an instance of this handler with the given indentation check, name, abstract syntax tree, and parent handler.

Method Summary
`protected void` `checkChildren(DetailAST aParent, int[] aTokenTypes, IndentLevel aStartLevel, boolean aFirstLineMatches, boolean aAllowNesting)` Check the indent level of the children of the specified parent expression.
`protected void` `checkExpressionSubtree(DetailAST aTree, IndentLevel aLevel, boolean aFirstLineMatches, boolean aAllowNesting)` Check the indentation level for an expression subtree.
`abstract void` `checkIndentation()` Check the indentation of the expression we are handling.
`protected void` `checkLinesIndent(int aStartLine, int aEndLine, IndentLevel aIndentLevel)` Check the indentation of consecutive lines for the expression we are handling.
`protected void` `checkLParen(DetailAST aLparen)` Check the indentation of the left parenthesis.
`protected void` `checkModifiers()` Check the indentation level of modifiers.
`protected void` `checkRParen(DetailAST aLparen, DetailAST aRparen)` Check the indentation of the right parenthesis.
`protected int` `expandedTabsColumnNo(DetailAST aAST)` Get the column number for the start of a given expression, expanding tabs out into spaces in the process.
`protected void` `findSubtreeLines(LineSet aLines, DetailAST aTree, boolean aAllowNesting)` Find the set of lines for a given subtree.
`protected int` `getBasicOffset()` A shortcut for `IndentationCheck` property.
`protected int` `getBraceAdjustement()` A shortcut for `IndentationCheck` property.
`protected int` `getFirstLine(int aStartLine, DetailAST aTree)` Get the first line for a given expression.
`protected IndentationCheck` `getIndentCheck()` Accessor for the IndentCheck attribute.
`IndentLevel` `getLevel()` Get the indentation amount for this handler.
`protected IndentLevel` `getLevelImpl()` Compute the indentation amount for this handler.
`protected int` `getLineStart(DetailAST aAst)` Get the start of the line for the given expression.
`protected int` `getLineStart(String aLine)` Get the start of the specified line.
`protected DetailAST` `getMainAst()` Accessor for the MainAst attribute.
`protected ExpressionHandler` `getParent()` Accessor for the Parent attribute.
`protected void` `logError(DetailAST aAst, String aSubtypeName, int aActualLevel)` Log an indentation error.
`protected void` `logError(DetailAST aAst, String aSubtypeName, int aActualLevel, IndentLevel aExpectedLevel)` Log an indentation error.
`protected boolean` `shouldIncreaseIndent()`
`protected boolean` `startsLine(DetailAST aAst)` Determines if the given expression is at the start of a line.
`IndentLevel` `suggestedChildLevel(ExpressionHandler aChild)` Indentation level suggested for a child element.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ExpressionHandler

    public ExpressionHandler(IndentationCheck aIndentCheck,
                             String aTypeName,
                             DetailAST aExpr,
                             ExpressionHandler aParent)

  Construct an instance of this handler with the given indentation check, name, abstract syntax tree, and parent handler.

  Parameters:
    `aIndentCheck` - the indentation check
    `aTypeName` - the name of the handler
    `aExpr` - the abstract syntax tree
    `aParent` - the parent handler

Method Detail

### getLevel

    public final IndentLevel getLevel()

  Get the indentation amount for this handler. For performance reasons, this value is cached. The first time this method is called, the indentation amount is computed and stored. On further calls, the stored value is returned.

  Returns:
    the expected indentation amount

### getLevelImpl

    protected IndentLevel getLevelImpl()

  Compute the indentation amount for this handler.

  Returns:
    the expected indentation amount

### suggestedChildLevel

    public IndentLevel suggestedChildLevel(ExpressionHandler aChild)

  Indentation level suggested for a child element. Children don't have to respect this, but most do.

  Parameters:
    `aChild` - child AST (so suggestion level can differ based on child type)
  Returns:
    suggested indentation for child

### logError

    protected final void logError(DetailAST aAst,
                                  String aSubtypeName,
                                  int aActualLevel)

  Log an indentation error.

  Parameters:
    `aAst` - the expression that caused the error
    `aSubtypeName` - the type of the expression
    `aActualLevel` - the actual indent level of the expression

### logError

    protected final void logError(DetailAST aAst,
                                  String aSubtypeName,
                                  int aActualLevel,
                                  IndentLevel aExpectedLevel)

  Log an indentation error.

  Parameters:
    `aAst` - the expression that caused the error
    `aSubtypeName` - the type of the expression
    `aActualLevel` - the actual indent level of the expression
    `aExpectedLevel` - the expected indent level of the expression

### startsLine

    protected final boolean startsLine(DetailAST aAst)

  Determines if the given expression is at the start of a line.

  Parameters:
    `aAst` - the expression to check
  Returns:
    true if it is, false otherwise

### getLineStart

    protected final int getLineStart(DetailAST aAst)

  Get the start of the line for the given expression.

  Parameters:
    `aAst` - the expression to find the start of the line for
  Returns:
    the start of the line for the given expression

### checkLinesIndent

    protected final void checkLinesIndent(int aStartLine,
                                          int aEndLine,
                                          IndentLevel aIndentLevel)

  Check the indentation of consecutive lines for the expression we are handling.

  Parameters:
    `aStartLine` - the first line to check
    `aEndLine` - the last line to check
    `aIndentLevel` - the required indent level

### shouldIncreaseIndent

    protected boolean shouldIncreaseIndent()

  Returns:
    true if indentation should be increased after fisrt line in checkLinesIndent() false otherwise

### getLineStart

    protected final int getLineStart(String aLine)

  Get the start of the specified line.

  Parameters:
    `aLine` - the specified line number
  Returns:
    the start of the specified line

### checkChildren

    protected final void checkChildren(DetailAST aParent,
                                       int[] aTokenTypes,
                                       IndentLevel aStartLevel,
                                       boolean aFirstLineMatches,
                                       boolean aAllowNesting)

  Check the indent level of the children of the specified parent expression.

  Parameters:
    `aParent` - the parent whose children we are checking
    `aTokenTypes` - the token types to check
    `aStartLevel` - the starting indent level
    `aFirstLineMatches` - whether or not the first line needs to match
    `aAllowNesting` - whether or not nested children are allowed

### checkExpressionSubtree

    protected final void checkExpressionSubtree(DetailAST aTree,
                                                IndentLevel aLevel,
                                                boolean aFirstLineMatches,
                                                boolean aAllowNesting)

  Check the indentation level for an expression subtree.

  Parameters:
    `aTree` - the expression subtree to check
    `aLevel` - the indentation level
    `aFirstLineMatches` - whether or not the first line has to match
    `aAllowNesting` - whether or not subtree nesting is allowed

### getFirstLine

    protected final int getFirstLine(int aStartLine,
                                     DetailAST aTree)

  Get the first line for a given expression.

  Parameters:
    `aStartLine` - the line we are starting from
    `aTree` - the expression to find the first line for
  Returns:
    the first line of the expression

### expandedTabsColumnNo

    protected final int expandedTabsColumnNo(DetailAST aAST)

  Get the column number for the start of a given expression, expanding tabs out into spaces in the process.

  Parameters:
    `aAST` - the expression to find the start of
  Returns:
    the column number for the start of the expression

### findSubtreeLines

    protected final void findSubtreeLines(LineSet aLines,
                                          DetailAST aTree,
                                          boolean aAllowNesting)

  Find the set of lines for a given subtree.

  Parameters:
    `aLines` - the set of lines to add to
    `aTree` - the subtree to examine
    `aAllowNesting` - whether or not to allow nested subtrees

### checkModifiers

    protected final void checkModifiers()

  Check the indentation level of modifiers.

### checkIndentation

    public abstract void checkIndentation()

  Check the indentation of the expression we are handling.

### getIndentCheck

    protected final IndentationCheck getIndentCheck()

  Accessor for the IndentCheck attribute.

  Returns:
    the IndentCheck attribute

### getMainAst

    protected final DetailAST getMainAst()

  Accessor for the MainAst attribute.

  Returns:
    the MainAst attribute

### getParent

    protected final ExpressionHandler getParent()

  Accessor for the Parent attribute.

  Returns:
    the Parent attribute

### getBasicOffset

    protected final int getBasicOffset()

  A shortcut for `IndentationCheck` property.

  Returns:
    value of basicOffset property of `IndentationCheck`

### getBraceAdjustement

    protected final int getBraceAdjustement()

  A shortcut for `IndentationCheck` property.

  Returns:
    value of braceAdjustment property of `IndentationCheck`

### checkRParen

    protected final void checkRParen(DetailAST aLparen,
                                     DetailAST aRparen)

  Check the indentation of the right parenthesis.

  Parameters:
    `aRparen` - parenthesis to check
    `aLparen` - left parenthesis associated with aRparen

### checkLParen

    protected final void checkLParen(DetailAST aLparen)

  Check the indentation of the left parenthesis.

  Parameters:
    `aLparen` - parenthesis to check

Copyright © 2001-2011. All Rights Reserved.