Skip to content

[Yaml] Fix wrong line number when comments are inserted in the middle of a block. #17733

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

Conversation

paradajozsef
Copy link
Contributor

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #15437
License MIT
Doc PR -

@xabbuh what is your opinion a solution like this? (counting the skipped comment lines and when exception occurs add them to the current line count.)

@xabbuh
Copy link
Member

xabbuh commented Feb 9, 2016

@paradajozsef I think the fix is a bit more complex. For example, I do not think that this will solve the issue for the following example too:

foo:
    -
        # foobar
        baz: 123
bar:
    -
        # bar
        bar: "123",

Can you add it as a test case too?

@paradajozsef
Copy link
Contributor Author

@xabbuh Sorry for late answer. I added the test case and as always you are right again. 😃 In this case the line number is 9, but it should be 8. 😕 Still needs work.

@paradajozsef
Copy link
Contributor Author

@xabbuh I changed the fix. getNextEmbedBlock will only skip comment lines, if comments are not in a collection. WDUT?

The above test case passes, failing VarDumper tests unrelated imo.

@paradajozsef
Copy link
Contributor Author

Status: Needs Review

*
* @return bool
*/
private function isPreviousNonCommentLineIsCollectionItem()
Copy link
Member

Choose a reason for hiding this comment

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

method name is weird. It contains is twice

@fabpot
Copy link
Member

fabpot commented Apr 28, 2016

ping @xabbuh

@paradajozsef
Copy link
Contributor Author

I apologize to everyone for late answer. (I've been lack of internet at home lately because of moving to another place.)

@stof Thanks for the review. I changed the comment and method name. What about checkIfPreviousNonCommentLineIsCollectionItem? It's still kind of wierd imo. Any other ide is very welcome! Thanks!

@xabbuh
Copy link
Member

xabbuh commented May 6, 2016

@paradajozsef Can you please rebase and push again? Looks like Travis otherwise will not run builds for your changes otherwise.

@paradajozsef
Copy link
Contributor Author

Sure, I can do it tonight.

@stof
Copy link
Member

stof commented May 6, 2016

@xabbuh the reason why Travis does not run tests is because the branch conflicts. As Travis is actually running PR tests on a merge commit rather than on the feature branch, it cannot run them in case of conflicts

@paradajozsef paradajozsef force-pushed the 15437-fix-yaml-parse-exception-line-number branch from adb111d to bf4501a Compare May 6, 2016 22:23
@paradajozsef
Copy link
Contributor Author

Rebase is done, tests are green.

{
$isCollectionItem = false;
$moves = 0;
while($this->moveToPreviousLine()) {
Copy link
Member

@xabbuh xabbuh May 10, 2016

Choose a reason for hiding this comment

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

please add a space before the opening parenthesis (right after the while keyword)

@xabbuh
Copy link
Member

xabbuh commented May 10, 2016

👍

Status: Reviewed

ping @symfony/deciders

@paradajozsef
Copy link
Contributor Author

@xabbuh Thx for the review, I fixed them.

@fabpot
Copy link
Member

fabpot commented Jun 8, 2016

Thank you @paradajozsef.

fabpot added a commit that referenced this pull request Jun 8, 2016
… the middle of a block. (paradajozsef)

This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #17733).

Discussion
----------

[Yaml] Fix wrong line number when comments are inserted in the middle of a block.

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15437
| License       | MIT
| Doc PR        | -

@xabbuh what is your opinion a solution like this? (counting the skipped comment lines and when exception occurs add them to the current line count.)

Commits
-------

d83e346 [Yaml] Fix wrong line number when comments are inserted in the middle of a block.
@fabpot fabpot closed this Jun 8, 2016
@paradajozsef paradajozsef deleted the 15437-fix-yaml-parse-exception-line-number branch June 10, 2016 09:40
fabpot added a commit that referenced this pull request Jun 12, 2016
This PR was merged into the 2.7 branch.

Discussion
----------

[Yaml] properly count skipped comment lines

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15437, #17733, #19023
| License       | MIT
| Doc PR        |

Commits
-------

da7fc36 [Yaml] properly count skipped comment lines
@fabpot fabpot mentioned this pull request Jun 15, 2016
This was referenced Jun 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants