diff --git a/hphp/hack/test/ide_code_actions/extract_method/HH_FLAGS b/hphp/hack/test/ide_code_actions/extract_method/HH_FLAGS index 71a28b758d822..465f70d6da1db 100644 --- a/hphp/hack/test/ide_code_actions/extract_method/HH_FLAGS +++ b/hphp/hack/test/ide_code_actions/extract_method/HH_FLAGS @@ -1 +1,2 @@ --config everything_sdt=false +--extra-builtin ../hhi/extraBuiltins.hhi diff --git a/hphp/hack/test/ide_code_actions/extract_method/dune b/hphp/hack/test/ide_code_actions/extract_method/dune index 58a64e715cb94..20caefe4691e5 100644 --- a/hphp/hack/test/ide_code_actions/extract_method/dune +++ b/hphp/hack/test/ide_code_actions/extract_method/dune @@ -5,6 +5,7 @@ %{project_root}/hack/test/verify.py %{project_root}/hack/test/review.sh (glob_files %{project_root}/hack/test/ide_code_actions/extract_method/HH_FLAGS) + (glob_files %{project_root}/hack/test/ide_code_actions/hhi/*.hhi) (glob_files %{project_root}/hack/test/ide_code_actions/extract_method/*.php) (glob_files %{project_root}/hack/test/ide_code_actions/extract_method/*.exp)) (action diff --git a/hphp/hack/test/ide_code_actions/extract_method/extract_method_like_types_1.php b/hphp/hack/test/ide_code_actions/extract_method/extract_method_like_types_1.php new file mode 100644 index 0000000000000..f953d4d5cc03e --- /dev/null +++ b/hphp/hack/test/ide_code_actions/extract_method/extract_method_like_types_1.php @@ -0,0 +1,13 @@ + $vec): Awaitable { + $y = ExtraBuiltins\genInt(); + /*range-start*/ + $x1 = $y; + $x2 = ExtraBuiltins\genInt() + /*range-end*/ + echo $x1; + echo await $x2; + } +} diff --git a/hphp/hack/test/ide_code_actions/extract_method/extract_method_like_types_1.php.exp b/hphp/hack/test/ide_code_actions/extract_method/extract_method_like_types_1.php.exp new file mode 100644 index 0000000000000..aad91191a84fa --- /dev/null +++ b/hphp/hack/test/ide_code_actions/extract_method/extract_method_like_types_1.php.exp @@ -0,0 +1,48 @@ +Code actions available: +------------------------------------------ +slog variable (CodeActionKind: refactor) +Extract into method (CodeActionKind: refactor) SELECTED + +JSON for selected code action: +------------------------------------------ +{ + "diagnostics":[], + "edit":{ + "changes":{ + "FILE.php":[ + { + "newText":" private function ${0:method0}(~Awaitable $y): (~Awaitable, ~Awaitable) {\n $x1 = $y;\n $x2 = ExtraBuiltins\\genInt()\n return tuple($x1, $x2);\n }\n\n", + "range":{"end":{"character":0,"line":3},"start":{"character":0,"line":3}} + }, + { + "newText":"list($x1, $x2) = $this->${0:method0}($y);", + "range":{"end":{"character":32,"line":7},"start":{"character":4,"line":6}} + } + ] + } + }, + "kind":"refactor", + "title":"Extract into method" +} + +Applied edit for code action: +------------------------------------------ + $y): (~Awaitable, ~Awaitable) { + $x1 = $y; + $x2 = ExtraBuiltins\genInt() + return tuple($x1, $x2); + } + + public async function foo(vec $vec): Awaitable { + $y = ExtraBuiltins\genInt(); + /*range-start*/ + list($x1, $x2) = $this->${0:method0}($y); + /*range-end*/ + echo $x1; + echo await $x2; + } +} + diff --git a/hphp/hack/test/ide_code_actions/hhi/extraBuiltins.hhi b/hphp/hack/test/ide_code_actions/hhi/extraBuiltins.hhi new file mode 100644 index 0000000000000..ace1cbf61ac8c --- /dev/null +++ b/hphp/hack/test/ide_code_actions/hhi/extraBuiltins.hhi @@ -0,0 +1,3 @@ +namespace ExtraBuiltins; + +async function genInt(): ~Awaitable;