Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #14 from returntocorp/fix_find_source
Browse files Browse the repository at this point in the history
Support "javascript" in Find_source for sgrep.
  • Loading branch information
Yoann Padioleau authored Feb 3, 2020
2 parents 85b4824 + faf12bd commit 4d20941
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
6 changes: 5 additions & 1 deletion lang_GENERIC/parsing/find_source.ml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
(* UPDATE: this is mostly obsolete. You should use Lang.files_of_dirs_or_files
* instead.
*)

open Common

let finder lang =
Expand All @@ -14,7 +18,7 @@ let finder lang =
Lib_parsing_ml.find_source_files_of_dir_or_files
| "java" | "javafuzzy" ->
Lib_parsing_java.find_source_files_of_dir_or_files
| "js" | "jsfuzzy" | "jsgen" ->
| "js" | "javascript" | "jsfuzzy" | "jsgen" ->
Lib_parsing_js.find_source_files_of_dir_or_files ~include_scripts:false
| "py" | "python" ->
Lib_parsing_python.find_source_files_of_dir_or_files
Expand Down
3 changes: 3 additions & 0 deletions lang_GENERIC/parsing/find_source.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
(* UPDATE: this is mostly obsolete. You should use Lang.files_of_dirs_or_files
* instead.
*)

(* will manage optional skip list at root *)
val files_of_root:
Expand Down
30 changes: 10 additions & 20 deletions lang_GENERIC/parsing/lang.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,16 @@ let string_of_lang = function
| Go -> "Golang"



(* copy-paste: very similar to pfff/find_source.ml *)
let finder lang =
match lang with
| Python ->
Lib_parsing_python.find_source_files_of_dir_or_files
| Javascript ->
Lib_parsing_js.find_source_files_of_dir_or_files ~include_scripts:false
| C
| Java
| ML
| Go
-> raise Todo


let find_source lang xs =
Common.files_of_dir_or_files_no_vcs_nofilter xs
|> List.filter (fun filename ->
lang_of_filename_opt filename =*= Some lang
) |> Common.sort

(* this is used by sgrep, so it is probably better to keep the logic
* simple and not perform any Skip_code filtering (bento already does that)
*)
let files_of_dirs_or_files lang xs =
let finder = finder lang in
let xs = List.map Common.fullpath xs in
finder xs
(* |> Skip_code.filter_files_if_skip_list *)


find_source lang xs

0 comments on commit 4d20941

Please sign in to comment.