History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: IDEABKL-3268
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Olesya Smirnova
Reporter: Sascha Weinreuter
Votes: 1
Watchers: 2
Available Workflow Actions

Mark as Stalled
Operations

If you were logged in you would be able to see more operations.
IDEA: Backlog

JSP-Reformat should (allow to) indent HTML according to code-blocks

Created: 06 Jul 05 14:34   Updated: 25 Jan 06 10:02
Component/s: Code Formatting and Code Style
Affects Version/s: None
Fix Version/s: None

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown

Build: 3,394
Severity: High


 Description  « Hide
A JSP file with the following content is currently completely screwed up by reformatting. The indentation of HTML tags and JSP scriptlets according to code-blocks is completely removed, leaving an unreadable mess.

<html>
<head><title>Simple jsp page</title></head>
<body>
<% if (request.getParameter("...") != null) { %> <p>case 1</p> <% } else if (true) { %>
<% if (false) { %> <p>case 2.1</p> <% } else { %> <p>case 2.2</p> <% } %>
<% } else { %> <p>case 3</p> <% } %>
</body>
</html>



 All   Comments   Work Log   Change History      Sort Order:
AlexL - 25 Jan 06 10:02
The extent that this code gets messed up upon reformatting depends on your code style settings.
Things get much worse if you have HTML->Keep line breaks disabled.

IntelliJ should be calculating indent levels of the java code without regard to indent level of '<%' or '%>' or the indent level of the the html tags. Actually, I suppose someone might like it to indent starting at '<%', but that only works if the formatter can place the each '<%' at the right level.

It looks like IntelliJ newline indent algorithm is just looking at the enclosing indent level of the '<%' rather than backing up to the last line of java code.

For example,
<%
int a;
%>

If I move '<%' 10 spaces in, and then reindent "int a;", it will be indented starting at position of the '<%', rather than the previous last java line, or in this case, the outer class level which should be indent level 1.

<%
int a;
%>

I would rather IntelliJ ignore the position of '<%', and do
<%
int a;
%>

I guess this may be personal preference, but I think of all the code within the <% %> blocks as being part of one big method, so I want them all indented at the same level, irregardless of the position of '<%' '%>' tags and the html tags.

The current formatter does some really wierd stuff to the exmaple above like producing:

<% } else if (true) { %> <% if (false) { %>

It should be enforcing the java code indentation above all else.