Function: php-ts-mode--indent-styles
php-ts-mode--indent-styles is a byte-compiled function defined in
php-ts-mode.el.gz.
Signature
(php-ts-mode--indent-styles)
Documentation
Indent rules supported by php-ts-mode.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/php-ts-mode.el.gz
(defun php-ts-mode--indent-styles ()
"Indent rules supported by `php-ts-mode'."
(let ((common
`(;; Handle indentation relatives to HTML.
((or (parent-is "program")
(parent-is "text_interpolation"))
php-ts-mode--parent-html-heuristic 0)
(php-ts-mode--else-heuristic prev-line php-ts-indent-offset)
((query "(ERROR (ERROR)) @indent") parent-bol 0)
((node-is ")") parent-bol 0)
((node-is "]") parent-bol 0)
((node-is "else_clause") parent-bol 0)
((node-is "case_statement") parent-bol php-ts-indent-offset)
((node-is "default_statement") parent-bol php-ts-indent-offset)
((parent-is "default_statement") parent-bol php-ts-indent-offset)
((and
(parent-is "expression_statement")
(node-is ";"))
parent-bol 0)
((parent-is "expression_statement") parent-bol php-ts-indent-offset)
;; `c-ts-common-looking-at-star' has to come before
;; `c-ts-common-comment-2nd-line-matcher'.
((and (parent-is "comment") c-ts-common-looking-at-star)
c-ts-common-comment-start-after-first-star -1)
(c-ts-common-comment-2nd-line-matcher
c-ts-common-comment-2nd-line-anchor
1)
((parent-is "comment") prev-adaptive-prefix 0)
((parent-is "method_declaration") parent-bol 0)
((node-is "class_interface_clause") parent-bol php-ts-indent-offset)
((query "(class_interface_clause (name) @indent)") php-ts-mode--parent-eol 1)
((query "(class_interface_clause (qualified_name) @indent)")
parent-bol php-ts-indent-offset)
((parent-is "class_declaration") parent-bol 0)
((parent-is "namespace_use_declaration") parent-bol php-ts-indent-offset)
((node-is "namespace_use_clause") parent-bol php-ts-indent-offset)
((or (parent-is "use_declaration")
(parent-is "use_list"))
parent-bol php-ts-indent-offset)
((parent-is "function_definition") parent-bol 0)
((parent-is "member_call_expression") parent-bol php-ts-indent-offset)
((parent-is "conditional_expression") parent-bol php-ts-indent-offset)
((parent-is "assignment_expression") parent-bol php-ts-indent-offset)
((parent-is "array_creation_expression") parent-bol php-ts-indent-offset)
((parent-is "attribute_group") parent-bol php-ts-indent-offset)
((parent-is "parenthesized_expression") first-sibling 1)
((node-is "|>") php-ts-mode--pipe-heuristic 0)
((parent-is "binary_expression") parent 0)
((or (parent-is "arguments")
(parent-is "formal_parameters"))
parent-bol php-ts-indent-offset)
((query "(for_statement (assignment_expression left: (_)) @indent)")
parent-bol php-ts-indent-offset)
((query "(for_statement (binary_expression left: (_)) @indent)")
parent-bol php-ts-indent-offset)
((query "(for_statement (update_expression (_)) @indent)")
parent-bol php-ts-indent-offset)
((query "(function_call_expression arguments: (_) @indent)")
parent php-ts-indent-offset)
((query "(member_call_expression arguments: (_) @indent)")
parent php-ts-indent-offset)
((query "(scoped_call_expression name: (_) @indent)")
parent php-ts-indent-offset)
((parent-is "scoped_property_access_expression")
parent php-ts-indent-offset)
;; Closing bracket. Must stay here, the rule order matter.
((node-is "}") standalone-parent 0)
;; handle multiple single line comment that start at the and of a line
((match "comment" "declaration_list") php-ts-mode--anchor-prev-sibling 0)
((parent-is "declaration_list") column-0 php-ts-indent-offset)
((parent-is "initializer_list") parent-bol php-ts-indent-offset)
((parent-is "property_hook_list") parent-bol php-ts-indent-offset)
;; Statement in {} blocks.
((or (and (or (parent-is "compound_statement")
(parent-is "colon_block"))
;; If the previous sibling(s) are not on their
;; own line, indent as if this node is the first
;; sibling
php-ts-mode--first-sibling)
(or (match null "compound_statement")
(match null "colon_block")))
standalone-parent php-ts-indent-offset)
((or (parent-is "compound_statement")
(parent-is "colon_block"))
parent-bol php-ts-indent-offset)
;; Opening bracket.
((or (node-is "compound_statement")
(node-is "colon_block"))
standalone-parent php-ts-indent-offset)
((parent-is "match_block") parent-bol php-ts-indent-offset)
((parent-is "switch_block") parent-bol 0)
;; These rules are for cases where the body is bracketless.
((match "while" "do_statement") parent-bol 0)
;; rule for PHP alternative syntax
((or (node-is "else_if_clause")
(node-is "endif")
(node-is "endfor")
(node-is "endforeach")
(node-is "endwhile"))
parent-bol 0)
((or (parent-is "if_statement")
(parent-is "else_clause")
(parent-is "for_statement")
(parent-is "foreach_statement")
(parent-is "while_statement")
(parent-is "do_statement")
(parent-is "switch_statement")
(parent-is "case_statement")
(parent-is "empty_statement"))
parent-bol php-ts-indent-offset)
;; Do not touch the indentation inside a multiline the strings.
((parent-is "string_content") no-indent 0)
;; Workaround: handle "for" open statement group. Currently
;; the grammar handles it differently than other control structures.
(no-node prev-sibling 0))))
`((psr2
((parent-is "function_call_expression") parent-bol php-ts-indent-offset)
,@common)
(pear
((or (node-is "case_statement")
(node-is "default_statement"))
parent-bol 0)
((parent-is "binary_expression") parent-bol php-ts-indent-offset)
,@common)
(drupal
((parent-is "if_statement") parent-bol 0)
((parent-is "binary_expression") parent-bol php-ts-indent-offset)
((parent-is "function_call_expression") parent-bol php-ts-indent-offset)
,@common)
(symfony
((parent-is "function_call_expression") parent-bol php-ts-indent-offset)
,@common)
(wordpress
,@common)
(zend
((parent-is "class_interface_clause") php-ts-mode--anchor-first-sibling 0)
((parent-is "function_call_expression") first-sibling 0)
((parent-is "array_creation_expression") php-ts-mode--array-element-heuristic 0)
,@common))))