1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677(* Yoann Padioleau
*
* Copyright (C) 2012 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.
*)openCommonmoduleG=Graph_codemoduleE=Entity_code(*****************************************************************************)(* Prelude *)(*****************************************************************************)let(lookup_fully_qualified2:Graph_code.graph->stringlist->Graph_code.nodeoption)=fungxs->letrecauxcurrentxs=matchxswith|[]->Somecurrent|x::xs->letchildren=G.childrencurrentgin(* because have File intermediate (noisy) nodes *)letchildren=children|>List.map(funchild->matchchildwith|(_,E.File)->G.childrenchildg(* we prefer Package to Dir when we lookup, we don't want
* The "multiple entities" warning when have both
* a "net" package and "net" directory.
*)|(_,E.Dir)->[]|_->[child])|>List.flattenin(* sanity check, quite expansive according to -profile *)Common.group_assoc_bykey_effchildren|>List.iter(fun(k,xs)->ifList.lengthxs>1(* issue warnings lazily, only when the ambiguity concerns
* something we are actually looking for
*)&&k=$=xthenbegin(* todo: this will be a problem when go from class-level
* to method/field level dependencies
*)pr2"WARNING: multiple entities with same name";pr2_gen(k,xs);end);letstr=matchcurrentwith|".",E.Dir->x|s,_->s^"."^xinletnew_current=children|>Common.find_some_opt(fun(s2,kind)->ifstr=$=s2thenSome(s2,kind)elseNone)in(matchnew_currentwith(* less: could return at least what we were able to resolve *)|None->None|Somecurrent->auxcurrentxs)inauxG.rootxs