Index: includes/registry.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/registry.inc,v
retrieving revision 1.13
diff -u -r1.13 registry.inc
--- includes/registry.inc	3 Apr 2009 17:41:32 -0000	1.13
+++ includes/registry.inc	4 May 2009 18:34:31 -0000
@@ -41,7 +41,8 @@
   _registry_get_resource_name();
   // Get the list of files we are going to parse.
   $files = array();
-  foreach (module_rebuild_cache() as $module) {
+  $module_cache = module_rebuild_cache();
+  foreach ($module_cache as $module) {
     if ($module->status) {
       $dir = dirname($module->filepath);
       foreach ($module->info['files'] as $file) {
@@ -53,6 +54,12 @@
     $files["$filename"] = array('module' => '', 'weight' => 0);
   }
 
+  // Allow modules to manually modify the list of files before the registry
+  // parses them. The $module_cache provides the info file information that
+  // contains the list of files that can be used to add files provided
+  // by disabled modules.
+  drupal_alter('registry_files', $files, $module_cache);
+
   foreach (registry_get_parsed_files() as $filename => $file) {
     // Add the md5 to those files we've already parsed.
     if (isset($files[$filename])) {
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.31
diff -u -r1.31 system.api.php
--- modules/system/system.api.php	28 Apr 2009 00:27:06 -0000	1.31
+++ modules/system/system.api.php	4 May 2009 18:34:32 -0000
@@ -1693,5 +1693,43 @@
 }
 
 /**
+ * Perform necessary alterations to the list of files parsed by the registry.
+ *
+ * Modules can manually modify the list of files before the registry parses
+ * them. The $module_cache provides the info file information that contains the
+ * list of files that can be used to add files provided by disabled modules.
+ *
+ * Implementing hooks on behalf of another module can be done by implementing
+ * the hook in a file and changing the module related to the file before the
+ * registry parses the file. In the example bellow, hook_token() is implemented
+ * by the token module on behalf of the node module. The associated module for
+ * the file containing node_token() is changed to the node module.
+ *
+ * @param $files
+ *   List of files to be parsed by the registry. The list will contain file
+ *   found in each enabled module's info file and the includes directory. The
+ *   array is keyed by the file path and contains an array of the related module
+ *   name and weight.
+ *
+ *   For example:
+ *   @code
+ *     $files["modules/system/system.module"] = array(
+ *       'module' => 'system',
+ *       'weight' => 0,
+ *     );
+ *   @endcode
+ * @param $module_cache
+ *   List of all the files provided by modules in the system, as returned by
+ *   module_rebuild_cache().
+ *
+ * @see _registry_rebuild()
+ * @see module_rebuild_cache().
+ * @see simpletest_registry_files_alter()
+ */
+function hook_registry_files_alter($files, $module_cache) {
+  $files[drupal_get_path('module', 'token') . '/token.node.inc']['module'] = 'node';
+}
+
+/**
  * @} End of "addtogroup hooks".
  */
