1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162(* Yoann Padioleau
*
* Copyright (C) 2010, 2013 Facebook
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation, with the
* special exception on linking described in file license.txt.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file
* license.txt for more details.
*)openCommonmoduleV=Visitor_jsmoduleFT=File_type(*****************************************************************************)(* Filemames *)(*****************************************************************************)(* copy paste of php code, not sure this is relevant for Javascript *)letis_js_scriptfile=Common.with_open_infilefile(funchan->tryletl=input_linechaninl=~"#!/usr/.*/js"||l=~"#!/bin/env js"||l=~"#!/usr/bin/env js"withEnd_of_file->false)letfind_source_files_of_dir_or_files?(include_scripts=true)xs=Common.files_of_dir_or_files_no_vcs_nofilterxs|>List.filter(funfilename->matchFT.file_type_of_filefilenamewith(* less: could also consider Typescript files *)|FT.PL(FT.WebFT.Js)->true|_->ifinclude_scriptsthenis_js_scriptfilenameelsefalse)|>Common.sort(*****************************************************************************)(* Extract infos *)(*****************************************************************************)letextract_info_visitorrecursor=letglobals=ref[]inlethooks={V.default_visitorwithV.kinfo=(fun(_k,_)i->Common.pushiglobals)}inbeginletvout=V.mk_visitorhooksinrecursorvout;List.rev!globalsendletii_of_anyany=extract_info_visitor(funvisitor->visitorany)