mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
feat(ts)(php): php support for treesitter backend (#56)
This commit is contained in:
parent
e2b643021f
commit
4cc67ee3d4
4 changed files with 129 additions and 0 deletions
|
@ -64,6 +64,14 @@ return {
|
|||
markdown = {
|
||||
atx_heading = "Interface",
|
||||
},
|
||||
php = {
|
||||
anonymous_function_creation_expression = "Function",
|
||||
class_declaration = "Class",
|
||||
function_definition = "Function",
|
||||
interface_declaration = "Interface",
|
||||
method_declaration = "Method",
|
||||
trait_declaration = "Class",
|
||||
},
|
||||
python = {
|
||||
function_definition = "Function",
|
||||
class_definition = "Class",
|
||||
|
|
20
queries/php/aerial.scm
Normal file
20
queries/php/aerial.scm
Normal file
|
@ -0,0 +1,20 @@
|
|||
(function_definition
|
||||
name: (name) @name) @type
|
||||
|
||||
(expression_statement
|
||||
(assignment_expression
|
||||
left: (variable_name) @name
|
||||
right: (anonymous_function_creation_expression) @type
|
||||
)) @start
|
||||
|
||||
(class_declaration
|
||||
name: (name) @name) @type
|
||||
|
||||
(method_declaration
|
||||
name: (name) @name) @type
|
||||
|
||||
(interface_declaration
|
||||
name: (name) @name) @type
|
||||
|
||||
(trait_declaration
|
||||
name: (name) @name) @type
|
86
tests/treesitter/php_spec.lua
Normal file
86
tests/treesitter/php_spec.lua
Normal file
|
@ -0,0 +1,86 @@
|
|||
local util = require("tests.test_util")
|
||||
|
||||
describe("treesitter php", function()
|
||||
it("parses all symbols correctly", function()
|
||||
util.test_file_symbols("treesitter", "./tests/treesitter/php_test.php", {
|
||||
{
|
||||
kind = "Function",
|
||||
name = "my_function",
|
||||
level = 0,
|
||||
lnum = 2,
|
||||
col = 0,
|
||||
end_lnum = 2,
|
||||
end_col = 27,
|
||||
},
|
||||
{
|
||||
kind = "Function",
|
||||
name = "$var_function",
|
||||
level = 0,
|
||||
lnum = 4,
|
||||
col = 0,
|
||||
end_lnum = 4,
|
||||
end_col = 32,
|
||||
},
|
||||
{
|
||||
kind = "Class",
|
||||
name = "MyClass",
|
||||
level = 0,
|
||||
lnum = 6,
|
||||
col = 0,
|
||||
end_lnum = 8,
|
||||
end_col = 1,
|
||||
children = {
|
||||
{
|
||||
kind = "Method",
|
||||
name = "myMethod",
|
||||
level = 1,
|
||||
lnum = 7,
|
||||
col = 4,
|
||||
end_lnum = 7,
|
||||
end_col = 34,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind = "Interface",
|
||||
name = "InterfaceOne",
|
||||
level = 0,
|
||||
lnum = 9,
|
||||
col = 0,
|
||||
end_lnum = 11,
|
||||
end_col = 1,
|
||||
children = {
|
||||
{
|
||||
kind = "Method",
|
||||
name = "doSomething",
|
||||
level = 1,
|
||||
lnum = 10,
|
||||
col = 4,
|
||||
end_lnum = 10,
|
||||
end_col = 34,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
kind = "Class",
|
||||
name = "MyTrait",
|
||||
level = 0,
|
||||
lnum = 13,
|
||||
col = 0,
|
||||
end_lnum = 15,
|
||||
end_col = 1,
|
||||
children = {
|
||||
{
|
||||
kind = "Method",
|
||||
name = "myTraitMethod",
|
||||
level = 1,
|
||||
lnum = 14,
|
||||
col = 4,
|
||||
end_lnum = 14,
|
||||
end_col = 39,
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end)
|
||||
end)
|
15
tests/treesitter/php_test.php
Normal file
15
tests/treesitter/php_test.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
function my_function () { }
|
||||
|
||||
$var_function = function () { };
|
||||
|
||||
class MyClass {
|
||||
public function myMethod() { }
|
||||
}
|
||||
interface InterfaceOne {
|
||||
public function doSomething();
|
||||
}
|
||||
|
||||
trait MyTrait {
|
||||
public function myTraitMethod() { }
|
||||
}
|
Loading…
Reference in a new issue