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 177498

Summary: AssertionError: Invalid start:-1
Product: javaee Reporter: Chiana
Component: JSF EditorAssignee: Marek Fukala <mfukala>
Status: RESOLVED FIXED    
Severity: normal CC: Chiana
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter: 162793
Attachments: stacktrace

Description Chiana 2009-11-24 04:41:26 UTC
Build: NetBeans IDE Dev (Build 200911230200)
VM: Java HotSpot(TM) Client VM, 14.2-b01, Java(TM) SE Runtime Environment, 1.6.0_16-b01
OS: Windows Vista, 6.0, x86

User Comments:
Chiana: Editing an xhtml file, pressed esc to remove suggestion window and then backed over a trailing "}" since the editor automagically put #{} into the text when typing # inside an "action=" string that was not empty...



Stacktrace: 
java.lang.AssertionError: Invalid start:-1
        at org.netbeans.modules.csl.api.OffsetRange.<init>(OffsetRange.java:62)
        at org.netbeans.modules.web.jsf.editor.JsfHtmlExtension.getDocumentOffsetRange(JsfHtmlExtension.java:212)
        at org.netbeans.modules.web.jsf.editor.JsfHtmlExtension.highlight(JsfHtmlExtension.java:206)
        at org.netbeans.modules.web.jsf.editor.JsfHtmlExtension.access$000(JsfHtmlExtension.java:101)
        at org.netbeans.modules.web.jsf.editor.JsfHtmlExtension$2.visit(JsfHtmlExtension.java:190)
        at org.netbeans.editor.ext.html.parser.AstNodeUtils.visitChildren(AstNodeUtils.java:374)
Comment 1 Chiana 2009-11-24 04:41:30 UTC
Created attachment 91592 [details]
stacktrace
Comment 2 Marek Fukala 2009-11-30 02:34:44 UTC
Is that issue reproducible? Can you please give a sample code and exact steps to reproduce? I am also little bit confused by your statement that you had to back over the trailing '}' char. The trailing bracket autocompletion should move the caret inside the brackets when you type #{ . Thanks for the feedback.
Comment 3 Chiana 2009-11-30 04:55:08 UTC
I think the problem lies in the fact that the codecompletion automatically adds the trailing } without checking if there is one before...
Here's the setup; have a line that you are tying in a .xhtml
<f:button id="knapp" value="testBean.value" style=
At that point you realized you forgot the #{} and starts backing towards the first parameter, then you add the "}" when you pass by so the string looks like
 //<f:button id="knapp" value="testBean.value}" style=//
after that you continue to the beginning of the parameter and type #{ and then the autocompletion kicks in and the result looks like
 //<f:button id="knapp" value="#{}testBean.value" style=//
but since that is NOT what you want you need to delete the first } whitch IMHO shouldn't have been there in the first place, perhaps an enhancement would be to scan the string to look for an ending } and then don't insert the }, the editor obviously knows you are inside a quoted string.
There is a similar phenomena occuring if you start on the other end (i.e. beginning) but that's another report...
Comment 4 Marek Fukala 2009-11-30 06:30:56 UTC
Chiana, thanks for the detailed explanation, now it's clear what you ment. However, I am still not able to reproduce the exception. Does it happen to you each time?
Comment 5 Marek Fukala 2009-11-30 06:40:03 UTC
fixed in web-main#4740f68485be
Comment 6 Chiana 2009-11-30 06:42:51 UTC
(In reply to comment #4)
> Chiana, thanks for the detailed explanation, now it's clear what you ment.
> However, I am still not able to reproduce the exception. Does it happen to you
> each time?

Oh, yes, every time, i normally don't report every time it happens, as that would probable overload bugzilla B-)
Comment 7 Marek Fukala 2009-11-30 07:10:37 UTC
Can you reproduce it on a new file with just a few necessary lines of code or it is specific to some context? I cannot reproduce following the scenario.

What I do is: 
1) create a xhtml file
2) put <h:outputText value="blabla"/>| 
then continue editing according to the description (| denotes caret)
3) <h:outputText value="blabla}|"/> (move caret back and type })
4) <h:outputText value="${|}blabla}"/> (move caret at the beginning of the attribute value and type {
5) <h:outputText value="#{|blabla}"/> (deleted the first close curly bracket)
6) invoked completion

=> no exception.

Am I doing something wrong?

BTW I've fixed the issue just by ignoring the errorneous offset range, but I am curious what is the cause of the problem. Of course I tried the steps before the fix ;-)

Thanks for your help.
Comment 8 Quality Engineering 2009-12-01 03:05:59 UTC
Integrated into 'main-golden', will be available in build *200912010200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4740f68485be
User: Marek Fukala <mfukala@netbeans.org>
Log: #177498 -  AssertionError: Invalid start:-1