Community
Participate
Working Groups
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>
Created attachment 105527 [details] Bug screenshot
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.
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".
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.
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?
test
Hi Matthias, I had to tweak the patch a little to get it to apply. Everything looks great to me. Thanks for the patch!
*** Bug 248996 has been marked as a duplicate of this bug. ***