- This topic has 1 reply, 2 voices, and was last updated 19 years, 9 months ago by Riyad Kalla.
-
AuthorPosts
-
mikewseMember[Windows 2000, Eclipse 3.1M4, MyEclipse 3.8.4 (3.1 Beta)]
Hi guys,
I want to give you some feedback on the return of the JSP formatter. See my example below and my comments at the bottom of this post.
Best regards
MikeThis is the way my example looks before formatting (yes, where I work we quite like using dual indentation hierarchies to separate structural tags like <c:for> and <c:if> from tags and content that actually generate html, to improve readability of html):
<tr> <td> <c:if test="${xxx}"> <html:link action="/abc"> <c:out value="${xxx}"/> </html:link> </td> </c:if> <c:if test="${not xxx}"> None </td> </c:if> <td> <c:out value="${status}"/> </td> </tr>
After formatting:
<tr> <td><c:if test="${xxx}"> <html:link action="/abc"> <c:out value="${xxx}" /> </html:link></td> </c:if> <c:if test="${not xxx}"> None </td> </c:if> <td><c:out value="${status}" /></td> </tr>
Comments:
1) You seem to try to get <td> and </td> on the same line as its body, which works fine for simple (one-line) bodies. For more complex bodies it really impairs readability (see how <c:if> and </td> disappears into another line in the upper <c:if> block). It would be better with an algorithm that only joins single line bodies in this way, and also to have a user setting whether to affect line breaks at all.
2) I am surprised that the text “None” isn’t indented one step further as it seems you normally indent after <c:if>.
3) It would be nice to have support for the “dual indentation hierarchies”-style that I mentioned above. There could be a setting for what tags to regard as “structure only”, or the instantiated tag objects themselves could be inspected.
4) As you can see in my example I have put </td>:s corresponding to the same <td> in both <c:if> blocks. In this example this construct really isn’t needed but I wanted to include it for demonstration as this is something that could easily break auto indentation. Unfortunately it doesn’t show anything interesting with the formatting here as your algorithm pretty much seems to flatten everything out in the bottom half of the example. But it probably is a case you will want to think of (if you not already are :-).
One more thing: there also seems to be a keyboard shortcut Ctrl+Shift+L in MyEclipse’s JSP editor that displays a Cleanup dialog box for the JSP code. This shortcut hides the new Eclipse 3.1 feature that displays all current keyboard shortcuts (try Ctrl+Shift+L f ex in a Java editor).
Riyad KallaMemberThe indentation issue is a known problem that has been filed, sorry about that. Also I’ll file the shortcut hiding the 3.1 feature. Thx!
-
AuthorPosts