This repository has been archived by the owner on Jun 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 205
/
find_source.ml
156 lines (126 loc) · 4.52 KB
/
find_source.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
open Common
let finder lang =
match lang with
| "php" | "phpfuzzy" | "php2" ->
Lib_parsing_php.find_source_files_of_dir_or_files ~verbose:false ~include_hack:false
| "hack" ->
Lib_parsing_php.find_source_files_of_dir_or_files ~verbose:false ~include_hack:true
| "c++" ->
Lib_parsing_cpp.find_source_files_of_dir_or_files
| "c" ->
Lib_parsing_c.find_source_files_of_dir_or_files
| "ml" ->
Lib_parsing_ml.find_source_files_of_dir_or_files
| "cmt" ->
Lib_parsing_ml.find_cmt_files_of_dir_or_files
| "java" ->
Lib_parsing_java.find_source_files_of_dir_or_files
| "js" ->
Lib_parsing_js.find_source_files_of_dir_or_files ~include_scripts:false
| "clang2" ->
Lib_parsing_clang.find_source2_files_of_dir_or_files
| "lisp" ->
Lib_parsing_lisp.find_source_files_of_dir_or_files
| "dot" -> (fun _ -> [])
| _ -> failwith ("Find_source: unsupported language: " ^ lang)
let skip_file dir =
Filename.concat dir "skip_list.txt"
let files_of_dir_or_files ~lang ~verbose xs =
let finder = finder lang in
let xs = List.map Common.realpath xs in
finder xs +> Skip_code.filter_files_if_skip_list ~verbose
(* todo: factorize with filter_files_if_skip_list? *)
let files_of_root ~lang root =
let finder = finder lang in
let files = finder [root] in
let skip_list =
if Sys.file_exists (skip_file root)
then begin
pr2 (spf "Using skip file: %s" (skip_file root));
Skip_code.load (skip_file root);
end
else []
in
let files = Skip_code.filter_files skip_list root files in
files
(*
let root = Common.realpath dir in
let all_files = Lib_parsing_clang.find_source2_files_of_dir_or_files [root] in
(* step0: filter noisy modules/files *)
let files = Skip_code.filter_files skip_list root all_files in
(* step0: reorder files *)
let files = Skip_code.reorder_files_skip_errors_last skip_list root files in
let root = Common.realpath dir_or_file in
let all_files =
Lib_parsing_bytecode.find_source_files_of_dir_or_files [root] in
(* step0: filter noisy modules/files *)
let files =
Skip_code.filter_files skip_list root all_files in
let root = Common.realpath dir in
let all_files = Lib_parsing_c.find_source_files_of_dir_or_files [root] in
(* step0: filter noisy modules/files *)
let files = Skip_code.filter_files skip_list root all_files in
let root = Common.realpath dir_or_file in
let all_files = Lib_parsing_java.find_source_files_of_dir_or_files [root] in
(* step0: filter noisy modules/files *)
let files = Skip_code.filter_files skip_list root all_files in
let root = Common.realpath dir in
let all_files = Lib_parsing_ml.find_source_files_of_dir_or_files [root] in
(* step0: filter noisy modules/files *)
let files = Skip_code.filter_files skip_list root all_files in
let root = Common.realpath dir in
let all_files = Lib_parsing_cpp.find_source_files_of_dir_or_files [root] in
(* step0: filter noisy modules/files *)
let files = Skip_code.filter_files skip_list root all_files in
let root, files =
Common.profile_code "Graph_php.step0" (fun () ->
match dir_or_files with
| Left dir ->
let root = Common.realpath dir in
let files =
Lib_parsing_php.find_php_files_of_dir_or_files [root]
+> Skip_code.filter_files skip_list root
+> Skip_code.reorder_files_skip_errors_last skip_list root
in
root, files
(* useful when build codegraph from test code *)
| Right files ->
"/", files
)
in
let root, files =
match dir_or_files with
| Left dir ->
let root = Common.realpath dir in
let all_files = Lib_parsing_php.find_php_files_of_dir_or_files [root] in
(* step0: filter noisy modules/files *)
let files =
Skip_code.filter_files skip_list root all_files in
(* step0: reorder files *)
let files =
Skip_code.reorder_files_skip_errors_last skip_list root files in
root, files
(* useful when build from test code *)
| Right files ->
"/", files
in
let skip_file = !skip_list ||| skip_file_of_dir root in
let skip_list =
if Sys.file_exists skip_file
then begin
pr2 (spf "Using skip file: %s" skip_file);
Skip_code.load skip_file
end
else []
in
let finder = Find_source.finder lang in
let skip_file = "skip_list.txt" in
let skip_list =
if Sys.file_exists skip_file
then begin
pr2 (spf "Using skip file: %s" skip_file);
Skip_code.load skip_file
end
else []
in
*)