1234567891011121314151617181920212223242526272829303132333435363738394041(* This Source Code Form is subject to the terms of the Mozilla Public License,
v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at http://mozilla.org/MPL/2.0/. *)typet={mutableignored_intervals:(int*int)list;mutablemarked_lines:intlist;}letcomments_cache:(string,t)Hashtbl.t=Hashtbl.create17letgetfilename=tryHashtbl.findcomments_cachefilenamewithNot_found->(* We many have multiple 'filenames' inside of a file
because of the line directive. *)letchan=open_infilenameintryletlexbuf=Lexing.from_channelchaninletstack=Stack.create()inletlst=Comments_lexer.normal[][]stack(filename,[])lexbufinletas_comments=List.map(fun(filename,(ignored_intervals,marked_lines))->letcomments={ignored_intervals;marked_lines}inHashtbl.addcomments_cachefilenamecomments;(filename,comments))lstinclose_in_noerrchan;List.assocfilenameas_commentswithe->close_in_noerrchan;raiseeletline_is_ignoredline_numbercomments_info=List.exists(fun(low,high)->line_number>=low&&line_number<=high)comments_info.ignored_intervals||List.memline_numbercomments_info.marked_lines