Esempio n. 1
0
 /**
  * even more optimized version:
  *      getIncrementalReport($from, $to, $list_of_files) = getReport($to) - getReport($from),
  * but only the modified files ($list_of_files) will be analyzed/parsed/processed
  *
  * @param XRef_IFileProvider $from
  * @param XRef_IFileProvider $to
  * @param array $list_of_modified_files -  list of files,
  *          that are different between $from and $to
  * @return array - map (file name => XRef_CodeDefect[])
  */
 public function getIncrementalReport(XRef_IFileProvider $from, XRef_IFileProvider $to, $list_of_modified_files)
 {
     $this->loadFilesMap($from);
     $has_files_map = (bool) $this->filesMap;
     $files = $this->xref->filterFiles($list_of_modified_files);
     foreach ($files as $filename) {
         $this->report[$filename] = $this->getFileReportCached($from, $filename);
     }
     $old_report = $this->collectReport();
     $this->report = array();
     foreach ($files as $filename) {
         // remove info about this file from filesMap
         // getFileReportCached() will update the filesMap
         unset($this->filesMap[$filename]);
         $this->report[$filename] = $this->getFileReportCached($to, $filename);
     }
     $new_report = $this->collectReport();
     // save the updated filesMap:
     // filesMap($to) == filesMap($from) + update for modified files
     if ($has_files_map) {
         $this->saveFilesMap($to);
     }
     $this->releaseParsedFile();
     return self::getNewProjectErrors($old_report, $new_report);
 }
Esempio n. 2
0
if (XRef::needHelp() || count($arguments)) {
    XRef::showHelpScreen("xref-doc - tool to create cross-reference source code reports");
    exit(1);
}
$xref = new XRef();
$xref->setOutputDir(XRef::getConfigValue("doc.output-dir"));
$xref->loadPluginGroup("doc");
$plugins = $xref->getPlugins("XRef_IDocumentationPlugin");
$path = XRef::getConfigValue("project.source-code-dir");
$file_provider = new XRef_FileProvider_FileSystem($path);
$exclude_paths = XRef::getConfigValue("project.exclude-path", array());
$file_provider->excludePaths($exclude_paths);
$numberOfFiles = 0;
$numberOfCodeLines = 0;
// 1. Call each plugin once for each input file
$files = $xref->filterFiles($file_provider->getFiles());
foreach ($files as $filename) {
    try {
        $file_content = $file_provider->getFileContent($filename);
        $pf = $xref->getParsedFile($filename, $file_content);
        foreach ($plugins as $pluginId => $plugin) {
            $plugin->generateFileReport($pf);
        }
        $numberOfFiles++;
        $numberOfCodeLines += $pf->getNumberOfLines();
        $pf->release();
        // help PHP garbage collector to free memory
    } catch (Exception $e) {
        error_log("Can't process file '{$filename}': " . $e->getMessage() . "\n");
    }
}