Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix php-ts-mode--defun-name #51

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions php-ts-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -232,15 +232,17 @@ see https://www.php.net/manual/language.constants.predefined.php")
`((["(" ")" "[" "]" "{" "}"]) @font-lock-bracket-face))
"Tree-sitter font-lock settings for `php-ts-mode'.")

(defun php-ts-mode--defun-name (node)
(defun php-ts-mode--defun-name (node)
"Return the defun name of NODE.
Return nil if there is no name or if NODE is not a defun node."
(pcase (treesit-node-type node)
((or "class_declaration"
"enum_declaration"
"function_definition"
"interface_declaration"
"method_declaration"
"namespace_definition")
"namespace_definition"
"trait_declaration")
(treesit-node-text
(treesit-node-child-by-field-name node "name")
t))))
Expand Down Expand Up @@ -314,6 +316,7 @@ Currently there are `php-mode' and `php-ts-mode'."
("Enum" "\\`enum_declaration\\'" nil nil)
("Class" "\\`class_declaration\\'" nil nil)
("Interface" "\\`interface_declaration\\'" nil nil)
("Trait" "\\`trait_declaration\\'" nil nil)
("Method" "\\`method_declaration\\'" nil nil)))

(treesit-major-mode-setup))
Expand Down
Loading