123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165(* Yoann Padioleau
*
* Copyright (C) 2009, 2010 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 *)(*****************************************************************************)(*
* The code in this module used to be in database_code.ml but many stuff
* now have their own view on how to represent a code database
* (database_code.ml but also graph_code.ml, prolog_code.ml, etc)
*)(*****************************************************************************)(* Type *)(*****************************************************************************)(*
* Code entities.
*
* See also http://ctags.sourceforge.net/FORMAT and the doc on 'kind'
* note: if you change this, you may want to bump graph_code.version.
*
* coupling: If you add a constructor modify also entity_kind_of_string()!
* coupling: if you add a new kind of entity, then don't forget to modify
* also size_font_multiplier_of_categ in code_map/.
*
* less: could perhaps factorize code with highlight_code.ml? see
* entity_kind_of_highlight_category_def|use
*)typeentity_kind=|Package(* when we use the database for completion purpose, then files/dirs
* are also useful "entities" to get completion for.
*)|Dir|Module|File|Function|Class(* Less: Obj, because in JS it differs from Class *)|Type|Constant|Global|Macro|Exception|TopStmts(* nested entities *)|Field|Method|ClassConstant|Constructor(* for ml *)(* forward decl *)|Prototype|GlobalExtern(* people often spread the same component in multiple dirs with the same
* name (hmm could be merged now with Package)
*)|MultiDirs|Otherofstring(* todo: IsInlinedMethod, ...
* todo: IsOverriding, IsOverriden
*)typeproperty=(* mostly function properties *)(* todo: could also say which argument is dataflow involved in the
* dynamic call if any
*)|ContainDynamicCall|ContainReflectionCall(* the argument position taken by ref; 0-index based *)|TakeArgNByRefofint|UseGlobalofstring|ContainDeadStatements|DeadCode(* the function itself is dead, e.g. never called *)|CodeCoverageofintlist(* e.g. covered lines by unit tests *)(* for class *)|ClassKindofclass_kind|Privacyofprivacy|Abstract|Final|Static(* used for the xhp @required fields for now *)|Required|Async(* todo: git info, e.g. Age, Authors, Age_profile (range) *)andprivacy=Public|Protected|Privateandclass_kind=Struct|Class_|Interface|Trait|Enum(*****************************************************************************)(* String of *)(*****************************************************************************)(* todo: should be autogenerated !! *)letstring_of_entity_kinde=matchewith|Function->"Function"|Prototype->"Prototype"|GlobalExtern->"GlobalExtern"|Class->"Class"|Module->"Module"|Package->"Package"|Type->"Type"|Constant->"Constant"|Global->"Global"|Macro->"Macro"|TopStmts->"TopStmts"|Method->"Method"|Field->"Field"|ClassConstant->"ClassConstant"|Others->"Other:"^s|File->"File"|Dir->"Dir"|MultiDirs->"MultiDirs"|Exception->"Exception"|Constructor->"Constructor"letentity_kind_of_strings=matchswith|"Function"->Function|"Class"->Class|"Module"->Module|"Type"->Type|"Constant"->Constant|"Global"->Global|"Macro"->Macro|"TopStmts"->TopStmts|"Method"->Method|"Field"->Field|"ClassConstant"->ClassConstant|"File"->File|"Dir"->Dir|"MultiDirs"->MultiDirs|"Exception"->Exception|"Constructor"->Constructor|_whens=~"Other:\\(.*\\)"->Other(Common.matched1s)|_->failwith("entity_of_string: bad string = "^s)