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 213963 - Code completion for bean in JSP can't finish for some methods
Summary: Code completion for bean in JSP can't finish for some methods
Status: VERIFIED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: JSP (show other bugs)
Version: 7.2
Hardware: PC Linux
: P2 normal (vote)
Assignee: Martin Fousek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-11 11:49 UTC by Vladimir Riha
Modified: 2012-09-08 12:59 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2012-06-11 11:49:57 UTC
Use following code in JSP file (GlassFish 3.1.2, Java EE 6 Web):

==START
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <jsp:useBean class="java.util.Date" id="mm" scope="request"/>
    <% mm.getD  
    <body>
        <h1>Hello World!</h1>
    </body>
</html>

==END

- Invoke cc for the "mm.getD", select getDate() and press Enter
=> nothing happens. The same goes for getTime(), surprisingly getClass() works fine. If I close the scriptlet tag ("%>") and invoke cc again, it works


Product Version: NetBeans IDE Dev (Build 201206110001)
Java: 1.7.0_04; Java HotSpot(TM) Client VM 23.0-b21
System: Linux version 3.0.0-20-generic-pae running on i386; UTF-8; en_US (nb)
Comment 1 Vladimir Riha 2012-06-26 12:34:15 UTC
Another case:
<% mm.

Invoke cc, select and confirm "after(when)". Result:

=>  <% mm.(when)

Again, closing %> helps

Product Version: NetBeans IDE 7.2 RC1 (Build 201206252201)
Java: 1.7.0_06-ea; Java HotSpot(TM) Client VM 23.2-b05
System: Linux version 3.0.0-21-generic-pae running on i386; UTF-8; en_US (nb)
Comment 2 Petr Jiricka 2012-08-27 09:00:08 UTC
Martin, could you please investigate this? Possibly a 7.2 patch candidate. Thanks.
Comment 3 Martin Fousek 2012-08-28 06:39:59 UTC
(In reply to comment #2)
> Martin, could you please investigate this? Possibly a 7.2 patch candidate.
> Thanks.

Hard to say whether to put it into patch or not. I'm a little bit afraid of possible regressions since I didn't know much jsp sources and there is only several tests.

The completing works wrong since whole rest of the file is taken as a SCRIPTLET item which causes issues by using standard Java's completion infrastructure. Guess where the unfinished SCRIPTLET ends just in the JspLexer is probably impossible so the fix came to the generation of the simplified servlet for completion and Java is embedded there only to the cursor position (which suffers for this purpose).

So if you think that the issue is severe enough, I think that it could go to the patch but it's really necessary to test a lot from QE this issue and for assurance also other code completion in the scriplets.

Fixed in web-main #b77c3cab6cea.
Comment 4 Martin Fousek 2012-08-28 12:27:01 UTC
Marek, we are waiting with the resolution whether the fix will go to the patch or not for testing by Lada. Anyway could you review that change for assurance in advance?

The principle of that change is that the whole unfinished SCRIPTLET token, including HTML code behind, is passed to (created embedded source for) Java CC. And I didn't get an idea how to differ where the scriptlet ends in it the JspLexer - if possible at all. So if something like that happens (unfinished scriptlet) it is cut to the caret position (where we are btw. asking for the completion).

Thanks a lot...
Comment 5 Quality Engineering 2012-08-29 02:41:38 UTC
Integrated into 'main-golden', will be available in build *201208290001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/b77c3cab6cea
User: Martin Fousek <marfous@netbeans.org>
Log: #213963 - Code completion for bean in JSP can't finish for some methods
Comment 6 Vladimir Riha 2012-08-29 06:40:17 UTC
Thanks, it fixed the problem and other code completion also works as expected
=> verified
Comment 7 Marek Fukala 2012-08-29 11:35:07 UTC
I'm afraid I cannot confirm the fix is ok. The idea of cutting the rest of the scriptlet after the caret is great, but as I'm looking it the diff I believe it happens also in correctly terminated scriptlets. In such case the diff may cause regressions as the code below the caret also matters. For example in scriptlet declarations you may define some methods which then goes the the servlet body. Having the fix as it is they wouldn't get to the generated servlet and some errors may pop-up, completion would be affected etc. In general the behavior of the java support would depend upon the caret position.

I believe the "current" scriptlet should be tested for the presence of the end delimiter (%>) and the cut to the caret position should be done only if the scriptlet is unfinished (the sctiptlet token ends at the end of the file).

BTW, please verify the behavior of following example:

<% java code | --editing here

...html...

<% java code 2 %>

I'm not sure how the JspLexer creates the sctiptlet token (if it check presence of open scriptlet delimiter inside a scriptlet.
Comment 8 Vladimir Riha 2012-08-29 11:53:21 UTC
(In reply to comment #7)
> please verify the behavior of following example:
> 
> <% java code | --editing here
> 
> ...html...
> 
> <% java code 2 %>

I have no problem with code completion or coloring but there is some (I don't if related, will try older build) problem that if you make some (syntax) error like missing semicolon then this error doesn't go away unless you: edit the 2nd one or reopen file. Is this the issue you are talking about?
Comment 9 Vladimir Riha 2012-08-29 11:54:50 UTC
(In reply to comment #8)
> if you make some (syntax) error

*in the first scriptlet
Comment 10 Marek Fukala 2012-08-29 11:58:01 UTC
(In reply to comment #9)
> (In reply to comment #8)
> > if you make some (syntax) error
> 
> *in the first scriptlet

(In reply to comment #8)
> (In reply to comment #7)
> > please verify the behavior of following example:
> > 
> > <% java code | --editing here
> > 
> > ...html...
> > 
> > <% java code 2 %>
> 
> I have no problem with code completion or coloring but there is some (I don't
> if related, will try older build) problem that if you make some (syntax) error
> like missing semicolon then this error doesn't go away unless you: edit the 2nd
> one or reopen file. Is this the issue you are talking about?
No, that's completely different (wery well known, super hard to fix issue - synchronization between parsing.api tasks and jasper jsp parser) issue.
Comment 11 Martin Fousek 2012-08-29 13:20:03 UTC
> I believe the "current" scriptlet should be tested for the presence of the end
> delimiter (%>) and the cut to the caret position should be done only if the
> scriptlet is unfinished (the sctiptlet token ends at the end of the file).

Thanks for good catch and detailed review. Applied in:
http://hg.netbeans.org/web-main/rev/f1aab9c4008c

Vlado, could you give it also another try tommorow? Thanks.
Comment 12 Vladimir Riha 2012-08-29 19:37:44 UTC
of course, I'll try.
Comment 13 Quality Engineering 2012-08-30 02:13:02 UTC
Integrated into 'main-golden', will be available in build *201208300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/f1aab9c4008c
User: Martin Fousek <marfous@netbeans.org>
Log: #213963 - Code completion for bean in JSP can't finish for some methods
Comment 14 Vladimir Riha 2012-08-30 15:23:49 UTC
carefully saying it's OK :) Sorry for delay, I didn't get a email from Bugzilla...

Product Version: NetBeans IDE Dev (Build 201208300001)
Java: 1.7.0_06; Java HotSpot(TM) Client VM 23.2-b09
System: Linux version 3.2.0-29-generic-pae running on i386; UTF-8; en_US (nb)
Comment 15 Martin Fousek 2012-08-30 16:51:14 UTC
(In reply to comment #14)
> carefully saying it's OK :) Sorry for delay, I didn't get a email from
> Bugzilla...

Thanks a lot Lado! I'll transplant it tomorrow.
Comment 16 Martin Fousek 2012-08-31 06:37:26 UTC
Transplanted related changes into releases#release72 branch:

changeset:   237344:c452240b2b31
description:
#213963 - Code completion for bean in JSP can't finish for some methods
(transplanted from b77c3cab6ceab41fd8f3eb965e0c801ca2f89f93)

changeset:   237345:2c1883f9e46b
description:
updated comment
(transplanted from 88eae207b9ccbb90a8dc85a6b5518052a9f01374)

changeset:   237346:c3edec76c140
description:
#213963 - Code completion for bean in JSP can't finish for some methods
(transplanted from f1aab9c4008c4c056c6e420e140e456fe22bc870)

changeset:   237347:17a32cc9f7b2
description:
Spec. version and long description update for issue #213963
Comment 17 Quality Engineering 2012-09-01 11:12:09 UTC
Integrated into 'releases', will be available in build *201209010822* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/c452240b2b31
User: Martin Fousek <marfous@netbeans.org>
Log: #213963 - Code completion for bean in JSP can't finish for some methods
(transplanted from b77c3cab6ceab41fd8f3eb965e0c801ca2f89f93)
Comment 18 Vladimir Riha 2012-09-08 12:59:46 UTC
seems fine in patch => verified


Product Version: NetBeans IDE 7.2 (Build 201207171143)
Java: 1.7.0_07; Java HotSpot(TM) Client VM 23.3-b01
System: Linux version 3.2.0-29-generic-pae running on i386; UTF-8; en_US