Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file loc.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134[@@@ocaml.ppx.context{tool_name="ppx_driver";include_dirs=[];load_path=[];open_modules=[];for_package=None;debug=false;use_threads=false;use_vmthreads=false;recursive_types=false;principal=false;transparent_modules=false;unboxed_types=false;unsafe_string=false;cookies=[("library-name","flow_parser");("sedlex.regexps",([%regexps]))]}]typeposition={line:int;column:int}[@@deriving(eq,show)]letrecequal_position:position->position->bool=((funlhs->funrhs->((fun(a:int)->funb->a=b)lhs.linerhs.line)&&((fun(a:int)->funb->a=b)lhs.columnrhs.column))[@ocaml.warning"-A"])[@@ocaml.warning"-39"]typet={source:File_key.toption;start:position;_end:position}[@@derivingshow]letnone={source=None;start={line=0;column=0};_end={line=0;column=0}}letis_none(x:t)=(x==none)||(matchxwith|{source=None;start={line=0;column=0};_end={line=0;column=0}}->true|_->false)letis_none_ignore_source(x:t)=(x==none)||(matchxwith|{source=_;start={line=0;column=0};_end={line=0;column=0}}->true|_->false)letbtwnloc1loc2={source=(loc1.source);start=(loc1.start);_end=(loc2._end)}letchar_beforeloc=letstart=let{line;column}=loc.startinletcolumn=ifcolumn>0thencolumn-1elsecolumnin{line;column}inlet_end=loc.startin{locwithstart;_end}letfirst_charloc=letstart=loc.startinlet_end={startwithcolumn=(start.column+1)}in{locwith_end}letpos_cmpab=letk=a.line-b.lineinifk=0thena.column-b.columnelsekletspan_compareab=letk=File_key.compare_opta.sourceb.sourceinifk=0thenletk=pos_cmpa.startb.startin(ifk<=0thenletk=pos_cmpa._endb._endin(ifk>=0then0else(-1))else1)elsek[@@ocaml.doc"\n * If `a` spans (completely contains) `b`, then returns 0.\n * If `b` starts before `a` (even if it ends inside), returns < 0.\n * If `b` ends after `a` (even if it starts inside), returns > 0.\n "]letcontainsloc1loc2=(span_compareloc1loc2)=0[@@ocaml.doc" [contains loc1 loc2] returns true if [loc1] entirely overlaps [loc2] "]letintersectsloc1loc2=((File_key.compare_optloc1.sourceloc2.source)=0)&&(not(((pos_cmploc1._endloc2.start)<0)||((pos_cmploc1.startloc2._end)>0)))[@@ocaml.doc" [intersects loc1 loc2] returns true if [loc1] intersects [loc2] at all "]letlines_intersectloc1loc2=((File_key.compare_optloc1.sourceloc2.source)=0)&&(not(((loc1._end).line<(loc2.start).line)||((loc1.start).line>(loc2._end).line)))[@@ocaml.doc" [lines_intersect loc1 loc2] returns true if [loc1] and [loc2] cover any part of\n the same line, even if they don't actually intersect.\n\n For example, if [loc1] ends and then [loc2] begins later on the same line,\n [intersects loc1 loc2] is false, but [lines_intersect loc1 loc2] is true. "]letcompare_ignore_sourceloc1loc2=matchpos_cmploc1.startloc2.startwith|0->pos_cmploc1._endloc2._end|k->kletcompareloc1loc2=letk=File_key.compare_optloc1.sourceloc2.sourceinifk=0thencompare_ignore_sourceloc1loc2elsekletequalloc1loc2=(compareloc1loc2)=0letdebug_to_string?(include_source=false)loc=letsource=ifinclude_sourcethenPrintf.sprintf"%S: "(matchloc.sourcewith|Somesrc->File_key.to_stringsrc|None->"<NONE>")else""inletpos=Printf.sprintf"(%d, %d) to (%d, %d)"(loc.start).line(loc.start).column(loc._end).line(loc._end).columninsource^pos[@@ocaml.doc"\n * This is mostly useful for debugging purposes.\n * Please don't dead-code delete this!\n "]letto_string_no_sourceloc=letline=(loc.start).lineinletstart=(loc.start).column+1inletend_=(loc._end).columninifline<=0then"0:0"elseif(line=(loc._end).line)&&(start=end_)thenPrintf.sprintf"%d:%d"linestartelseifline!=(loc._end).linethenPrintf.sprintf"%d:%d,%d:%d"linestart(loc._end).lineend_elsePrintf.sprintf"%d:%d-%d"linestartend_letmk_loc?source(start_line,start_column)(end_line,end_column)={source;start={line=start_line;column=start_column};_end={line=end_line;column=end_column}}letsourceloc=loc.sourceletcursorsourcelinecolumn={source;start={line;column};_end={line;column}}[@@ocaml.doc" Produces a zero-width Loc.t, where start = end "]letstart_locloc={locwith_end=(loc.start)}letend_locloc={locwithstart=(loc._end)}