mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat(php): improve indents in return statements & chained methods
This commit is contained in:
parent
df3e6a24ac
commit
143ca5ce17
3 changed files with 126 additions and 0 deletions
|
|
@ -1,7 +1,9 @@
|
|||
[
|
||||
(array_creation_expression)
|
||||
(parenthesized_expression)
|
||||
(compound_statement)
|
||||
(declaration_list)
|
||||
(member_call_expression)
|
||||
(binary_expression)
|
||||
(return_statement)
|
||||
(arguments)
|
||||
|
|
@ -12,6 +14,17 @@
|
|||
(case_statement)
|
||||
] @indent.begin
|
||||
|
||||
(return_statement
|
||||
[
|
||||
(object_creation_expression)
|
||||
(anonymous_function_creation_expression)
|
||||
(arrow_function)
|
||||
(match_expression)
|
||||
]) @indent.dedent
|
||||
|
||||
(member_call_expression
|
||||
object: (member_call_expression) @indent.branch)
|
||||
|
||||
[
|
||||
")"
|
||||
"}"
|
||||
|
|
@ -20,9 +33,18 @@
|
|||
|
||||
(comment) @indent.auto
|
||||
|
||||
(arguments
|
||||
")" @indent.end)
|
||||
|
||||
(formal_parameters
|
||||
")" @indent.end)
|
||||
|
||||
(compound_statement
|
||||
"}" @indent.end)
|
||||
|
||||
(return_statement
|
||||
";" @indent.end)
|
||||
|
||||
(ERROR
|
||||
"(" @indent.align
|
||||
.
|
||||
|
|
|
|||
66
tests/indent/php/issue-4848.php
Normal file
66
tests/indent/php/issue-4848.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
if (
|
||||
) {
|
||||
}
|
||||
|
||||
return (
|
||||
);
|
||||
|
||||
return true
|
||||
;
|
||||
|
||||
return fn () => (
|
||||
);
|
||||
|
||||
return fn (
|
||||
) => (
|
||||
);
|
||||
|
||||
return function (
|
||||
) {
|
||||
};
|
||||
|
||||
return function () {
|
||||
};
|
||||
|
||||
return match (
|
||||
) {
|
||||
};
|
||||
|
||||
return match () {
|
||||
};
|
||||
|
||||
return new class
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
}
|
||||
|
||||
public function down(
|
||||
) {
|
||||
}
|
||||
};
|
||||
|
||||
$this->foo()
|
||||
->bar(
|
||||
)
|
||||
->baz();
|
||||
|
||||
$this->get()
|
||||
->each(function () {
|
||||
})
|
||||
->each(
|
||||
function (
|
||||
) {
|
||||
},
|
||||
);
|
||||
|
||||
return $this->get()
|
||||
->each(function () {
|
||||
})
|
||||
->each(
|
||||
function (
|
||||
) {
|
||||
},
|
||||
);
|
||||
|
|
@ -24,5 +24,43 @@ describe("indent PHP:", function()
|
|||
run:new_line("unfinished-call.php", { on_line = 6, text = "$a =", indent = 4 })
|
||||
run:new_line("issue-3591.php", { on_line = 4, text = "$a =", indent = 8 })
|
||||
run:new_line("enum-indent.php", { on_line = 4, text = "case", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 3, text = "true", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 4, text = "return;", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 7, text = "true", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 10, text = "|| false", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 11, text = "$a = 0;", indent = 0 })
|
||||
run:new_line("issue-4848.php", { on_line = 13, text = "true", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 16, text = "$a,", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 17, text = "true", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 20, text = "$a,", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 21, text = "return $a;", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 24, text = "return;", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 27, text = "true", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 28, text = "true => null,", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 31, text = "true => null,", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 35, text = "function a() {}", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 37, text = "return;", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 40, text = "$a,", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 41, text = "return $a;", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 45, text = "->foo()", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 46, text = "$a,", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 47, text = "->foo()", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 48, text = "$a;", indent = 0 })
|
||||
run:new_line("issue-4848.php", { on_line = 50, text = "->foo()", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 51, text = "return $a;", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 52, text = "->foo()", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 53, text = "$a,", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 54, text = "$a,", indent = 12 })
|
||||
run:new_line("issue-4848.php", { on_line = 55, text = "return $a;", indent = 12 })
|
||||
run:new_line("issue-4848.php", { on_line = 56, text = "$a,", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 57, text = "$a;", indent = 0 })
|
||||
run:new_line("issue-4848.php", { on_line = 59, text = "->foo()", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 60, text = "return $a;", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 61, text = "->foo()", indent = 4 })
|
||||
run:new_line("issue-4848.php", { on_line = 62, text = "$a,", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 63, text = "$a,", indent = 12 })
|
||||
run:new_line("issue-4848.php", { on_line = 64, text = "return $a;", indent = 12 })
|
||||
run:new_line("issue-4848.php", { on_line = 65, text = "$a,", indent = 8 })
|
||||
run:new_line("issue-4848.php", { on_line = 66, text = "$a;", indent = 0 })
|
||||
end)
|
||||
end)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue