summaryrefslogtreecommitdiff
path: root/test/lisp/progmodes/java-ts-mode-resources/indent.erts
blob: 514d2e08977ac543dad1cd6acb2d895a3285f629 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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;
        }
    }
}
=-=-=

Name: Opening bracket on separate line (bug#67556)

=-=
public class Java {
    void foo(
        String foo)
    {
        for (var f : rs)
            return new String[]
            {
                "foo",
                "bar"
            };
        if (a == 0)
        {
            return 0;
        } else if (a == 1)
        {
            return 1;
        }

        switch(expr)
        {
            case x:
                // code block
                break;
        }
    }
}
=-=-=