mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
feat(php): add support for new relative_name node
This commit is contained in:
parent
93ce9feb4f
commit
081a99b3be
4 changed files with 175 additions and 34 deletions
|
|
@ -552,10 +552,10 @@
|
||||||
"revision": "bb53f204aa3e7507960014642965c9f9a9e84b1d"
|
"revision": "bb53f204aa3e7507960014642965c9f9a9e84b1d"
|
||||||
},
|
},
|
||||||
"php": {
|
"php": {
|
||||||
"revision": "f3a19ab3217a6e838870fc7142fa492d1fd7a7c9"
|
"revision": "b22484c92180e6e30c14477f00e1c7f9d2e39304"
|
||||||
},
|
},
|
||||||
"php_only": {
|
"php_only": {
|
||||||
"revision": "f3a19ab3217a6e838870fc7142fa492d1fd7a7c9"
|
"revision": "b22484c92180e6e30c14477f00e1c7f9d2e39304"
|
||||||
},
|
},
|
||||||
"phpdoc": {
|
"phpdoc": {
|
||||||
"revision": "fe3202e468bc17332bec8969f2b50ff1f1da3a46"
|
"revision": "fe3202e468bc17332bec8969f2b50ff1f1da3a46"
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,8 @@
|
||||||
(name) @type
|
(name) @type
|
||||||
(qualified_name
|
(qualified_name
|
||||||
(name) @type)
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
])
|
])
|
||||||
|
|
||||||
(named_type
|
(named_type
|
||||||
|
|
@ -208,6 +210,8 @@
|
||||||
(name) @type
|
(name) @type
|
||||||
(qualified_name
|
(qualified_name
|
||||||
(name) @type)
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
])
|
])
|
||||||
|
|
||||||
(enum_declaration
|
(enum_declaration
|
||||||
|
|
@ -269,6 +273,8 @@
|
||||||
(name) @type
|
(name) @type
|
||||||
(qualified_name
|
(qualified_name
|
||||||
(name) @type)
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
])
|
])
|
||||||
|
|
||||||
(scoped_call_expression
|
(scoped_call_expression
|
||||||
|
|
@ -276,6 +282,8 @@
|
||||||
(name) @type
|
(name) @type
|
||||||
(qualified_name
|
(qualified_name
|
||||||
(name) @type)
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
])
|
])
|
||||||
|
|
||||||
(class_constant_access_expression
|
(class_constant_access_expression
|
||||||
|
|
@ -284,6 +292,8 @@
|
||||||
(name) @type
|
(name) @type
|
||||||
(qualified_name
|
(qualified_name
|
||||||
(name) @type)
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
]
|
]
|
||||||
(name) @constant)
|
(name) @constant)
|
||||||
|
|
||||||
|
|
@ -292,6 +302,8 @@
|
||||||
(name) @type
|
(name) @type
|
||||||
(qualified_name
|
(qualified_name
|
||||||
(name) @type)
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
])
|
])
|
||||||
|
|
||||||
(scoped_property_access_expression
|
(scoped_property_access_expression
|
||||||
|
|
@ -309,6 +321,8 @@
|
||||||
(name) @type
|
(name) @type
|
||||||
(qualified_name
|
(qualified_name
|
||||||
(name) @type)
|
(name) @type)
|
||||||
|
(relative_name
|
||||||
|
(name) @type)
|
||||||
])
|
])
|
||||||
|
|
||||||
; Functions, methods, constructors
|
; Functions, methods, constructors
|
||||||
|
|
@ -326,11 +340,13 @@
|
||||||
name: (name) @function.method)
|
name: (name) @function.method)
|
||||||
|
|
||||||
(function_call_expression
|
(function_call_expression
|
||||||
function: (qualified_name
|
function: [
|
||||||
(name) @function.call))
|
(name) @function.call
|
||||||
|
(qualified_name
|
||||||
(function_call_expression
|
(name) @function.call)
|
||||||
(name) @function.call)
|
(relative_name
|
||||||
|
(name) @function.call)
|
||||||
|
])
|
||||||
|
|
||||||
(scoped_call_expression
|
(scoped_call_expression
|
||||||
name: (name) @function.call)
|
name: (name) @function.call)
|
||||||
|
|
@ -365,6 +381,8 @@
|
||||||
(name) @constructor
|
(name) @constructor
|
||||||
(qualified_name
|
(qualified_name
|
||||||
(name) @constructor)
|
(name) @constructor)
|
||||||
|
(relative_name
|
||||||
|
(name) @constructor)
|
||||||
])
|
])
|
||||||
|
|
||||||
; Parameters
|
; Parameters
|
||||||
|
|
@ -410,6 +428,9 @@
|
||||||
(namespace_name
|
(namespace_name
|
||||||
(name) @module)
|
(name) @module)
|
||||||
|
|
||||||
|
(relative_name
|
||||||
|
"namespace" @module.builtin)
|
||||||
|
|
||||||
; Attributes
|
; Attributes
|
||||||
(attribute_list) @attribute
|
(attribute_list) @attribute
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,49 +2,22 @@
|
||||||
|
|
||||||
namespace Foo\Bar;
|
namespace Foo\Bar;
|
||||||
//^^^^^^^ @keyword.type
|
//^^^^^^^ @keyword.type
|
||||||
// ^^^ @module
|
|
||||||
// ^^^ @module
|
|
||||||
|
|
||||||
use Foo\Baz as Baaz;
|
use Foo\Baz as Baaz;
|
||||||
//^ @keyword.import
|
//^ @keyword.import
|
||||||
// ^^^ @module
|
|
||||||
// ^^^ @type
|
|
||||||
// ^^ @keyword.operator
|
// ^^ @keyword.operator
|
||||||
// ^^^^ @type.definition
|
|
||||||
|
|
||||||
use Foo\Baz\{Foo, Bar};
|
|
||||||
// ^^^ @type
|
|
||||||
// ^^^ @type
|
|
||||||
|
|
||||||
use function Foo\foo as fooo;
|
use function Foo\foo as fooo;
|
||||||
// ^^^^^^^^ @keyword.function
|
// ^^^^^^^^ @keyword.function
|
||||||
// ^^^ @function
|
|
||||||
// ^^^^ @function
|
|
||||||
|
|
||||||
use function Foo\{bar, baz};
|
|
||||||
// ^^^ @function
|
|
||||||
// ^^^ @function
|
|
||||||
|
|
||||||
use const Foo\FOO as FOOO;
|
use const Foo\FOO as FOOO;
|
||||||
// ^^^^^ @keyword.modifier
|
// ^^^^^ @keyword.modifier
|
||||||
// ^^^ @constant
|
|
||||||
// ^^^^ @constant
|
|
||||||
|
|
||||||
use const Foo\{FOO, BAR};
|
|
||||||
// ^^^ @constant
|
|
||||||
// ^^^ @constant
|
|
||||||
|
|
||||||
use Foo\Baz\{
|
use Foo\Baz\{
|
||||||
// ^^^ @module
|
|
||||||
// ^^^ @module
|
|
||||||
Bar,
|
|
||||||
//^^^ @type
|
|
||||||
function foo,
|
function foo,
|
||||||
//^^^^^^^^ @keyword.function
|
//^^^^^^^^ @keyword.function
|
||||||
// ^^^ @function
|
|
||||||
const FOO,
|
const FOO,
|
||||||
//^^^^^ @keyword.modifier
|
//^^^^^ @keyword.modifier
|
||||||
// ^^^ @constant
|
|
||||||
};
|
};
|
||||||
|
|
||||||
abstract class A
|
abstract class A
|
||||||
|
|
|
||||||
147
tests/query/highlights/php/namespaces.php
Normal file
147
tests/query/highlights/php/namespaces.php
Normal file
|
|
@ -0,0 +1,147 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Foo\Bar;
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @module
|
||||||
|
|
||||||
|
use Baz as Baaz;
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^^ @type
|
||||||
|
use Foo\Baz as Baaz;
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^^ @type
|
||||||
|
|
||||||
|
use Foo\{Bar, Baz as Baaz};
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^^ @type
|
||||||
|
|
||||||
|
use function foo as fooo;
|
||||||
|
// ^^^ @function
|
||||||
|
// ^^^^ @function
|
||||||
|
//
|
||||||
|
use function Foo\foo as fooo;
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @function
|
||||||
|
// ^^^^ @function
|
||||||
|
use function Foo\{bar, foo as fooo};
|
||||||
|
// ^^^ @function
|
||||||
|
// ^^^ @function
|
||||||
|
// ^^^^ @function
|
||||||
|
use const FOO as FOOO;
|
||||||
|
// ^^^ @constant
|
||||||
|
// ^^^^ @constant
|
||||||
|
use const Foo\FOO as FOOO;
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @constant
|
||||||
|
// ^^^^ @constant
|
||||||
|
use const Foo\{FOO as FOOO, BAR};
|
||||||
|
// ^^^ @constant
|
||||||
|
// ^^^^ @constant
|
||||||
|
// ^^^ @constant
|
||||||
|
|
||||||
|
use Foo\Baz\{
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @module
|
||||||
|
Bar as Barr,
|
||||||
|
//^^^ @type
|
||||||
|
// ^^^^ @type
|
||||||
|
Foo\Bar as Barr,
|
||||||
|
//^^^ @module
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^^ @type
|
||||||
|
function foo as fooo,
|
||||||
|
// ^^^ @function
|
||||||
|
// ^^^^ @function
|
||||||
|
function Foo\foo as fooo,
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @function
|
||||||
|
// ^^^^ @function
|
||||||
|
const FOO as FOOO,
|
||||||
|
// ^^^ @constant
|
||||||
|
// ^^^^ @constant
|
||||||
|
const Foo\FOO as FOOO,
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @constant
|
||||||
|
// ^^^^ @constant
|
||||||
|
};
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
public function foo() {
|
||||||
|
Bar::foo();
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^ @function.call
|
||||||
|
\Bar::foo();
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^ @function.call
|
||||||
|
Foo\Bar::foo();
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^ @function.call
|
||||||
|
\Foo\Bar::foo();
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^ @function.call
|
||||||
|
namespace\Bar::foo();
|
||||||
|
// ^^^^^^^^^ @module.builtin
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^ @function.call
|
||||||
|
namespace\Foo\Bar::foo();
|
||||||
|
// ^^^^^^^^^ @module.builtin
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @type
|
||||||
|
// ^^^ @function.call
|
||||||
|
new Bar();
|
||||||
|
// ^^^ @constructor
|
||||||
|
new \Bar();
|
||||||
|
// ^^^ @constructor
|
||||||
|
new Foo\Bar();
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @constructor
|
||||||
|
new \Foo\Bar();
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @constructor
|
||||||
|
new namespace\Bar();
|
||||||
|
// ^^^^^^^^^ @module.builtin
|
||||||
|
// ^^^ @constructor
|
||||||
|
new namespace\Foo\Bar();
|
||||||
|
// ^^^^^^^^^ @module.builtin
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @constructor
|
||||||
|
BAZ;
|
||||||
|
// ^^^ @constant
|
||||||
|
\BAZ;
|
||||||
|
// ^^^ @constant
|
||||||
|
Foo\BAZ;
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @constant
|
||||||
|
\Foo\BAZ;
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @constant
|
||||||
|
namespace\BAZ;
|
||||||
|
// ^^^^^^^^^ @module.builtin
|
||||||
|
// ^^^ @constant
|
||||||
|
namespace\Foo\BAZ;
|
||||||
|
// ^^^^^^^^^ @module.builtin
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @constant
|
||||||
|
foo();
|
||||||
|
// ^^^ @function.call
|
||||||
|
\foo();
|
||||||
|
// ^^^ @function.call
|
||||||
|
Foo\foo();
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @function.call
|
||||||
|
\Foo\foo();
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @function.call
|
||||||
|
namespace\foo();
|
||||||
|
// ^^^^^^^^^ @module.builtin
|
||||||
|
// ^^^ @function.call
|
||||||
|
namespace\Foo\foo();
|
||||||
|
// ^^^^^^^^^ @module.builtin
|
||||||
|
// ^^^ @module
|
||||||
|
// ^^^ @function.call
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue