Module Merlin_specific.Browse_raw

Browse_node offers a uniform interface to traverse constructions from * TypedTree. * * Mutually recursive types from TypedTree are wrapped into different * constructors of the type node. * Then the fold function traverses one-level of sub-nodes. * * In the meantime, the most specific environment and location are threaded * (FIXME: should these two be managed separately?). * * Finally BrowseT module a node into a tree which structure mimics * the recursive structure of the TypedTree node. *

type constructor_declaration = Ocaml_typing.Typedtree.constructor_declaration
type node =
  1. | Dummy
  2. | Pattern : _ Ocaml_typing.Typedtree.general_pattern -> node
  3. | Expression of Ocaml_typing.Typedtree.expression
  4. | Case : _ Ocaml_typing.Typedtree.case -> node
  5. | Class_expr of Ocaml_typing.Typedtree.class_expr
  6. | Class_structure of Ocaml_typing.Typedtree.class_structure
  7. | Class_field of Ocaml_typing.Typedtree.class_field
  8. | Class_field_kind of Ocaml_typing.Typedtree.class_field_kind
  9. | Module_expr of Ocaml_typing.Typedtree.module_expr
  10. | Module_type_constraint of Ocaml_typing.Typedtree.module_type_constraint
  11. | Structure of Ocaml_typing.Typedtree.structure
  12. | Signature of Ocaml_typing.Typedtree.signature
  13. | Structure_item of Ocaml_typing.Typedtree.structure_item * Ocaml_typing.Env.t
  14. | Signature_item of Ocaml_typing.Typedtree.signature_item * Ocaml_typing.Env.t
  15. | Module_binding of Ocaml_typing.Typedtree.module_binding
  16. | Value_binding of Ocaml_typing.Typedtree.value_binding
  17. | Module_type of Ocaml_typing.Typedtree.module_type
  18. | Module_declaration of Ocaml_typing.Typedtree.module_declaration
  19. | Module_type_declaration of Ocaml_typing.Typedtree.module_type_declaration
  20. | With_constraint of Ocaml_typing.Typedtree.with_constraint
  21. | Core_type of Ocaml_typing.Typedtree.core_type
  22. | Package_type of Ocaml_typing.Typedtree.package_type
  23. | Row_field of Ocaml_typing.Typedtree.row_field
  24. | Value_description of Ocaml_typing.Typedtree.value_description
  25. | Type_declaration of Ocaml_typing.Typedtree.type_declaration
  26. | Type_kind of Ocaml_typing.Typedtree.type_kind
  27. | Type_extension of Ocaml_typing.Typedtree.type_extension
  28. | Extension_constructor of Ocaml_typing.Typedtree.extension_constructor
  29. | Label_declaration of Ocaml_typing.Typedtree.label_declaration
  30. | Constructor_declaration of Ocaml_typing.Typedtree.constructor_declaration
  31. | Class_type of Ocaml_typing.Typedtree.class_type
  32. | Class_signature of Ocaml_typing.Typedtree.class_signature
  33. | Class_type_field of Ocaml_typing.Typedtree.class_type_field
  34. | Class_declaration of Ocaml_typing.Typedtree.class_declaration
  35. | Class_description of Ocaml_typing.Typedtree.class_description
  36. | Class_type_declaration of Ocaml_typing.Typedtree.class_type_declaration
  37. | Binding_op of Ocaml_typing.Typedtree.binding_op
  38. | Include_description of Ocaml_typing.Typedtree.include_description
  39. | Include_declaration of Ocaml_typing.Typedtree.include_declaration
  40. | Open_description of Ocaml_typing.Typedtree.open_description
  41. | Open_declaration of Ocaml_typing.Typedtree.open_declaration
  42. | Method_call of Ocaml_typing.Typedtree.expression * Ocaml_typing.Typedtree.meth * Ocaml_parsing.Location.t
  43. | Record_field : [ `Expression of Ocaml_typing.Typedtree.expression | `Pattern of Ocaml_typing.Typedtree.pattern ] * 'rep Ocaml_typing.Types.gen_label_description * 'rep Ocaml_typing.Types.record_form * Ocaml_parsing.Longident.t Ocaml_parsing.Location.loc -> node
  44. | Module_binding_name of Ocaml_typing.Typedtree.module_binding
  45. | Module_declaration_name of Ocaml_typing.Typedtree.module_declaration
  46. | Module_type_declaration_name of Ocaml_typing.Typedtree.module_type_declaration
  47. | Mode of Ocaml_parsing.Parsetree.mode Ocaml_parsing.Location.loc
  48. | Modality of Ocaml_parsing.Parsetree.modality Ocaml_parsing.Location.loc
  49. | Jkind_annotation of Ocaml_parsing.Parsetree.jkind_annotation
  50. | Attribute of Ocaml_typing.Typedtree.attribute
    (*

    The location of an Attribute is considered to be the location of the attr_name, not the overall attribute. This is because in an Mbrowse.t, an Attribute is not the parent node of its payload. Thus, to ensure that sibling nodes do not have overlapping locations (otherwise Mtyper.node_at would break), we cannot use the location of the entire attribute.

    *)
val fold_node : (Ocaml_typing.Env.t -> node -> 'a -> 'a) -> Ocaml_typing.Env.t -> node -> 'a -> 'a

Fold over the children of a node. Note that this is not deep.

Accessors for information specific to a node

val node_update_env : Ocaml_typing.Env.t -> node -> Ocaml_typing.Env.t
val node_attributes : node -> Ocaml_typing.Typedtree.attribute list
val has_attr : name:string -> node -> bool
val string_of_node : node -> string