aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodor Thornhill2023-02-06 09:36:08 +0100
committerDmitry Gutov2023-11-21 16:26:54 +0200
commit054202d48c31e718b48a2b601c0e6bd2fdbce1ef (patch)
treee41c723fa4eb1ea7609b9f16ed63f12ac27f7be4
parentd2776d8254fa4afc64a8828da7d30886c2d35ac2 (diff)
downloademacs-054202d48c31e718b48a2b601c0e6bd2fdbce1ef.tar.gz
emacs-054202d48c31e718b48a2b601c0e6bd2fdbce1ef.zip
Backport: Add more java indentation tests
* test/lisp/progmodes/java-ts-mode-resources/indent.erts: Use default indent offset, and tweak the indentation examples. (cherry picked from commit dbe7803aa1e8249bd70f67f25f19aedabeb9cc22)
-rw-r--r--test/lisp/progmodes/java-ts-mode-resources/indent.erts91
1 files changed, 75 insertions, 16 deletions
diff --git a/test/lisp/progmodes/java-ts-mode-resources/indent.erts b/test/lisp/progmodes/java-ts-mode-resources/indent.erts
index c8e0ac71708..4fca74dd2e1 100644
--- a/test/lisp/progmodes/java-ts-mode-resources/indent.erts
+++ b/test/lisp/progmodes/java-ts-mode-resources/indent.erts
@@ -1,7 +1,7 @@
1Code: 1Code:
2 (lambda () 2 (lambda ()
3 (setq indent-tabs-mode nil) 3 (setq indent-tabs-mode nil)
4 (setq java-ts-mode-indent-offset 2) 4 (setq java-ts-mode-indent-offset 4)
5 (java-ts-mode) 5 (java-ts-mode)
6 (indent-region (point-min) (point-max))) 6 (indent-region (point-min) (point-max)))
7 7
@@ -11,9 +11,9 @@ Name: Basic
11 11
12=-= 12=-=
13public class Basic { 13public class Basic {
14 public void basic() { 14 public void basic() {
15 return; 15 return;
16 } 16 }
17} 17}
18=-=-= 18=-=-=
19 19
@@ -21,9 +21,9 @@ Name: Empty Line
21 21
22=-= 22=-=
23public class EmptyLine { 23public class EmptyLine {
24 public void emptyLine() { 24 public void emptyLine() {
25 | 25 |
26 } 26 }
27} 27}
28=-=-= 28=-=-=
29 29
@@ -31,15 +31,15 @@ Name: Statements
31 31
32=-= 32=-=
33if (x) { 33if (x) {
34 for (var foo : foos) { 34 for (var foo : foos) {
35 | 35 |
36 } 36 }
37} else if (y) { 37} else if (y) {
38 for (int i = 0; x < foos.size(); i++) { 38 for (int i = 0; x < foos.size(); i++) {
39 return; 39 return;
40 } 40 }
41} else { 41} else {
42 return; 42 return;
43} 43}
44=-=-= 44=-=-=
45 45
@@ -47,7 +47,66 @@ Name: Field declaration without access modifier (bug#61115)
47 47
48=-= 48=-=
49public class T { 49public class T {
50 @Autowired 50 @Autowired
51 String a; 51 String a;
52}
53=-=-=
54
55Name: Array initializer
56
57=-=
58public class Java {
59 void foo() {
60 return new String[]{
61 "foo", // These
62 "bar"
63 }
64 }
65}
66=-=-=
67
68Name: Advanced bracket matching indentation (bug#61142)
69
70=-=
71public class Java {
72
73 public Java(
74 String foo) {
75 this.foo = foo;
76 }
77
78 void foo(
79 String foo) {
80
81 for (var f : rs)
82 return new String[]{
83 "foo",
84 "bar"
85 };
86 if (a == 0
87 && b == 1
88 && foo) {
89 return 0;
90 } else if (a == 1) {
91 return 1;
92 } else if (true)
93 return 5;
94 else {
95 if (a == 0
96 && b == 1
97 && foo)
98 while (true)
99 for (
100 ;;)
101 if (true)
102 return 5;
103 else if (false) {
104 return 6;
105 } else
106 if (true
107 && false)
108 return 6;
109 }
110 }
52} 111}
53=-=-= 112=-=-=