java-ts-mode: Indentation for opening brace on a separate line
* 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.
This commit is contained in:
parent
9e56bd5ed8
commit
5a64d2c759
2 changed files with 40 additions and 4 deletions
|
@ -74,7 +74,12 @@
|
|||
((parent-is "program") column-0 0)
|
||||
((match "}" "element_value_array_initializer")
|
||||
parent-bol 0)
|
||||
((node-is "}") column-0 c-ts-common-statement-offset)
|
||||
((node-is
|
||||
,(format "\\`%s\\'"
|
||||
(regexp-opt '("constructor_body" "class_body" "interface_body"
|
||||
"block" "switch_block" "array_initializer"))))
|
||||
parent-bol 0)
|
||||
((node-is "}") standalone-parent 0)
|
||||
((node-is ")") parent-bol 0)
|
||||
((node-is "else") parent-bol 0)
|
||||
((node-is "]") parent-bol 0)
|
||||
|
@ -86,10 +91,10 @@
|
|||
((parent-is "array_initializer") parent-bol java-ts-mode-indent-offset)
|
||||
((parent-is "annotation_type_body") column-0 c-ts-common-statement-offset)
|
||||
((parent-is "interface_body") column-0 c-ts-common-statement-offset)
|
||||
((parent-is "constructor_body") column-0 c-ts-common-statement-offset)
|
||||
((parent-is "constructor_body") standalone-parent java-ts-mode-indent-offset)
|
||||
((parent-is "enum_body_declarations") parent-bol 0)
|
||||
((parent-is "enum_body") column-0 c-ts-common-statement-offset)
|
||||
((parent-is "switch_block") column-0 c-ts-common-statement-offset)
|
||||
((parent-is "switch_block") standalone-parent java-ts-mode-indent-offset)
|
||||
((parent-is "record_declaration_body") column-0 c-ts-common-statement-offset)
|
||||
((query "(method_declaration (block _ @indent))") parent-bol java-ts-mode-indent-offset)
|
||||
((query "(method_declaration (block (_) @indent))") parent-bol java-ts-mode-indent-offset)
|
||||
|
@ -125,7 +130,7 @@
|
|||
((parent-is "case_statement") parent-bol java-ts-mode-indent-offset)
|
||||
((parent-is "labeled_statement") parent-bol java-ts-mode-indent-offset)
|
||||
((parent-is "do_statement") parent-bol java-ts-mode-indent-offset)
|
||||
((parent-is "block") column-0 c-ts-common-statement-offset)))
|
||||
((parent-is "block") standalone-parent java-ts-mode-indent-offset)))
|
||||
"Tree-sitter indent rules.")
|
||||
|
||||
(defvar java-ts-mode--keywords
|
||||
|
|
|
@ -110,3 +110,34 @@ public class Java {
|
|||
}
|
||||
}
|
||||
=-=-=
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
=-=-=
|
||||
|
|
Loading…
Add table
Reference in a new issue