mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-11 06:30:51 +00:00

* lisp/progmodes/java-ts-mode.el (java-ts-mode--indent-rules): Support putting the opening brace on a separate line (bug#67556). * test/lisp/progmodes/java-ts-mode-resources/indent.erts: Add a test.
143 lines
2.3 KiB
Text
143 lines
2.3 KiB
Text
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;
|
|
}
|
|
}
|
|
}
|
|
=-=-=
|