pxp-lang / pxp

A suite of high-performance tools for PHP developers – includes a code formatter, static analyser, language server and superset language.
https://pxplang.org
Other
784 stars 0 forks source link

Full open tag span position fixed #51

Closed supun-io closed 7 months ago

supun-io commented 7 months ago

I was working on #47 when I found this little bug:

<html><?php

The lexer sets 0 as the column of the <?php token span. This PR fixes it.

PS: I've tested with a test case, but I didn't add it so as not to pollute the beautifully organized code (I don't think you need bug test cases yet). but if you do let me, I'll add the test case as well.

ryangjchandler commented 7 months ago

@supun-io great spot! Since this is going to change the parse result, the snapshot tests will need to be regenerated but I can handle that since it's not documented anywhere yet.

ryangjchandler commented 7 months ago

Actually, no changes needed to existing tests since this only affected PHP tags after inline HTML code. I've added a test to cover this.

supun-io commented 7 months ago

@ryangjchandler thanks, as I have mentioned I was playing around with #47 and have some progress. So far something like <?php echo "Hello World" ?> works. However, it still needs some work to correctly generate whitespaces. If you have some time, would be able to take a look at the code to see if it looks like what you expect?

Basically, I'm converting the stmts and exprs to their respective code, and then I'm adding whitespace later (I don't think there's a way to handle tabs vs spaces though)

I saw there's a pxp-visitor crate but I'm not sure I should use that (or how). So far, stmt / expr pattern matching seems to be working. Do we need the visitor?

Looking forward to hearing from you. This is definitely a fun project to work on!

ryangjchandler commented 7 months ago

@supun-io It's easier if you open a draft PR and we can talk about it over there :^)