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.
Scriptlet formatting doesn't work due to the fact that java formatter is not receiving information of which parts of the file should be formatted. Milo please reassign the issue to Dusan after providing the enhancements we discussed (in the formatting framework).
Assigning to the editor component.
The requierements should be addressed but I would like to add some more tests before reassigning to Dusan. Checking in indent/src/org/netbeans/api/editor/indent/IndentUtils.java; /cvs/editor/indent/src/org/netbeans/api/editor/indent/IndentUtils.java,v <-- IndentUtils.java new revision: 1.4; previous revision: 1.3 done Checking in indent/src/org/netbeans/api/editor/indent/Indent.java; /cvs/editor/indent/src/org/netbeans/api/editor/indent/Indent.java,v <-- Indent.java new revision: 1.4; previous revision: 1.3 done Checking in src/org/netbeans/modules/editor/NbEditorDocument.java; /cvs/editor/src/org/netbeans/modules/editor/NbEditorDocument.java,v <-- NbEditorDocument.java new revision: 1.44; previous revision: 1.43 done Checking in indent/apichanges.xml; /cvs/editor/indent/apichanges.xml,v <-- apichanges.xml new revision: 1.5; previous revision: 1.4 done Checking in indent/src/org/netbeans/modules/editor/indent/FormatterOverrideImpl.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/FormatterOverrideImpl.java,v <-- FormatterOverrideImpl.java new revision: 1.4; previous revision: 1.3 done Checking in indent/src/org/netbeans/modules/editor/indent/TaskHandler.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/TaskHandler.java,v <-- TaskHandler.java new revision: 1.12; previous revision: 1.11 done Checking in indent/src/org/netbeans/modules/editor/indent/IndentImpl.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/IndentImpl.java,v <-- IndentImpl.java new revision: 1.14; previous revision: 1.13 done Checking in indent/src/org/netbeans/modules/editor/indent/FormatterImpl.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/FormatterImpl.java,v <-- FormatterImpl.java new revision: 1.10; previous revision: 1.9 done Checking in indent/src/org/netbeans/modules/editor/indent/IndentSpiPackageAccessor.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/IndentSpiPackageAccessor.java,v <-- IndentSpiPackageAccessor.java new revision: 1.6; previous revision: 1.5 done Checking in lib/nbproject/project.properties; /cvs/editor/lib/nbproject/project.properties,v <-- project.properties new revision: 1.24; previous revision: 1.23 done Checking in indent/src/org/netbeans/spi/editor/indent/Context.java; /cvs/editor/indent/src/org/netbeans/spi/editor/indent/Context.java,v <-- Context.java new revision: 1.6; previous revision: 1.5 done Checking in libsrc/org/netbeans/editor/BaseDocument.java; /cvs/editor/libsrc/org/netbeans/editor/BaseDocument.java,v <-- BaseDocument.java new revision: 1.150; previous revision: 1.149 done Checking in indent/nbproject/project.properties; /cvs/editor/indent/nbproject/project.properties,v <-- project.properties new revision: 1.5; previous revision: 1.4 done Checking in indent/test/unit/src/org/netbeans/api/editor/indent/EmbeddedIndentTest.java; /cvs/editor/indent/test/unit/src/org/netbeans/api/editor/indent/EmbeddedIndentTest.java,v <-- EmbeddedIndentTest.java new revision: 1.7; previous revision: 1.6 done Checking in lib/apichanges.xml; /cvs/editor/lib/apichanges.xml,v <-- apichanges.xml new revision: 1.12; previous revision: 1.11
*** Issue 118380 has been marked as a duplicate of this issue. ***
Passing to Dusan...
Additional fix for giving indent regions' bounds always within bounds of global bounds. /cvs/editor/indent/src/org/netbeans/modules/editor/indent/TaskHandler.java,v <-- TaskHandler.java new revision: 1.13; previous revision: 1.12
Fixed. Checking in Reformatter.java; /cvs/java/source/src/org/netbeans/modules/java/source/save/Reformatter.java,v <-- Reformatter.java new revision: 1.20; previous revision: 1.19 done
So it should now be fixed completely. Since this is beta2fix I would like to first ask tslota to confirm that the fix eliminates the problem and then QE whether I can integrate into beta2 branch. Only the two last fixed files need to be integrated (the previous complex fix is already in beta2).
I'm affraid this issue is not ready to be integrated into beta2. After invoking reformat code over jsp file containing this scriptlet code: --------------------- <% application.getAttribute("ATTRIB"); int i = 1; if (i < 50) {i++; } %> --------------------- ArrayIndexOutOfBoundsException is thrown and JAVA code is reformated, but not indented - it seems to be reformated, but than "reindented" by html formatter -> reassigning to tslota
I have some changes in my build, which may (but are unlikely to, except perhaps the new line indent) influence the behavior. Anyways, on my machine: - I cannot reproduce the ArrayIndexOutOfBoundsException problem, Jindro can you please attach the stack trace? - new line indentation doesn't work at all - formatting Jindra's sample produces the following result: <% application.getAttribute("ATTRIB"); // indent base is one step too big int i = 1; if (i < 50) { i++; } // closing bracket not indented at all %> Jindro, the Java formatter is called after the JSP and HTML formatters. Current (as of beta2 and hopefully final) implementation of the JSP/HTML formatting does the following to blocks of embedded 3rd languages (such as Java or CSS): - the first line is indented according to HTML/JSP rules - indentation of the following lines is shifted by the difference with the first line - in other words the whole block of embedded code is shifted but formatting within it is preserved. Embedded language formatter should keep the indentation of the first line of the embedded block unchanged and format the other lines accordingly. - the expected behavior of new line indentation is that HTML/JSP formatter will not adjust the indent at all if the cursor is placed inside embedded block It looks like the ball is on Dusan's side, anyways, let's discuss it tomorrow
Created attachment 51201 [details] attaching stacktrace of ArrayIndexOutOfBoundsException
Created attachment 51202 [details] jsp file to reproduce easily
I guess that me and Dusan can fix the } // closing bracket not indented at all but the last AIOOBE is entirely inside org.netbeans.modules.editor.structure.formatting.* which (although it seems that's an editor stuff :) ) was entirely created and maintained by the web team. So unfortunately IMHO we can't fix this into beta2.
Marek volunteered to coordinate this one.
fixed indentation in java scriptlet, that is the part I promised to fix. Reassigning back to Tomasz for reevaluation since I am not sure if I can close the issue as fixed. Checking in JspJavaFormatter.java; /cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/formatting/JspJavaFormatter.java,v <-- JspJavaFormatter.java new revision: 1.3; previous revision: 1.2 done Checking in JSPLexerFormatter.java; /cvs/web/jspsyntax/src/org/netbeans/modules/web/core/syntax/formatting/JSPLexerFormatter.java,v <-- JSPLexerFormatter.java new revision: 1.8; previous revision: 1.7 done
formatting part fixe. /cvs/editor/indent/src/org/netbeans/modules/editor/indent/TaskHandler.java,v <-- TaskHandler.java new revision: 1.15; previous revision: 1.14
verified Product Version: NetBeans IDE Dev (Build 200811050201) Java: 1.6.0_10; Java HotSpot(TM) Client VM 11.0-b15 System: Linux version 2.6.27-7-generic running on i386; UTF-8; en_US
I have a question about change http://hg.netbeans.org/main/rev/08b3015c7a2e which was done to resolve this issue. Do I understand it right that it was a short term hotfix but it never got fixed properly? What I do not like is that Java formatting is hardcoded in JSP formatter whenever enter is pressed on a Java token. For now I locally rewrote it so that there is IndentTask.Factory registered in web.core.syntax module for mime text/x-jsp/text/x-java which returnes IndentTask doing: new JspJavaFormatter(JavaKit.class).reformat(context.document(), context.startOffset(), context.endOffset(), true); That seems to me better than current state, but still half-way solution. Why Java module does not register IndentTask similarly as it registers ReformatTask?
Yes, just workaround as stated in the code.
Dusan, why Java module does not register IndentTask similarly as it registers ReformatTask? I removed (just locally for now) original hotfix and now indentation in Java scriptlet does not work. I tried to solve it properly by using org.netbeans.editor.ext.java.JavaFormatter (see my previous comment) but that does not work either as JavaFormatter does not do any checks if tokens being formatted are actually from JavaTokenContext or not - it blindly reindents everything (eg. HTML tags). What solution do you suggest?
I would like to rewrite the JavaFormatter (still JavaSyntax based) to a regular lexer-based IndentTask. I could possibly make it into 6.7 M3. However additional changes in the Indent API should be discussed as well but that will require a longer discussion.
Thanks Mila. Migrating from old API sounds like good idea. Re "Indent API" - agreed. I have some small API changes done locally but at this stage it is just for experimentation sake. I will see what comes out of it and will talk to you and Vita.