Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 289258 - JSPTranslator should handle assignment in JSP expressions
Summary: JSPTranslator should handle assignment in JSP expressions
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.2 M3   Edit
Assignee: Ian Tewksbury CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 238385
  Show dependency tree
 
Reported: 2009-09-11 15:46 EDT by Ian Tewksbury CLA
Modified: 2009-10-19 13:46 EDT (History)
1 user (show)

See Also:
nsand.dev: review+


Attachments
Fix Patch (1.24 KB, text/plain)
2009-09-11 15:46 EDT, Ian Tewksbury CLA
no flags Details
Fix Patch with JUnit Updates (8.83 KB, patch)
2009-09-14 09:27 EDT, Ian Tewksbury CLA
no flags Details | Diff
Fix Patch Update 1 with JUnit Updates (10.31 KB, patch)
2009-09-16 14:56 EDT, Ian Tewksbury CLA
nsand.dev: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Tewksbury CLA 2009-09-11 15:46:50 EDT
Created attachment 146992 [details]
Fix Patch

+++ This bug was initially created as a clone of Bug #289257 for the 3.2 stream
+++

Currently if a JSP document contains something along the lines of:

<% String foo %>
<%= foo = "Hello World!" %>

It gets translated to:

String foo;
out.print(""+
 foo = "Hello!" 
);

Which has an error on the = saying "Syntax error on token "=". != expected"
which is then displayed to the user in their JSP document.

To fix this issue my patch makes it so the JSP is translated to:

String foo;
out.print(""+(
 foo = "Hello!" 
));

Thus eliminating the error.

It is worth noting that this does bring up another smaller issue in that with
this case "foo" would be marked with a warning saying "The local variable foo
is never read" because it seems the Java compiler is not smart enough to
realize that foo is being read in this case.  This is really a Java compiler
issue and not our issue but we may want to consider opening another bug to make
it so this doesn't happen in JSP page.
Comment 1 Nitin Dahyabhai CLA 2009-09-13 14:48:06 EDT
(In reply to comment #0)
I'm sure this will break some JUnits (or it should), but while you're in there, can you remove the extraneous line delimiters that are inserted around the expressions?  At least for 3.2?

And foo really is never being read, it's only being _written_ to.
Comment 2 Ian Tewksbury CLA 2009-09-14 09:26:31 EDT
(In reply to comment #1)
> (In reply to comment #0)
> I'm sure this will break some JUnits (or it should)

Oops, forgot to check that.  There a couple of failures.  Updates to JUnits will be included with updated patch.

> but while you're in there,
> can you remove the extraneous line delimiters that are inserted around the
> expressions?  At least for 3.2?

Patch to follow.

> And foo really is never being read, it's only being _written_ to.

Hrm, I thought the order of operations here was something like:
1. wright "hello world" to 'foo'.
2. read 'foo' and print it
Comment 3 Ian Tewksbury CLA 2009-09-14 09:27:48 EDT
Created attachment 147099 [details]
Fix Patch with JUnit Updates

This patch removes the extra new lines as requested and updates JUnits for the change.
Comment 4 Ian Tewksbury CLA 2009-09-16 14:56:55 EDT
Created attachment 147366 [details]
Fix Patch Update 1 with JUnit Updates

As per Nick's comment on  Bug 289257 we do not need to be concatenating an empty string onto jsp expressions when translating them to java because of override versions of out.print.

This patch updates the translator to not use parentheses or "" + and updates the JUnits appropriately.
Comment 5 Nick Sandonato CLA 2009-09-28 14:50:11 EDT
Thanks for the patch.
Comment 6 Ian Tewksbury CLA 2009-10-19 13:46:17 EDT
Verified in I-3.2.0-20091017071807