X Tutup
Skip to content

fix(Parser): Parse pipes in arguments#2348

Closed
vicb wants to merge 1 commit intoangular:masterfrom
vicb:0604-pipe
Closed

fix(Parser): Parse pipes in arguments#2348
vicb wants to merge 1 commit intoangular:masterfrom
vicb:0604-pipe

Conversation

@vicb
Copy link
Copy Markdown
Contributor

@vicb vicb commented Jun 4, 2015

fixes #1680

/cc @gdi2290

@vicb vicb added type: bug/fix comp: core action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 4, 2015
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Jun 4, 2015

@vsavkin there are actually more place where this should be updated. I'll take care of them tomorrow but it would be great if you can validate the changes here anyway. Thanks.

@PatrickJS
Copy link
Copy Markdown
Contributor

👍 sweet

@vsavkin
Copy link
Copy Markdown
Contributor

vsavkin commented Jun 5, 2015

looks good

@vicb vicb force-pushed the 0604-pipe branch 2 times, most recently from 6d4d1f1 to 167eba1 Compare June 5, 2015 10:46
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Jun 5, 2015

@vsavkin I have refactored the PR. ParsePipe() is now only called from parsePrimary() meaning that it could be applied to any primary expression.

It used to be called at different places before.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there needs to be another test with
parseBinding('a( b() | c )')

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is no need to test this because it works, trust me :)

In in ideal world, there should be a test for any kind of primary expression. But visiting the tree to check the expression is really a pain and I don't want to go this road.

Once we have a visitor to convert an AST back to an exp, we can add more test, ie
expect(toExpression(parseBinding('a( b() | c )').ast)).toEqual('a(b()|c').

There is an issue for that #1949 - it would be great if someone from the community could tackle this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's not that I don't trust you. I'm only suggesting the error wasn't with that example because that already worked alpha.21. The problem is when you introduce more parentheses inside of the arguments with a pipe. In the jsbint above if you change
{{ wat(number.get | async) }} to {{ wat(number.getAsync() | async) }} then you will see the error

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I know what you mean and it was because AccessMember and MethodCall were not handled in the same way, see https://github.com/angular/angular/pull/2348/files#diff-a200f3d86e80e2bea53a7a9ca4d40a10L475 above, Pipe were parsed only for the former and not for the later.

As explained above, parse are now parsed for any Primary expression (https://github.com/angular/angular/pull/2348/files#diff-a200f3d86e80e2bea53a7a9ca4d40a10R424) and to be exhaustive we would need to test all the 10 cases. I prefer to defer that to when we can convert AST back to expressions.

Note that referring to the issue from my previous comment has added a link there and we should add those tests when we'll add the visitor.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I understand now, thanks for clearing that up for me 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Still you're probably right about adding a test for a(b.c|d) as c is not a PE. We really need to come with ast -> exp before merging this and add more tests.

@vicb vicb added state: blocked and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 6, 2015
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Jun 6, 2015

Blocked on #2395

Once we have the Unparser we can refactor the test suite and add more test (ParsePipe should also probably be moved from primary to CallChain).

@vicb vicb force-pushed the 0604-pipe branch 7 times, most recently from 5cfb481 to 955536d Compare June 6, 2015 13:48
@vicb vicb added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: blocked labels Jun 6, 2015
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Jun 6, 2015

Only the last commit is to be reviewed, other are #2395 which this PR depends on.

@vicb vicb mentioned this pull request Jun 8, 2015
@vicb vicb added state: WIP and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 9, 2015
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Jun 9, 2015

I need to rework this PR after having discussed with @mhevery

@vicb vicb added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Jun 10, 2015
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Jun 10, 2015

@vsavkin this is now ready for review. I have implemented what we've discussed with @mhevery: The pipe operator should have the lowest priority consistently.

@vsavkin vsavkin added pr_state: LGTM action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jun 11, 2015
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Jun 11, 2015

merged via f974532

@vicb vicb closed this Jun 11, 2015
@vicb vicb deleted the 0604-pipe branch June 11, 2015 19:04
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: w/jsbin: template expressions with Pipes as function argument

4 participants

X Tutup