1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677(* Yoann Padioleau
*
* Copyright (C) 2012, 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.
*)openCommon(*****************************************************************************)(* Prelude *)(*****************************************************************************)(*****************************************************************************)(* Types *)(*****************************************************************************)typerefactoring_kind=|AddInterfaceofstringoption(* specific class *)*string(* the interface to add *)|RemoveInterfaceofstringoption*string|SplitMembers(* todo: Rename of entity * entity *)(* type related *)|AddReturnTypeofstring|AddTypeHintParameterofstring|OptionizeTypeParameter|AddTypeMemberofstringtypeposition={file:Common.filename;line:int;col:int;}typerefactoring=refactoring_kind*positionoption(*****************************************************************************)(* IO *)(*****************************************************************************)(* format: file;RETURN;line;col;value *)letloadfile=Common.catfile|>List.map(funs->letxs=Common.split";"sinmatchxswith|[file;action;line;col;value]whenline=~"[0-9]+"&&col=~"[0-9]+"&&(List.memaction["RETURN";"PARAM";"MEMBER";"MAKE_OPTION_TYPE";"SPLIT_MEMBERS";])->(matchactionwith|"RETURN"->AddReturnTypevalue|"PARAM"->AddTypeHintParametervalue|"MEMBER"->AddTypeMembervalue|"MAKE_OPTION_TYPE"->OptionizeTypeParameter|"SPLIT_MEMBERS"->SplitMembers|_->raiseImpossible),Some{file;line=int_of_stringline;col=int_of_stringcol;}|_->failwith("wrong format for refactoring action: "^s))