Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[flow] abstract get_def_process_location mapper over annot position
Summary: This diff changes the signature of `get_def_process_location` mapper from a ``` [ALoc.t, ALoc.t * Type.t, ALoc.t, ALoc.t * Type.t] Flow_polymorphic_ast_mapper.mapper ``` to a ``` [ALoc.t, 'T, ALoc.t, 'T] Typed_ast_finder.enclosing_node_mapper ``` The main change is in the type of the annotation position which is now abstract. For this to work we need to change places that before inspected this position and expected to find an `ALoc.t * Type.t`, to now first call into one of the following (virtual) methods ``` method virtual loc_of_annot : 'T -> ALoc.t method virtual type_from_enclosing_node : 'T -> Type.t method virtual get_module_t : 'T -> ALoc.t Ast.StringLiteral.t -> Type.t method virtual remote_name_def_loc_of_import_named_specifier: (ALoc.t, 'T) Ast.Statement.ImportDeclaration.named_specifier -> ALoc.t option method virtual remote_default_name_def_loc_of_import_declaration: 'T -> ALoc.t * (ALoc.t, 'T) Ast.Statement.ImportDeclaration.t -> ALoc.t option method virtual component_name_of_jsx_element: 'T -> (ALoc.t, 'T) Ast.JSX.element -> ALoc.t * Type.t ``` Each class that finalizes `searcher`, will need to implement these methods. `typed_ast_searcher` which is included in this diff restores the behavior of `searcher` before this change. All these operations can be implemented by looking up relevant information in the typed AST. Follow up diffs implement a searcher that create typed AST nodes on-demand, by calling facilities introduced in the previous diff. Changelog: [internal] Reviewed By: SamChou19815 Differential Revision: D55053045 fbshipit-source-id: c52b0ea1eb90e9a4c86374970787cc7c60946ea6
- Loading branch information