Commit c323851
support for typedefs and typeconsts
Summary:
This diff adds support for typedefs and typeconsts to `hh --find-my-tests`.
For a typedef, `type Foo = ...`:
- If `Foo` is directly mentioned in a test in any way, we select that test.
- If `Foo` appears in the definition of another typedef `Bar` or typeconst `Bar::TBar`, we add `Bar`/`Bar::TBar` to our search.
- If `Foo::class` or `nameof Foo` appears in the body of some method `m`, we add `m` to our search.
For a tyepconst, `Foo::TFoo:
- If `Foo::TFoo` is directly mentioned in a test in any way, we select that test.
- If `Foo::TFoo` appears in the definition of another typedef `Bar` or typeconst `Bar::TBar`, we add `Bar`/`Bar::TBar` to our search.
- If `type_structure(Foo::class, 'TFoo')` appears in some method `m`, we add `m` to our search.
Implementation notes:
- I've factored out some code shared by `get_method_references` and `get_class_references` into `get_references_standard`, which causes some noise in this diff.
- The code for getting all references to a type constant `Foo::TFoo` (`get_typeconst_references`) is more complicated that code for other constructs:
+ For most heuristics, we need to find all references to `Foo::TFoo` directly.
+ For handling `type_structure(Foo::class, 'TFoo')`, we need to find all references to class `Foo`, and then inspect its use sites to look if it's one of the `type_structure` calls we are interested in.
Reviewed By: madgen
Differential Revision: D88656532
fbshipit-source-id: 6ce3bfebbe26f3adfc787e0cc26d78f27e1336991 parent 5b0e305 commit c323851
19 files changed
Lines changed: 620 additions & 108 deletions
File tree
- hphp/hack
- src
- client_and_server
- client
- server
- test/integration
- data/find_my_tests_repo/f
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1043 | 1043 | | |
1044 | 1044 | | |
1045 | 1045 | | |
| 1046 | + | |
1046 | 1047 | | |
1047 | 1048 | | |
1048 | 1049 | | |
1049 | 1050 | | |
| 1051 | + | |
1050 | 1052 | | |
1051 | 1053 | | |
1052 | 1054 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
162 | 163 | | |
| 164 | + | |
163 | 165 | | |
164 | 166 | | |
165 | 167 | | |
| |||
0 commit comments