Skip to content

Commit 77d0d73

Browse files
mheiberfacebook-github-bot
authored andcommitted
extract shape type auto-rename
Summary: Extract shape type refactor: - select in IDE so the shape type is easy to rename - Use a `T` prefix for the shape: a use told me that shape (see facebook section for why) https://pxl.cl/2SzCZ Reviewed By: nt591 Differential Revision: D47187718 fbshipit-source-id: f06768baec8944944bf83ba3d1f7e6faf768e7bd
1 parent d19683f commit 77d0d73

10 files changed

+19
-19
lines changed

hphp/hack/src/server/server_code_actions_services/extract_shape_type.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ let edit_of_candidate ~path { shape_ty; container_pos; tast_env } :
9090
in
9191
let tenv = Tast_env.tast_env_as_typing_env tast_env in
9292
let ty_text = Typing_print.full_strip_ns tenv shape_ty in
93-
let text = Printf.sprintf "type placeholder_ = %s;\n\n" ty_text in
93+
let text = Printf.sprintf "type T${0:placeholder_} = %s;\n\n" ty_text in
9494
Lsp.TextEdit.{ range; newText = text }
9595
in
9696
let changes = SMap.singleton (Relative_path.to_absolute path) [edit] in

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_1.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ JSON for selected code action:
1111
"changes":{
1212
"FILE.php":[
1313
{
14-
"newText":"type placeholder_ = shape('a' => int, 'b' => A);\n\n",
14+
"newText":"type T${0:placeholder_} = shape('a' => int, 'b' => A);\n\n",
1515
"range":{"end":{"character":0,"line":5},"start":{"character":0,"line":5}}
1616
}
1717
]
@@ -28,7 +28,7 @@ Applied edit for code action:
2828
class Other {}
2929
class A {}
3030

31-
type placeholder_ = shape('a' => int, 'b' => A);
31+
type T${0:placeholder_} = shape('a' => int, 'b' => A);
3232

3333
function foo(): void {
3434
$a = new A();

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_2.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ JSON for selected code action:
1212
"changes":{
1313
"FILE.php":[
1414
{
15-
"newText":"type placeholder_ = shape('a' => int, 'b' => A);\n\n",
15+
"newText":"type T${0:placeholder_} = shape('a' => int, 'b' => A);\n\n",
1616
"range":{"end":{"character":0,"line":4},"start":{"character":0,"line":4}}
1717
}
1818
]
@@ -28,7 +28,7 @@ Applied edit for code action:
2828

2929
class A {}
3030

31-
type placeholder_ = shape('a' => int, 'b' => A);
31+
type T${0:placeholder_} = shape('a' => int, 'b' => A);
3232

3333
class C {
3434
public function foo(): void {

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_3.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ JSON for selected code action:
1212
"changes":{
1313
"FILE.php":[
1414
{
15-
"newText":"type placeholder_ = shape();\n\n",
15+
"newText":"type T${0:placeholder_} = shape();\n\n",
1616
"range":{"end":{"character":0,"line":2},"start":{"character":0,"line":2}}
1717
}
1818
]
@@ -26,7 +26,7 @@ Applied edit for code action:
2626
------------------------------------------
2727
<?hh
2828

29-
type placeholder_ = shape();
29+
type T${0:placeholder_} = shape();
3030

3131
class C {
3232
public function foo(): void {

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_4.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ JSON for selected code action:
1212
"changes":{
1313
"FILE.php":[
1414
{
15-
"newText":"type placeholder_ = shape('the_union' => (int | bool));\n\n",
15+
"newText":"type T${0:placeholder_} = shape('the_union' => (int | bool));\n\n",
1616
"range":{"end":{"character":0,"line":2},"start":{"character":0,"line":2}}
1717
}
1818
]
@@ -26,7 +26,7 @@ Applied edit for code action:
2626
------------------------------------------
2727
<?hh
2828

29-
type placeholder_ = shape('the_union' => (int | bool));
29+
type T${0:placeholder_} = shape('the_union' => (int | bool));
3030

3131
class C {
3232
public function foo(): void {

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_5.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ JSON for selected code action:
1212
"changes":{
1313
"FILE.php":[
1414
{
15-
"newText":"type placeholder_ = shape('a' => nothing);\n\n",
15+
"newText":"type T${0:placeholder_} = shape('a' => nothing);\n\n",
1616
"range":{"end":{"character":0,"line":2},"start":{"character":0,"line":2}}
1717
}
1818
]
@@ -26,7 +26,7 @@ Applied edit for code action:
2626
------------------------------------------
2727
<?hh
2828

29-
type placeholder_ = shape('a' => nothing);
29+
type T${0:placeholder_} = shape('a' => nothing);
3030

3131
class C {
3232
public function foo(): void {

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_6.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ JSON for selected code action:
1212
"changes":{
1313
"FILE.php":[
1414
{
15-
"newText":"type placeholder_ = shape('a' => int);\n\n",
15+
"newText":"type T${0:placeholder_} = shape('a' => int);\n\n",
1616
"range":{"end":{"character":0,"line":2},"start":{"character":0,"line":2}}
1717
}
1818
]
@@ -26,7 +26,7 @@ Applied edit for code action:
2626
------------------------------------------
2727
<?hh
2828

29-
type placeholder_ = shape('a' => int);
29+
type T${0:placeholder_} = shape('a' => int);
3030

3131
class C {
3232
public function foo(vec<int> $v): void {

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_7.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ JSON for selected code action:
1212
"changes":{
1313
"FILE.php":[
1414
{
15-
"newText":"type placeholder_ = shape('a' => shape('b' => vec<int>));\n\n",
15+
"newText":"type T${0:placeholder_} = shape('a' => shape('b' => vec<int>));\n\n",
1616
"range":{"end":{"character":0,"line":2},"start":{"character":0,"line":2}}
1717
}
1818
]
@@ -26,7 +26,7 @@ Applied edit for code action:
2626
------------------------------------------
2727
<?hh
2828

29-
type placeholder_ = shape('a' => shape('b' => vec<int>));
29+
type T${0:placeholder_} = shape('a' => shape('b' => vec<int>));
3030

3131
class C {
3232
public function foo(vec<int> $v): void {

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_like_types.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ JSON for selected code action:
1111
"changes":{
1212
"FILE.php":[
1313
{
14-
"newText":"type placeholder_ = shape('a' => int);\n\n",
14+
"newText":"type T${0:placeholder_} = shape('a' => int);\n\n",
1515
"range":{"end":{"character":0,"line":2},"start":{"character":0,"line":2}}
1616
}
1717
]
@@ -25,7 +25,7 @@ Applied edit for code action:
2525
------------------------------------------
2626
<?hh
2727

28-
type placeholder_ = shape('a' => int);
28+
type T${0:placeholder_} = shape('a' => int);
2929

3030
function foo(vec<shape('a' => int)> $v): void {
3131
$sh = $v[0];

hphp/hack/test/ide_code_actions/extract_shape_type/extract_shape_type_var_1.php.exp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ JSON for selected code action:
1212
"changes":{
1313
"FILE.php":[
1414
{
15-
"newText":"type placeholder_ = shape(?'a' => int, 'b' => int, ...);\n\n",
15+
"newText":"type T${0:placeholder_} = shape(?'a' => int, 'b' => int, ...);\n\n",
1616
"range":{"end":{"character":0,"line":2},"start":{"character":0,"line":2}}
1717
}
1818
]
@@ -26,7 +26,7 @@ Applied edit for code action:
2626
------------------------------------------
2727
<?hh
2828

29-
type placeholder_ = shape(?'a' => int, 'b' => int, ...);
29+
type T${0:placeholder_} = shape(?'a' => int, 'b' => int, ...);
3030

3131
class C {
3232
public function foo(shape(?"a" => int, ...) $sh): void {

0 commit comments

Comments
 (0)