Bug 237967 - Errors on JSP Editor caused by EL validation or parser
Summary: Errors on JSP Editor caused by EL validation or parser
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P2 major with 23 votes (vote)
Target Milestone: 3.2 M3   Edit
Assignee: Nick Sandonato CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: contributed, needinfo
: 248996 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-06-20 13:59 EDT by Pedro Boschi CLA
Modified: 2010-03-14 23:13 EDT (History)
8 users (show)

See Also:
thatnitind: review+
nsand.dev: review+


Attachments
Bug screenshot (59.10 KB, image/jpeg)
2008-06-20 14:00 EDT, Pedro Boschi CLA
no flags Details
patch to solve some of the problems with the example (6.09 KB, patch)
2008-06-24 18:07 EDT, Matthias Fuessel CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pedro Boschi CLA 2008-06-20 13:59:53 EDT
When creating a JSP using default JSTL expressions, Eclipse's JSP editor looses itself creating several parser errors. These errors occur when Strings are used as parameters to TAG functions.

The code bellow is a simple example that cause this error.
Attached to this there is the screenshot displaying the description of one error  point displayed.



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
  "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<html>
<body>
  <c:out value="${fn:length('string test')}" />
  <c:out value="${fn:length('string test')}" />
  <c:out value="${fn:length('string test')}" />
</body>
</html>
Comment 1 Pedro Boschi CLA 2008-06-20 14:00:48 EDT
Created attachment 105527 [details]
Bug screenshot
Comment 2 Matthias Fuessel CLA 2008-06-24 17:57:45 EDT
This is because ELGeneratorVisitor generates java function definition for every ASTExpression it encounters. Unfortunately the parameters of el functions are are also ASTExpressions, so it generates function definitions within function definitions.
Comment 3 Matthias Fuessel CLA 2008-06-24 18:07:46 EDT
Created attachment 105765 [details]
patch to solve some of the problems with the example

This moves the triggering of function definition generation from ELGeneratorVisitor to ELGenerator, so that it doesn't generate new function definitions for method parameters.

It allows el functions to throw JspExceptions (as the length-function does). (Don't know if other exceptions are allowed, too).

It changes behaviour when the generator can't generate java code for an el expression: now it only removes the generated function for /this/ el expressions, not all functions (untested).

And finally it translates 'string literals' to java "string literals".
Comment 4 Matthias Fuessel CLA 2008-06-24 18:27:37 EDT
Now I only get ~30 warnings that I should use generics for the Maps (in the generated code) :-(

...which unfortunately don't have correct line information so that they aren't even shown in the jsp file.

I'm afraid the whole jsp translation process needs some serious work.
Comment 5 Nitin Dahyabhai CLA 2008-06-30 17:15:52 EDT
Many thanks for the patch, Matthias.  Is the begin/end column enough positional information in the changes to the ELGenerator?  Is there any uncertainty about the first and last tokens being on different lines?
Comment 6 xiaoqiang CLA 2008-12-09 10:43:25 EST
test
Comment 7 Nick Sandonato CLA 2009-10-13 14:14:18 EDT
Hi Matthias, I had to tweak the patch a little to get it to apply. Everything looks great to me. Thanks for the patch!
Comment 8 Nick Sandonato CLA 2009-10-13 14:18:06 EDT
*** Bug 248996 has been marked as a duplicate of this bug. ***