summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes/java-ts-mode-resources/indent.erts
blob: 4fca74dd2e1506c8f201489748b447a1201e28ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
Code:
  (lambda ()
    (setq indent-tabs-mode nil)
    (setq java-ts-mode-indent-offset 4)
    (java-ts-mode)
    (indent-region (point-min) (point-max)))

Point-Char: |

Name: Basic

=-=
public class Basic {
    public void basic() {
        return;
    }
}
=-=-=

Name: Empty Line

=-=
public class EmptyLine {
    public void emptyLine() {
        |
    }
}
=-=-=

Name: Statements

=-=
if (x) {
    for (var foo : foos) {
        |
    }
} else if (y) {
    for (int i = 0; x < foos.size(); i++) {
        return;
    }
} else {
    return;
}
=-=-=

Name: Field declaration without access modifier (bug#61115)

=-=
public class T {
    @Autowired
    String a;
}
=-=-=

Name: Array initializer

=-=
public class Java {
    void foo() {
        return new String[]{
            "foo", // These
            "bar"
        }
    }
}
=-=-=

Name: Advanced bracket matching indentation (bug#61142)

=-=
public class Java {

    public Java(
        String foo) {
        this.foo = foo;
    }

    void foo(
        String foo) {

        for (var f : rs)
            return new String[]{
                "foo",
                "bar"
            };
        if (a == 0
            && b == 1
            && foo) {
            return 0;
        } else if (a == 1) {
            return 1;
        } else if (true)
            return 5;
        else {
            if (a == 0
                && b == 1
                && foo)
                while (true)
                    for (
                        ;;)
                        if (true)
                            return 5;
                        else if (false) {
                            return 6;
                        } else
                            if (true
                                && false)
                                return 6;
        }
    }
}
=-=-=