tree-sitter-php icon indicating copy to clipboard operation
tree-sitter-php copied to clipboard

tree-sitter-php seems to ignore __DIR__

Open etu opened this issue 1 year ago • 1 comments

I've just started to try out tree-sitter, one thing that I noticed straight away is that it seems to ignore __DIR__, a bunch of other of constants (like __FILE__) is handled much better.

See screenshot: image

I did find #144, however that was a while ago and this is more specific to just __DIR__ :slightly_smiling_face:

EDIT: Code:

<?php

echo(__FILE__);
echo(__DIR__);
echo(__FUNCTION__);
echo(__METHOD__);
echo(__CLASS__);
echo(__TRAIT__);
echo(__NAMESPACE__);
echo(__LINE__);

Debug:

program:
  php_tag:
  echo_statement:
    parenthesized_expression:
      name:
  echo_statement:
    parenthesized_expression:
      name:
  echo_statement:
    parenthesized_expression:
      name:
  echo_statement:
    parenthesized_expression:
      name:
  echo_statement:
    parenthesized_expression:
      name:
  echo_statement:
    parenthesized_expression:
      name:
  echo_statement:
    parenthesized_expression:
      name:
  echo_statement:
    parenthesized_expression:
      name:

And now I'm realizing that they are all the same... so... it's something weird with something else... like in the emacs mode maybe that displays this... or something maybe that conflicts with php-mode... or something... I'm not sure. The parser does this fine.

etu avatar Aug 24 '22 16:08 etu

Thanks for reporting!

I don't have time to do a deep investigation right now, but from a quick glance I guess we'll need to make a few updates to highlight.scm to make your issues go away. Some of them are simply me forgetting to update the queries to match the improvements in the parser.

If you have time to play with it, a PR would be most welcome 🙂

cfroystad avatar Aug 24 '22 18:08 cfroystad

I've updated the highlights file to fix this and your other issues. Thanks for reporting!

cfroystad avatar Sep 24 '22 06:09 cfroystad