]> khamidou — GitHub mirrors - arcanist.git/commit
Munge XHP class names when generating phutil dependency maps
authorJames Ide <ide+github@jameside.com>
Sat, 23 Jul 2011 23:48:21 +0000 (16:48 -0700)
committerJames Ide <ide+github@jameside.com>
Sun, 24 Jul 2011 00:38:26 +0000 (17:38 -0700)
commiteb98ab553e86854bb892465d826516a5246b6ba4
tree29326e3e59ec17acadc72d058be1671fb2c239a7
parentb3a9ee3d846640f4cc447ca97bc305daea7464b2
Munge XHP class names when generating phutil dependency maps

Summary:
When phutil_analyzer builds the dependency graph I convert all class names w.r.t
XHP's internal naming scheme. It actually wouldn't be a terrible idea to do this
munging when phutil loads the symbols. I guess it doesn't really matter at the
moment since only Arcanist generates phutil maps and only libphutil reads them,
but it'd be nice to do this munging in as few places as possible in the future.

The XHP grammar does not allow elements to be interfaces
(https://github.com/facebook/xhp/blob/dafff2cc1844d1138c3388509c9560b87167a3bb/xhp/parser.y#L1688)
so I've only applied this to classes.

Test Plan:
Created a sample project:

  ./__phutil_library_init__.php
    hopping/__init__.php
           /hophophop.php

where that last file contains

  <?php
  class :bunny:hop-hop-hop extends :x:element {
    protected function render() {
      return <p>bunny goes hop hop hop</p>;
    }
  }

Ran phutil_mapper.php and generated __phutil_library_map__.php:

  <?php

  /**
   * This file is automatically generated. Use 'phutil_mapper.php' to rebuild i\
t.
   * @generated
   */

  phutil_register_library_map(array(
    'class' =>
    array(
      'xhp_bunny__hop_hop_hop' => 'hopping',
    ),
    'function' =>
    array(
    ),
    'requires_class' =>
    array(
      'xhp_bunny__hop_hop_hop' => 'xhp_x__element',
    ),
    'requires_interface' =>
    array(
    ),
  ));

Reviewed By: epriestley
Reviewers: epriestley
Commenters: aran
CC: aran, ide, epriestley
Differential Revision: 715
src/parser/phutilmodule/PhutilModuleRequirements.php