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 144382 - Code completion for Java does not work in nonparsable JSP
Summary: Code completion for Java does not work in nonparsable JSP
Status: RESOLVED WORKSFORME
Alias: None
Product: javaee
Classification: Unclassified
Component: JSP (show other bugs)
Version: 6.x
Hardware: Sun All
: P3 blocker (vote)
Assignee: Anton Chechel
URL:
Keywords:
: 123139 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-19 12:36 UTC by Jindrich Sedek
Modified: 2011-04-28 14:05 UTC (History)
5 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 Jindrich Sedek 2008-08-19 12:36:25 UTC
Create new WebApplication
use this code inside index.jsp:
-----------------
<%@ include file="test.jspf" %>
<%
            Object ob;
            application.equals(obj);
%>
---------------------
You have no test.jspf to include so the file is broken and no completion is invoked in scriptlet.
No message is given to user, no warning, it just doesn't work...
Some message should be shown to user instead of the list of java keywords like "abstract, class, final, import" that 
makes no sence is JSP

I would recommend some text in simmilar way as "No suggestions" is used.
For example "File nonparsable" could be shown - probably Ondra could give us some advice.
Comment 1 Tomasz Slota 2008-09-10 14:26:52 UTC
jsedek and I agreed that the best solution would be to offer a single completion item saying smth like "unparsable source" in case it is not possible to parse 
the file. At the moment when the file is not parsable am passing an empty string to the java infrastructure, hence the random keyword results. I can't just 
pass null cos the infrastructure does not handle it.

So it looks like the fix should be performed on the java side and it would involve handling null value returned by the 
SimplifiedJSPServlet.getVirtualClassBody(). The SimplifiedJSPServlet.getVirtualClassBody() method should be also changed to return null instead of an empty 
string in case parsing fails, it is a trivial change.
Comment 2 Jan Lahoda 2008-09-10 15:11:22 UTC
Wouldn't it be better to:
-fix the error recovery to produce a reasonable Java virtual source (so that e.g. semantic highlighting would work, the
CC would work, etc.)
-place an error mark on the "include file=" line, explaining the the file cannot be load/found/included?
Comment 3 Tomasz Slota 2008-09-10 15:26:32 UTC
jlahoda: we do not own the jsp parser code. Trying to work it around on our side does not seem to be worth the effort, we would eventually end up with a 
huge chunk of code to maintain and after all embedding java code in JSP is considered a bad practice...
Comment 4 Dusan Balek 2008-09-10 16:37:46 UTC
JavaCompletinProvider modified to return "No suggestion". See:
changeset 82ace56021b8 in main
details: http://hg.netbeans.org/main?cmd=changeset;node=82ace56021b8
Comment 5 Tomasz Slota 2008-09-10 16:40:24 UTC
With dbalek's commit this issue becomes a P3 at most. There seem to be no easy way to customize the message
Comment 6 Jan Lahoda 2008-09-10 16:53:30 UTC
Sorry, but I (having "my user's hat on") cannot agree with P3 - there needs to be at least an error explaining the user
what is going on (independent on CC).

<rant>Why do we have a Java support in JSP, if it practically does not work?</rant>
Comment 7 Tomasz Slota 2008-09-10 17:08:39 UTC
The parser error messages are still displayed in the editor's status bar. They are not always as helpful as they should be but I really dont think it's a P2 now.
Comment 8 Jan Lahoda 2008-09-10 17:34:24 UTC
Well, the StatusBar errors are at least some feedback (it was not clear from the original report that these are shown).
This errors disappear after cursor movement, etc., so the user may not notice them.

BTW: what I do not understand is: when the code completion showed "non-senses", this was a P2. When code navigation in
the scriplet does not work (it does not work for me, at least) it is a P3? (Not speaking about semantic highlighting,
Java errors and the fact that the CC does not propose anything.)
Comment 9 Tomasz Slota 2008-09-11 08:49:33 UTC
The original priority of this bug as well as the one about navigation not working in scriptlets (btw. is it reported?)  are questionable.  For me they are more like 
"outstanding P3s". In cases like this we try to agree on the priority with jsedek and mfukala. 

As for this bug in the current state we agreed on P3, the parser warning is visible enough.
Comment 10 Jan Lahoda 2008-09-11 08:56:01 UTC
re is it reported?: the code navigation does not work in the Java scriplet in the above code, as well as no parser-based
Java feature (at least for me). So, I assume it is reported in this issue.
Comment 11 Quality Engineering 2008-09-11 17:33:38 UTC
Integrated into 'main-golden', will be available in build *200809111401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/82ace56021b8
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #144382: use info message in cc instead of java keywords in nonparsable JSP - partial fix.
Comment 12 Tomasz Slota 2008-10-08 10:46:27 UTC
*** Issue 123139 has been marked as a duplicate of this issue. ***
Comment 13 Petr Jiricka 2009-11-05 13:18:05 UTC
I agree with Jan Lahoda's suggestions:

> -fix the error recovery to produce a reasonable Java virtual source (so that e.g. semantic highlighting would work, 
> the CC would work, etc.)

Though this may be hard to do, as the JSP parser is a mess, we don't own the code, noone is maintaining it and any
change is very risky. Instead, could we use the latest valid result? For example:
* if I fix this code to make it parseable, completion starts to work again
* if I break the code again, completion stops working. In this case, we should use the previous valid parse result.

> -place an error mark on the "include file=" line, explaining the the file cannot be load/found/included?

Definitely.
Comment 14 Petr Jiricka 2009-11-05 14:48:40 UTC
Issue 117339 complains about a similar case:

1. Create Java class p.MyClass 
2. Add public static method getHello() to this class
3. Put the following in index.jsp:
<%@page import="p.MyClass" %>
<%@include file="nonfile.jsp" %>
<% MyClass.getHello(); %>

Code completion does not work on the last line after MyClass.|

Comment 15 Marek Fukala 2009-11-05 15:55:15 UTC
PetrJ suggestion to use last successfuly parsed result sounds reasonable. I rather wander it is not done this way
already. The problem is if there's isn't any successful parser result like when you open an errornous file.
Comment 16 Petr Jiricka 2009-11-05 17:16:30 UTC
After discussing with Marek, we think this is quite serious, raising to P2. If this is really hard to fix, then we can
waive for 6.8, but we should try to fix. Also adjusting summary.

> The problem is if there's isn't any successful parser result like when you open an errornous file.

Yes, but this is a lower priority aspect. If the page was parseable at least for a while, then completion should offer
something - this is the P2 aspect that should be fixed.
Comment 17 Tomasz Slota 2009-11-09 06:19:31 UTC
We agreed with Marek that the issue can be downgraded to P3 if I improve error reporting by underlining the first line with an error annotation and the message from the parser. Unfortunately any other fix does not seem to be feasible - things should be improved on the JSP parser side.
Comment 18 Tomasz Slota 2009-11-10 03:16:00 UTC
the improvement mentioned above:
http://hg.netbeans.org/web-main/rev/911091ed6514
Comment 19 Quality Engineering 2009-11-13 06:44:06 UTC
Integrated into 'main-golden', will be available in build *200911131401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/911091ed6514
User: Tomasz Slota <tslota@netbeans.org>
Log: #144382: Code completion for Java does not work in nonparsable JSP
Comment 20 Anton Chechel 2011-04-28 14:05:46 UTC
Product Version: NetBeans IDE Dev (Build 20110411-95fa2f6ba3a6)
Java: 1.6.0_23; Java HotSpot(TM) 64-Bit Server VM 19.0-b09
System: Windows 7 version 6.1 running on amd64; Cp1252; en_US (nb)
Userdir: C:\Projects\netbeans\web-main\nbbuild\testuserdir

1. I am getting error annotation: "PWC6117: File "/test.jspf" not found" in editor and in compilation result as well.
2. CC works fine.

Works for me.