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: | NPE from IndentImpl$TaskHandler when pressing enter | ||
---|---|---|---|
Product: | editor | Reporter: | Marek Fukala <mfukala> |
Component: | Formatting & Indentation | Assignee: | Miloslav Metelka <mmetelka> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | ||
Priority: | P2 | ||
Version: | 6.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 102058 | ||
Attachments: |
The NPE
The new NPE at org.netbeans.modules.editor.indent.IndentImpl$MimeItem.lock(IndentImpl.java:407) |
Description
Marek Fukala
2007-06-18 14:26:30 UTC
Created attachment 43882 [details]
The NPE
I have added the assignment and I'm writing a test for this. after the fix I am getting another NPE (whole stack is attached): SEVERE [global] java.lang.NullPointerException at org.netbeans.modules.editor.indent.IndentImpl$MimeItem.lock(IndentImpl.java:407) at org.netbeans.modules.editor.indent.IndentImpl$TaskHandler.lock(IndentImpl.java:286) Created attachment 43897 [details]
The new NPE at org.netbeans.modules.editor.indent.IndentImpl$MimeItem.lock(IndentImpl.java:407)
The problem is null returned from impl of IdentTask: public ExtraLock indentLock() { return null; } ...which is allowed according to the javadoc. after: void lock() { if(extraLock != null) { extraLock.lock(); } } void unlock() { if(extraLock != null) { extraLock.unlock(); } } it works fine and finally calls my SPI implementation!!! Yippee :-) Oops, I thought that this was already covered by present tests but I was wrong. I will add the necessary tests. Fixed: Checking in IndentImpl.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/IndentImpl.java,v <-- IndentImpl.java new revision: 1.3; previous revision: 1.2 BTW I have added a test for TokenHierarchy.languagePaths() that is used by the indentation code. Improved embedded sections processing: Checking in TaskHandler.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/TaskHandler.java,v <-- TaskHandler.java initial revision: 1.1 done Checking in IndentImpl.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/IndentImpl.java,v <-- IndentImpl.java new revision: 1.4; previous revision: 1.3 done Checking in IndentSpiPackageAccessor.java; /cvs/editor/indent/src/org/netbeans/modules/editor/indent/IndentSpiPackageAccessor.java,v <-- IndentSpiPackageAccessor.java new revision: 1.3; previous revision: 1.2 Checking in 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 initial revision: 1.1 done Checking in nbproject/project.xml; /cvs/editor/indent/nbproject/project.xml,v <-- project.xml new revision: 1.3; previous revision: 1.2 done Checking in 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.3; previous revision: 1.2 I impelemnted the IndentTask also for JSP mimetype and found following issues so far: 1) the embedded IndentTasks are not called when modifying a document containing their embedded pieces. In particular formatting HTML code in JSP doesn't invoke the HTML one. 2) I have some problems with caret position when pressing ENTER in the editor. The row indent is properly changed, but the caret stays at the beginning of the line. 3) I noticed slightly different behaviour between the old infrastructure and the new one in the case when enter is pressed. In such case the IndentTask gets an instance of Context which endoffset = startoffset + 1; In the previous impl. they were the same. This is just minor issue OTOH. Please address primarily #1, #2 can be workaround as well as #3. Apologies, I'm currently working on all of these. 2) should be fixed by following: /cvs/editor/indent/src/org/netbeans/modules/editor/indent/FormatterImpl.java,v <-- FormatterImpl.java new revision: 1.3; previous revision: 1.2 |