I have many JSP files with EL expressions of the form ${foo.bar.baz.phleem1}
, ${foo.bar.baz.phleem2}
etc. (the first two or three segments are equal). To reduce EL lookups I am in the process of refactoring these pages:
Source:
<c:out value="${foo.bar.baz.phleem1}" />
<c:out value="${foo.bar.baz.phleem2}" />
<c:out value="${foo.bar.baz.phleem3}" />
After refactoring:
<c:set var="baz" value="${foo.bar.baz}" />
<c:out value="${baz.phleem1}" />
<c:out value="${baz.phleem2}" />
<c:out value="${baz.phleem3}" />
I know I can do most of this with searching / replacing, but it feels unsafe as it ignores code structure.
Is there any support for this type of refactoring in either Eclipse or IntelliJ Idea?
Maybe you can use the nxml-mode in emacs. (i don't tested it) There are some functions like nxml-up-element. I bet you can create a powerful macro. But i think its more easy to grep the code and do it manually.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With