facebookarchive / pfff

Tools for code analysis, visualizations, or style-preserving source transformation.
http://github.com/facebook/pfff/wiki/Main
Other
2.44k stars 204 forks source link

Can't use spatch to wrap a function call #83

Open jthemphill opened 10 years ago

jthemphill commented 10 years ago

example.php:

<?hh
f(1, 2, 3);

example.spatch:

+ prep(
  f(1, 2, 3)
+ )

The output I want:

@@ -1,3 +1,3 @@
 <?hh
-f(1, 2, 3);
+prep(f(1, 2, 3));

The output I get:

@@ -1,3 +1,3 @@
 <?hh
-f(1, 2, 3);
+f(1, 2, 3));
billf commented 10 years ago

$ cat example.php

<?hh
f(1, 2, 3);

$ cat /tmp/example.spatch

- f(
+ prep(f(
...)
+ )

$ spatch_php -f /tmp/example.spatch example.php

--- /data/users/bill/dwww/example.php   2014-05-16 12:08:14.202900928 -0700
+++ /workspace/tmp/trans-7372-30cdc9.spatch 2014-05-16 12:08:55.524864212 -0700
@@ -1,2 +1,2 @@
 <?hh
-f(1, 2, 3);
+prep(f(1, 2, 3));
jthemphill commented 10 years ago

Thanks!

aryx commented 10 years ago

wow, this is still bad. The first one should work.

billf commented 10 years ago

it would be nice if it did, because right now

- X
+ Y(X(
...)
+)

will also destroy style if X is complex (e.g. foo()->bar()->baz(....))

ghost commented 9 years ago

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.