codemod 2010-2016 to 2010-present
[hiphop-php.git] / hphp / compiler / package.h
blobf1940add76e51fded98e3c53b0a28de701b78a05
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_PACKAGE_H_
18 #define incl_HPHP_PACKAGE_H_
20 #include "hphp/compiler/hphp.h"
21 #include <map>
22 #include <memory>
23 #include <set>
24 #include <vector>
25 #include "hphp/util/string-bag.h"
26 #include "hphp/util/file-cache.h"
27 #include "hphp/util/mutex.h"
29 namespace HPHP {
30 ///////////////////////////////////////////////////////////////////////////////
32 DECLARE_BOOST_TYPES(ServerData);
33 DECLARE_BOOST_TYPES(AnalysisResult);
35 /**
36 * A package contains a list of directories and files that will be parsed
37 * and analyzed together. No files outside of a package will be considered
38 * in type inferences. One single AnalysisResult will be generated and it
39 * contains all classes, functions, variables, constants and their types.
40 * Therefore, a package is really toppest entry point for parsing.
42 struct Package {
43 explicit Package(const char *root,
44 bool bShortTags = true,
45 bool bAspTags = false);
47 void addAllFiles(bool force); // add from Option::PackageDirectories/Files
49 void addSourceFile(const char *fileName, bool check = false);
50 void addInputList(const char *listFileName);
51 void addStaticFile(const char *fileName);
52 void addDirectory(const std::string &path, bool force);
53 void addDirectory(const char *path, bool force);
54 void addStaticDirectory(const std::string path);
55 void addPHPDirectory(const char *path, bool force);
57 bool parse(bool check);
58 bool parse(const char *fileName);
59 bool parseImpl(const char *fileName);
61 AnalysisResultPtr getAnalysisResult() { return m_ar;}
62 void resetAr() { m_ar.reset(); }
63 int getFileCount() const { return m_files.size();}
64 int getLineCount() const { return m_lineCount;}
65 int getCharCount() const { return m_charCount;}
67 void saveStatsToFile(const char *filename, int totalSeconds) const;
69 const std::string& getRoot() const { return m_root;}
70 std::shared_ptr<FileCache> getFileCache();
72 private:
73 std::string m_root;
74 std::set<std::string> m_filesToParse;
75 StringBag m_files;
76 void *m_dispatcher;
78 Mutex m_mutex;
79 AnalysisResultPtr m_ar;
80 int m_lineCount;
81 int m_charCount;
83 std::shared_ptr<FileCache> m_fileCache;
84 std::set<std::string> m_directories;
85 std::set<std::string> m_staticDirectories;
86 std::set<std::string> m_extraStaticFiles;
87 std::map<std::string,std::string> m_discoveredStaticFiles;
90 ///////////////////////////////////////////////////////////////////////////////
92 #endif // incl_HPHP_PACKAGE_H_