Add support for XHP namespaces (#8645)
Summary:
This contains the second half of the split https://github.com/facebook/hhvm/issues/8595 PR. It adds namespace support for XHP. Note that this is only supported if the xhp class has been defined using the xhp modifier style. For example `xhp class name {}`.
Examples of supported syntax:
<:foo:bar> finds the xhp class \foo\bar
Use namespace
Use namespace as
Use type
Use type group
Currently not supported in this PR:
Declaring a class inside of a namespace using the xhp syntax. For example: `xhp class foo:bar {}`
I've struggled to get this to work. Will try again in a follow up PR when there are fewer moving parts to take care of. I think that's free standing enough that it's not a requirement to for this PR (that is already getting quite big).
See a more detailed list of syntax here: https://gist.github.com/fredemmott/
de7eeb91765b0c98fafac9c591263aca
The meat of this PR is in `namespaces.ml` where we change an incoming :foo:bar into \foo\bar to match regular namespaces. `parser_trait.rs` contains the other big chunk where we change xhp elements to allow a colon prefix. This is to allow `<:foo:bar>` to be looked up as `\foo\bar` (as opposed to `<foo:bar>` that will look in `currentnamespace\foo\bar`.
Most of this functionality is hidden behind the flag `disable_xhp_element_mangling`. Perhaps that should be called enable_xhp_namespaces instead since it's not truly just about mangling anymore.
This also contains the following bug fix PR but that one should probably go in sooner rather than later:
https://github.com/facebook/hhvm/issues/8644
Pull Request resolved: https://github.com/facebook/hhvm/pull/8645
Reviewed By: Wilfred
Differential Revision:
D19501207
fbshipit-source-id:
35e1112233fc29f07903260b5a6ea2c5b9761b42