This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 442414 - Data loss when formatting JSP that is surrounded by comments
Summary: Data loss when formatting JSP that is surrounded by comments
Status: NEW
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: jst.jsp (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows 7
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: jst.jsp CLA
QA Contact: Nick Sandonato CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-22 14:44 EDT by eneerge@eneerge.net Greene CLA
Modified: 2018-05-24 14:26 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description eneerge@eneerge.net Greene CLA 2014-08-22 14:44:27 EDT
Whenever I format the following text in a JSP, it breaks the javascript code:

<script TYPE="text/javascript">
<!--
  var myVar = <%= otherVariable %>;
-->
</script>


After formatting the above code, it looks like this:
<script TYPE="text/javascript">
<!--
  var myVarotherVariableiable %>
	;
	-->
</script>


I noticed if I removed the <!-- --> comment tags, the formatter still doesn't format the code properly.  The script tags and variable are moved to a new line:

<script TYPE="text/javascript">
	var myVar =
<%=otherVariable%>
	;
</script>



This occurs when formatting a .jsp page.  Didn't notice this until testing a page and received javascript errors.  Luckily my undo history was large enough to recover the code.

Eclipse Luna
Comment 1 Carl Anderson CLA 2014-08-22 16:03:41 EDT
I am not sure if this is a JSP issue or a JavaScript issue- I will send it to JSP first.
Comment 2 Nick Sandonato CLA 2014-08-28 10:51:56 EDT
The initial problem, when the comment tags are in place, looks to be a translation  problem on our behalf. It looks like somehow the length of the comment start tag isn't being taken into account when setting up the offset mapping between the translation and JSP document.

The odd formatting when you remove the comment tags looks to be a JSDT problem. So you would want to open up a separate defect with them.
Comment 3 Nick Boldt CLA 2018-05-24 14:26:17 EDT
Nitin reports this is a LOT of work to do during triage session in dev call on 05/24.

Downgrading from critical since it's been in queue for 4 years.