1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle.checks.indentation;
21
22 import com.puppycrawl.tools.checkstyle.api.DetailAST;
23
24
25
26
27
28 public class LambdaHandler extends AbstractExpressionHandler {
29
30
31
32
33
34
35
36
37
38 public LambdaHandler(IndentationCheck indentCheck,
39 DetailAST ast, AbstractExpressionHandler parent) {
40 super(indentCheck, "lambda", ast, parent);
41 }
42
43 @Override
44 public IndentLevel getSuggestedChildIndent(AbstractExpressionHandler child) {
45 return getIndent();
46 }
47
48
49
50
51
52 @Override
53 protected IndentLevel getIndentImpl() {
54 if (getParent() instanceof MethodCallHandler) {
55 return getParent().getSuggestedChildIndent(this);
56 }
57
58 DetailAST parent = getMainAst().getParent();
59 if (getParent() instanceof NewHandler) {
60 parent = parent.getParent();
61 }
62
63
64 IndentLevel level = new IndentLevel(getLineStart(parent));
65
66
67
68 final DetailAST firstChild = getMainAst().getFirstChild();
69 if (getLineStart(firstChild) == firstChild.getColumnNo()) {
70 level = new IndentLevel(level, getIndentCheck().getLineWrappingIndentation());
71 }
72
73 return level;
74 }
75
76 @Override
77 public void checkIndentation() {
78
79 final DetailAST firstChild = getMainAst().getFirstChild();
80 if (getLineStart(firstChild) == firstChild.getColumnNo()) {
81 final IndentLevel level = getIndent();
82 if (!level.isAcceptable(firstChild.getColumnNo())) {
83 logError(firstChild, "arguments", firstChild.getColumnNo(), level);
84 }
85 }
86
87
88 if (getLineStart(getMainAst()) == getMainAst().getColumnNo()) {
89 final IndentLevel level =
90 new IndentLevel(getIndent(), getIndentCheck().getLineWrappingIndentation());
91 if (!level.isAcceptable(getMainAst().getColumnNo())) {
92 logError(getMainAst(), "", getMainAst().getColumnNo(), level);
93 }
94 }
95 }
96
97 }