This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | HTML indentation fails for some embedded scenarios | ||
---|---|---|---|
Product: | web | Reporter: | Torbjorn Norbye <tor> |
Component: | HTML Editor | Assignee: | Torbjorn Norbye <tor> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | pjiricka, tslota |
Priority: | P3 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 120491 | ||
Bug Blocks: | 104929 |
Description
Torbjorn Norbye
2007-09-21 00:46:56 UTC
*** Issue 116235 has been marked as a duplicate of this issue. *** Formatting is broken by exception thrown when there is a language embedded *inside a tag*. This can be also reproduced in JSP with the following code: <tr class="<%= page %>"> <td></td> </tr> I will probably need support from lexer to fix this. I suggest downgrading to P2. The reason I made it a P1 was the exception popup which occurs whenever you try to edit the file. If that can be resolved (and the exception is coming from TagBasedLexerFormatter), then the rest of the issue can be a P2 - as long as that doesn't mean it won't get done for 6.0 :) Is there anything I can do to help? Do you need a new issue filed against lexer or are you already talking to Mila? As a fallback plan for 6.0 (if we don't get this done), perhaps we can keep the old HTML formatter around, and in the HtmlIndentTask, invoke it whenever we see that the outermost language has mimetype "application/x-httpd-eruby". But this is definitely only an emergency solution. Unfortunately, I think I have to make other changes to the RHTML indenter too (after the above bug is fixed) to address the fact that <% %> sections are no longer indented by the HTML indenter, and so on. So, hopefully this bug won't be fixed at the very last minute before the deadline since I need additional time :) Here's a patch which restores RHTML formatting for now as described above (it -does- expose a lexer bug on some source files) Index: html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTask.java =================================================================== RCS file: /cvs/html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTask.java,v retrieving revision 1.2 diff -u -r1.2 HtmlIndentTask.java --- html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTask.java 17 Sep 2007 15:40:18 -0000 1.2 +++ html/editor/src/org/netbeans/modules/html/editor/indent/HtmlIndentTask.java 21 Sep 2007 15:25:10 -0000 @@ -47,6 +47,15 @@ } public void reindent() throws BadLocationException { + // Workaround for http://www.netbeans.org/issues/show_bug.cgi?id=116231 + String mimeType = NbEditorUtilities.getMimeType(context.document()); + if (mimeType != null && mimeType.equals("application/x-httpd-eruby")) { // NOI18N + new org.netbeans.editor.ext.html.HTMLFormatter(HTMLKit.class). + reformat((BaseDocument) context.document(), + context.startOffset(), context.endOffset(), true);; + return; + } + getFormatter().reformat((BaseDocument) context.document(), context.startOffset(), context.endOffset(), true); } OK, the error window didn't pop up with my config. I already worked around the missing lexer infrastructure and am very close to having this issue fixed, it will not happen today though. Fixed. Checking in web/jspsyntax/src/org/netbeans/modules/web/core/syntax/formatting/JSPLexerFormatter.java; /cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/formatting/JSPLexerFormatter.java,v <-- JSPLexerFormatter.java new revision: 1.4; previous revision: 1.3 done Checking in html/editor/lib/src/org/netbeans/editor/ext/html/HTMLLexerFormatter.java; /cvs/html/editor/lib/src/org/netbeans/editor/ext/html/HTMLLexerFormatter.java,v <-- HTMLLexerFormatter.java new revision: 1.6; previous revision: 1.5 done Checking in xml/tageditorsupport/src/org/netbeans/modules/editor/structure/formatting/TagBasedLexerFormatter.java; /cvs/xml/tageditorsupport/src/org/netbeans/modules/editor/structure/formatting/TagBasedLexerFormatter.java,v <-- TagBasedLexerFormatter.java new revision: 1.13; previous revision: 1.12 done I updated my netbeans as soon as this got fixed. However, there are still some small problems with indentation. 1. extra indent before closing tag after formatting 2. after pressing enter, extra indent inserted before the line under the cursor I've been trying to simplify the case but it played hide-and-seek. Here is as far as I can get: <div> <%if session[:user]%> <%end%> </div> After Alt+Shift+F <div> <%if session[:user]%> <%end%> </div> Or <div> <%if session[:user]%> <%end%> <div>$cursor is here</div> </div> After pressing enter <div> <%if session[:user]%> <%end%> <div> </div> </div> Netbeans is my favorite ruby IDE. Thank you for the great work! I hope I'm providing helpful information. Thank you for your feedback arrix. The HTML formatting/indentation has been undergoing massive changes, hopefully the situation is stabilized now. I've just committed a few fixes in the new line line indentation area, they are not present in any build yet. Tor please have a look at the RHTML-specific issues, if there are problems please file separate bugs. I examined the specific scenario which is still reproducible: <div> <%if session[:user]%> <%end%> </div> It turns out that the JRuby lexer is incorrectly passing the second "]" as an identifier token rather than an RBRACKET, which breaks the formattter. I added a similar workaround to one I have for a few "[" identifiers instead of LBRACKETs and formatting now passes this test. I believe everything else should work in RHTML indentation now (and in particular the two previous broken code fragments listed in this bug report), so closing this older issue as fixed. |