Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 332072

Summary: Exception in JSPELParserTokenManager causes the Content Assist not to show the proposals.
Product: [WebTools] Java Server Faces Reporter: Victor Rubezhny <vrubezhny>
Component: UIAssignee: Ian Trimble <ian.trimble>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: alkazako, raghunathan.srinivasan, thatnitind, vyemialyanchyk
Version: unspecifiedFlags: raghunathan.srinivasan: iplog+
Target Milestone: 3.3 M7   
Hardware: PC   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
The patch adds an additional catch for TokenMgrError to getVisitorForPosition() method due to prevent the crash when <EOF> or other parse error occurred raghunathan.srinivasan: iplog+

Description Victor Rubezhny CLA 2010-12-07 14:06:22 EST
Build Identifier: I20100608-0911

An exception occurres while trying to use Content Assistant in JSP page for non-finished EL-expression in Dynamic Web Project (with JSF Facet). For example, when trying to select/insert a resource bundle property by Content Assistant into the following attribute value:

<h:outputText value="#{Message['|}" />,

where "|"-character indicated the cursor position where the Content Assist is invoked.

No proposals is shown in this particular case and Error Log says that the following exception occurred:

org.eclipse.jst.jsp.core.internal.java.jspel.TokenMgrError: Lexical error at line 1, column 10.  Encountered: <EOF> after : ""
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParserTokenManager.getNextToken(JSPELParserTokenManager.java:851)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_scan_token(JSPELParser.java:1379)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_25(JSPELParser.java:1027)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_23(JSPELParser.java:1006)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_21(JSPELParser.java:1071)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_19(JSPELParser.java:1086)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_17(JSPELParser.java:1142)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_15(JSPELParser.java:1174)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_13(JSPELParser.java:1200)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_11(JSPELParser.java:888)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_9(JSPELParser.java:1062)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_38(JSPELParser.java:903)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_37(JSPELParser.java:910)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_36(JSPELParser.java:930)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_32(JSPELParser.java:954)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_29(JSPELParser.java:936)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_27(JSPELParser.java:993)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_26(JSPELParser.java:999)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_23(JSPELParser.java:1008)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_21(JSPELParser.java:1071)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_19(JSPELParser.java:1086)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_17(JSPELParser.java:1142)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_15(JSPELParser.java:1174)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_13(JSPELParser.java:1200)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_11(JSPELParser.java:888)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3R_9(JSPELParser.java:1062)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_3_1(JSPELParser.java:883)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.jj_2_1(JSPELParser.java:870)
	at org.eclipse.jst.jsp.core.internal.java.jspel.JSPELParser.Expression(JSPELParser.java:44)
	at org.eclipse.jst.jsf.core.internal.contentassist.el.ContentAssistParser.getVisitorForPosition(ContentAssistParser.java:100)
	at org.eclipse.jst.jsf.core.internal.contentassist.el.ContentAssistParser.getPrefix(ContentAssistParser.java:64)
	at org.eclipse.jst.jsf.ui.internal.contentassist.el.JSFELContentAssistProcessor.computeCompletionProposals(JSFELContentAssistProcessor.java:71)
	at org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.collectProposals(StructuredContentAssistProcessor.java:463)
	at org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor.computeCompletionProposals(StructuredContentAssistProcessor.java:249)
	at org.eclipse.wst.sse.ui.internal.contentassist.CompoundContentAssistProcessor.computeCompletionProposals(CompoundContentAssistProcessor.java:126)
	at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1834)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:556)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:553)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:488)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:482)
	at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1660)
	at org.eclipse.wst.sse.ui.internal.StructuredTextViewer.doOperation(StructuredTextViewer.java:441)
	at org.jboss.tools.jst.jsp.jspeditor.JSPTextEditor$JSPStructuredTextViewer.doOperation(JSPTextEditor.java:679)
	at org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:129)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
	at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
	at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1525)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1257)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1282)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1267)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1294)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:730)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:2839)
	at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:734)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1743)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:4794)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4372)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:8163)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1239)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2224)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3169)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

Reproducible: Always

Steps to Reproduce:
1. Create a Dymamic Web Project (With JSF Facet)
2. Create JSP Page and load a message bundle to be used on the page, for example:

<f:loadBundle var="Message" basename="demo.Messages" />

3. Add the following tag to the page:

<h:outputText value="#{Message['|}" />

4. Place the cursor instead of "|" character and invoke the Content Assist.

5. Result see the exception in Error Log
Comment 1 Victor Rubezhny CLA 2010-12-08 08:48:47 EST
Created attachment 184783 [details]
The patch adds an additional catch for TokenMgrError to getVisitorForPosition() method due to prevent the crash when <EOF> or other parse error occurred

The patch adds an additional catch for TokenMgrError to getVisitorForPosition() method due to prevent the crash when <EOF> or other parse error occurred, so the ContentAssist may continue to collect proposals.
Comment 2 Nick Sandonato CLA 2011-04-13 10:27:30 EDT
Patch is in JSF.
Comment 3 Raghunathan Srinivasan CLA 2011-04-13 12:26:37 EDT
Thanks for the patch. We will review for inclusion in Indigo.
Comment 4 Ian Trimble CLA 2011-04-13 17:35:42 EDT
Swallowing an exception and simply returning null merely prevents an entry in the error log. It doesn't result in any content assist appearing, it just silently ignores what could be a valid problem in JSPELParser. JSF is just one client of the JSPELParser; rather than have each client swallow its exceptions, JSPELParser should deal with it. I don't find the patch to be valid, and I don't see the issue to be in the JSF Tools component.
Comment 5 Ian Trimble CLA 2011-04-13 17:59:02 EDT
Since JSF is the invoker of the parser, and since we only care to get proposals where it is possible (and here it is not), I suppose it's not a terible thing to do to swallow an exception that we are expecting and want to handle by simply returning null.

But I'm not seeing any proposals. Is there an adopter-contributed CA processor that is being blocked by this exception?
Comment 6 Ian Trimble CLA 2011-04-13 18:24:12 EDT
Fix submitted at 2011/04/13 03:21PM PDT.

We invoke the parser, and can do no more when the parser throws this exception, so catching and returning null is valid. I see no content assist, though, so assuming that this exception blocks someone else's contributed CA processor.
Comment 7 Victor Rubezhny CLA 2011-04-13 18:35:03 EDT
(In reply to comment #6)
> Fix submitted at 2011/04/13 03:21PM PDT.
> 
> We invoke the parser, and can do no more when the parser throws this exception,
> so catching and returning null is valid. I see no content assist, though, so
> assuming that this exception blocks someone else's contributed CA processor.

The blocked CA-processor is not in WTP but the third-party one.

Thank you for paying attention for the issue.