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

Tree-sitter fixes for December (including a PHP grammar!) #852

Merged
Merged
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
a8f5b17
[tree-sitter] Fold on type objects in TypeScript
savetheclocktower Dec 18, 2023
a1e9fa0
[tree-sitter] Make the shell grammar's file types match the TM grammar's
savetheclocktower Dec 19, 2023
daf0637
Do the same for the modern Tree-sitter grammar
savetheclocktower Dec 19, 2023
818d204
[tree-sitter] Add the pipe character (`|`) as an operator
savetheclocktower Dec 19, 2023
037377a
[tree-sitter] Ruby fixes…
savetheclocktower Dec 21, 2023
1ed79e2
[tree-sitter] Fix indentation hinting at the edges of injections
savetheclocktower Dec 23, 2023
fdc70fc
[tree-sitter] Highlight an obscure inheritance construct properly in C++
savetheclocktower Dec 23, 2023
20a64bd
Allow `suggestedIndentForBufferRows` to work correctly…
savetheclocktower Dec 23, 2023
be37b26
[tree-sitter] Don't highlight JS default param values like parameters
savetheclocktower Dec 24, 2023
f6bb61f
[tree-sitter] Highlight assertion function clauses in TypeScript
savetheclocktower Dec 25, 2023
da10036
[tree-sitter] Fix JSX dedent logic
savetheclocktower Dec 25, 2023
bc55c4f
[tree-sitter] Further JSX indent fixes for JS and TS alike
savetheclocktower Dec 25, 2023
7b4a50d
(oops)
savetheclocktower Dec 26, 2023
66aea45
[tree-sitter] Fixes for shell script highlighting
savetheclocktower Dec 29, 2023
294134c
[tree-sitter] Highlight private fields similarly to other JS properties
savetheclocktower Jan 2, 2024
ee54d37
[tree-sitter] Highlight TypeScript `infer` clauses properly
savetheclocktower Jan 3, 2024
d6f8a3c
Add a modern Tree-sitter PHP grammar
savetheclocktower Jan 5, 2024
00de52c
Add `parserSource` fields where appropriate
savetheclocktower Jan 5, 2024
1dc1536
Remove logging from injection callback
savetheclocktower Jan 5, 2024
0fd47f5
Skip incorrect CI behavior on changes to `web-tree-sitter` itself
savetheclocktower Jan 5, 2024
ee3f41e
Don't try to parse non-CSON files as CSON
savetheclocktower Jan 5, 2024
3a4b2dc
Handle nowdocs in PHP
savetheclocktower Jan 5, 2024
8ae599f
[tree-sitter] TS: Treat parameters with defaults like parameters…
savetheclocktower Jan 5, 2024
b6d88a5
Update `tree-sitter-php` WASM file to latest `master`
savetheclocktower Jan 5, 2024
18788c0
Address feedback on PHP syntax highlighting
savetheclocktower Jan 8, 2024
f6e1a22
Apply PHPDoc learnings to JSDoc
savetheclocktower Jan 9, 2024
5e62e20
[tree-sitter] Add TODO and hyperlink injections to Java
savetheclocktower Jan 9, 2024
0807dcf
Add TODO and hyperlink injections to Rust
savetheclocktower Jan 9, 2024
bbf4cb4
Add TODO and hyperlink injections to C/C++
savetheclocktower Jan 9, 2024
351493f
Only inject TODO and hyperlink into CSS when needed
savetheclocktower Jan 9, 2024
bf039cc
Don't add root scopes to CSS for TODO/hyperlink injections
savetheclocktower Jan 9, 2024
ebd0ae0
Add TODO and hyperlink injections to Go
savetheclocktower Jan 9, 2024
e2da555
Add hyperlink injection to JSON
savetheclocktower Jan 9, 2024
70b34cd
Add TODO and hyperlink injections to YAML comments
savetheclocktower Jan 9, 2024
a40bae4
Allow `(#set! capture.final)` as shorthand…
savetheclocktower Jan 9, 2024
30f696f
Address more PHP grammar feedback
savetheclocktower Jan 10, 2024
9db2ace
[tree-sitter] Add the pipe character (`|`) as an operator
savetheclocktower Dec 19, 2023
0e8fe9b
[tree-sitter] Fix indentation hinting at the edges of injections
savetheclocktower Dec 23, 2023
a42d0ed
Allow `suggestedIndentForBufferRows` to work correctly…
savetheclocktower Dec 23, 2023
d32bdf6
[tree-sitter] Highlight assertion function clauses in TypeScript
savetheclocktower Dec 25, 2023
d9f6946
[tree-sitter] Fix JSX dedent logic
savetheclocktower Dec 25, 2023
0b51a77
[tree-sitter] Further JSX indent fixes for JS and TS alike
savetheclocktower Dec 25, 2023
aef7c84
(oops)
savetheclocktower Dec 26, 2023
b7dc654
[tree-sitter] Fixes for shell script highlighting
savetheclocktower Dec 29, 2023
d148a73
Add a modern Tree-sitter PHP grammar
savetheclocktower Jan 5, 2024
c93bdeb
Add `parserSource` fields where appropriate
savetheclocktower Jan 5, 2024
ad8a215
Remove logging from injection callback
savetheclocktower Jan 5, 2024
58b9cc1
Handle nowdocs in PHP
savetheclocktower Jan 5, 2024
8c946a0
[tree-sitter] TS: Treat parameters with defaults like parameters…
savetheclocktower Jan 5, 2024
f2dabe5
Update `tree-sitter-php` WASM file to latest `master`
savetheclocktower Jan 5, 2024
2580642
Address feedback on PHP syntax highlighting
savetheclocktower Jan 8, 2024
8836be7
Only inject TODO and hyperlink into CSS when needed
savetheclocktower Jan 9, 2024
0b08306
Don't add root scopes to CSS for TODO/hyperlink injections
savetheclocktower Jan 9, 2024
336f609
More PHP grammar feedback
savetheclocktower Jan 10, 2024
c50b0e6
More PHP grammar feedback
savetheclocktower Jan 10, 2024
4c6b0ba
Ensure indentation decisions consult the correct layers…
savetheclocktower Jan 10, 2024
254440e
Oops
savetheclocktower Jan 11, 2024
50bfa51
Update `tree-sitter-json` WASM build to latest
savetheclocktower Jan 11, 2024
865153b
Address newly failing tests
savetheclocktower Jan 12, 2024
ddfa645
Fix issue where `symbol-provider-ctags` used the wrong package root
savetheclocktower Jan 12, 2024
9972245
[symbols-view] Allow for scope-specific overrides of preferred providers
savetheclocktower Jan 12, 2024
a34b01b
In JS/TS, correctly highlight a variable with a default value…
savetheclocktower Jan 12, 2024
e78feea
Address more PHP grammar feedback
savetheclocktower Jan 10, 2024
62bd6cc
Even more PHP grammar feedback
savetheclocktower Jan 13, 2024
f3be33b
Add `<>` and `<=>` operators in PHP
savetheclocktower Jan 13, 2024
bae3689
Add folds for PHP
savetheclocktower Jan 13, 2024
6ebdfa0
Remove unneeded file
savetheclocktower Jan 13, 2024
0111e13
PHP feedback
savetheclocktower Jan 13, 2024
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
101 changes: 85 additions & 16 deletions packages/language-php/grammars/tree-sitter/queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,60 @@
(class_declaration (base_clause (name) @entity.other.inherited-class.php))
(class_declaration (class_interface_clause (name) @entity.other.implemented-interface.php))

; Static method calls.
; The "Foo" and "Bar" in `use Bar, Foo;`
(use_declaration (name) @support.other.trait.php)

; The "Foo" in `Baz::thud insteadof Foo;`
(use_instead_of_clause (name) @support.other.trait.php .
(#set! capture.final true))

; In `use` lists, the "bar" in `Foo::bar` is a method, not a constant.
(use_list
(_
(class_constant_access_expression (name) @support.other.function.method.php .)
)
(#set! capture.final true))

; The "Foo" and "bar" in `Foo::bar`.
(class_constant_access_expression . (name) @support.class.php)
(class_constant_access_expression (name) @support.other.property.php .)

; The "Foo" and "bar" in "Foo::bar()".
(scoped_call_expression
scope: (name) @support.class.php
name: (name) @support.other.function.method.static.php)

; The "Foo" and "$bar" in "Foo::$bar()".
(scoped_call_expression
scope: (name) @support.class.php)
(scoped_call_expression
name: (variable_name) @variable.other.method.static.php)

; The "Foo" and "$bar" in `Foo::$bar`.
(scoped_property_access_expression
scope: (name) @support.class.php)
(scoped_property_access_expression
name: (variable_name) @variable.other.property.static.php
(#set! capture.final true))

; The "bar" in `$foo->bar()`.
(member_call_expression
name: (name) @support.other.function.method.php)

(scoped_call_expression
scope: (name) @support.class.php)
; The "bar" in `$foo->bar`.
(member_access_expression
name: (name) @support.other.property.php
(#set! capture.final true))

; The "$bar" in `$foo->$bar()`.
(member_call_expression
name: (variable_name) @variable.other.method.php
(#set! capture.final true))

; The "$bar" in `$foo->$bar`.
(member_access_expression
name: (variable_name) @variable.other.property.php
(#set! capture.final true))


; TRAITS
Expand All @@ -262,6 +307,12 @@
(trait_declaration (name) @entity.name.type.trait.php)


; INTERFACES
; ==========

(interface_declaration (name) @entity.name.type.interface.php)


; TYPES
; =====

Expand All @@ -272,11 +323,22 @@

"global" @storage.modifier.global.php

["trait" "class"] @storage.type._TYPE_.php
["enum" "interface" "trait" "class"] @storage.type._TYPE_.php
(enum_case "case" @storage.type.case.php)
"function" @storage.type.function.php
"fn" @storage.type.function.arrow.php


; ENUMS
; =====

(enum_declaration
name: (name) @entity.name.type.enum.php)

(enum_declaration_list
(enum_case
name: (name) @constant.other.enum.php))

; VARIABLES
; =========

Expand All @@ -300,11 +362,6 @@
"$" @punctuation.definition.variable.php
) @variable.parameter.php))

; The "$bar" in `$foo->$bar`.
(member_access_expression
name: (variable_name) @variable.other.property.php
(#set! capture.final true))

((variable_name
("$" @punctuation.definition.variable.php)
(name) @_IGNORE_) @variable.other.php
Expand Down Expand Up @@ -349,10 +406,8 @@


[
"abstract"
"as"
"break"
"case"
"catch"
"const"
"continue"
Expand All @@ -367,16 +422,12 @@
"endif"
"endswitch"
"endwhile"
"extends"
"finally"
"foreach"
"if"
"implements"
"include_once"
"include"
"insteadof"
"interface"
"namespace"
"new"
"require_once"
"require"
Expand All @@ -388,8 +439,14 @@
"while"
] @keyword.control._TYPE_.php

(case_statement "case" @keyword.control.case.php)

[
"abstract"
"extends"
"final"
"implements"
"namespace"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] is this because namespace controls how we address the class in usage (eg by changing its namespace)? I would have pegged it more as a keyword (which is how TM scopes it).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace declares an entity. Just like class or function. If those are storage, so is namespace.

"private"
"protected"
"public"
Expand Down Expand Up @@ -451,7 +508,11 @@
(optional_type "?" @keyword.operator.nullable-type.php)
(union_type "|" @keyword.operator.union-type.php)

["&&" "||"] @keyword.operator.logical.php
[
"&&"
"||"
"??"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that this is correct. ?? isn't a logical operator like && and ||. I suggest moving it to keyword.operator.comparison.php. [docs]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if you agree, then it looks like <> and <=> could also be added as comparison operators: https://www.php.net/manual/en/language.operators.comparison.php

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If || is a logical operator, so is ??. The former will return the left-hand side unless it's falsy. The latter returns the left-hand side unless it's null.

<> and <=>, on the other hand, are comparison operators, so I'll add them as such.

] @keyword.operator.logical.php

["="] @keyword.operator.assignment.php

Expand Down Expand Up @@ -484,7 +545,15 @@
"-="
"*="
"/="
"%="
"**="
"&="
"|="
"^="
"<<="
">>="
".="
"??="
] @keyword.operator.assignment.compound.php

"->" @keyword.operator.class.php
Expand Down
Loading