-
-
Notifications
You must be signed in to change notification settings - Fork 130
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
WIP: Refactor handling of code blocks with just comments #513
Conversation
I tried fixing #509 and got the feeling that we might make our lives much easier by creating new AST nodes for code blocks that contain just comments, so I gave it a try. It seems to work quite well, but I still have issues with linebreaks/whitespace introduced by |
@czosel i can look on this at Monday, little vacation, also we have some regression after last commit (comments), i will create issue. Also i think we should create issue in parser, maybe new option for this or modify standard behavior. |
@evilebottnawi no rush, enjoy your vacation 😉 |
c11de07
to
f7ffd41
Compare
@@ -184,15 +184,11 @@ exports[`blank_lines.php 1`] = ` | |||
|
|||
// Other comment | |||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |||
<?php | |||
// The first line of a comment | |||
<?php // The first line of a comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to glayzzle/php-parser#169
: " "; | ||
afterOpenTag = | ||
between[2].includes("\n") && | ||
firstNestedChildNode.kind !== "lonelyComment" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug with
extra here
To be honest, I'm not sure that the idea of creating new ast nodes is good. Can you add link on issue in source code? |
@evilebottnawi done! I agree that the "post-production" AST manipulation doesn't seem very clean. The printer code is quite clean though, and it seems to me that any other approach without parser changes is not working/really hard to maintain. We should try to keep "our" AST closely aligned with what the PHP parser will do in the future, then migration will be easy. |
Also need fix space and we can merge |
@czosel Please read #532 (comment). Let's search solution without new ast nodes (fix it in parser or prepare text for parser). |
@evilebottnawi agreed. |
Fixes #509