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.
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.
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.
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?
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...
JavaCompletinProvider modified to return "No suggestion". See: changeset 82ace56021b8 in main details: http://hg.netbeans.org/main?cmd=changeset;node=82ace56021b8
With dbalek's commit this issue becomes a P3 at most. There seem to be no easy way to customize the message
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>
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.
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.)
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.
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.
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.
*** Issue 123139 has been marked as a duplicate of this issue. ***
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.
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.|
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.
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.
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.
the improvement mentioned above: http://hg.netbeans.org/web-main/rev/911091ed6514
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
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.