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.

Bug 106999 - NPE from IndentImpl$TaskHandler when pressing enter
Summary: NPE from IndentImpl$TaskHandler when pressing enter
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks: 102058
  Show dependency tree
 
Reported: 2007-06-18 14:26 UTC by Marek Fukala
Modified: 2007-11-05 13:39 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The NPE (2.41 KB, text/plain)
2007-06-18 14:27 UTC, Marek Fukala
Details
The new NPE at org.netbeans.modules.editor.indent.IndentImpl$MimeItem.lock(IndentImpl.java:407) (2.49 KB, text/plain)
2007-06-18 16:25 UTC, Marek Fukala
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2007-06-18 14:26:30 UTC
I have created an implementation of the editor/indent SPI and registered it to text/html mimetype. Now I am getting the
attached NPE when pressing enter in html editor. Please address this asap since it blocks the work on the indentation
feature. BTW it looks like a bug in TokenHierarchyOperation.languagePaths() not assigning proper value to the returned
lps  field.
Comment 1 Marek Fukala 2007-06-18 14:27:14 UTC
Created attachment 43882 [details]
The NPE
Comment 2 Miloslav Metelka 2007-06-18 14:31:57 UTC
I have added the assignment and I'm writing a test for this.
Comment 3 Marek Fukala 2007-06-18 16:24:26 UTC
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)
Comment 4 Marek Fukala 2007-06-18 16:25:38 UTC
Created attachment 43897 [details]
The new NPE at org.netbeans.modules.editor.indent.IndentImpl$MimeItem.lock(IndentImpl.java:407)
Comment 5 Marek Fukala 2007-06-18 16:27:52 UTC
The problem is null returned from impl of IdentTask:

 public ExtraLock indentLock() {
        return null;
 }

...which is allowed according to the javadoc.
Comment 6 Marek Fukala 2007-06-18 16:31:10 UTC
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 :-)
Comment 7 Miloslav Metelka 2007-06-19 00:12:55 UTC
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.
Comment 8 Miloslav Metelka 2007-06-22 09:06:46 UTC
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
Comment 9 Miloslav Metelka 2007-06-22 09:50:23 UTC
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
Comment 10 Marek Fukala 2007-06-22 14:22:38 UTC
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.
Comment 11 Miloslav Metelka 2007-06-22 17:28:43 UTC
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