Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 360713 - No JPQL content assist is available when ORM query is inside a CDATA section
Summary: No JPQL content assist is available when ORM query is inside a CDATA section
Status: RESOLVED FIXED
Alias: None
Product: Dali JPA Tools
Classification: WebTools
Component: JPA (show other bugs)
Version: 3.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.3   Edit
Assignee: Pascal Filion CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-12 14:20 EDT by Pascal Filion CLA
Modified: 2012-10-11 13:39 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Filion CLA 2011-10-12 14:20:25 EDT
Steps to reproduce:
1a. Have a project with at least one JPA entity or
1b. Create new JPA project and a new JPA entity
2. Create a JPA ORM Mapping File
3. Add the JPA entity to the ORM
4. Add the following line between <entity> and </entity>
   <named-query name="q"><query>select</query></named-query>
5. Position the cursor before the identifier select and invoke the content assist, three possible choices are displayed in the content assist popup (select, update, delete from)
6. Now change the query to be
   <![CDATA[select e from ]]>
7. No proposals are available at any position within the query.

Problem:
The offset starts at the beginning of the CDATA section but not at the beginning of the query.
Comment 1 Neil Hauge CLA 2012-04-23 17:03:32 EDT
Where did you run across this use case?
Comment 2 Pascal Filion CLA 2012-10-11 13:39:20 EDT
Fix checked into trunk.

The fix involves the following.
- Works with and without a CDATA section.
- Works with the JPQL query starting on the next line, content assist will not remove CDATA tags or the leading whitespace.
- Added support for all HTML pre-defined escape characters, example: &lt; or &#60; which represents <.

API changes:
- XmlQuery
  - Added 3 methods (getActualQuery(), getQueryOffset(), isQueryInsideCDATASection()) to help fix alignment issue of content assist and validation text range.
- JpaJpqlQueryHelper
  - Changed the signature of validate() to better support content assist and validation in split strings in a Java annotation and various layout of the query in XML


Example 1:
<query>select abs(e) from employee e where e.name = 2</query>

Example 2:
<query>
   select abs(e)
   from employee e where e.name = 2
</query>

Example 3:
<query><![CDATA[select abs(e) from employee e where e.name = 2]]></query>

Example 4:
<query><![CDATA[
   select abs(e)
   from employee e
   where e.name = 2]]>
</query>

Example 5:
<query>select &#101; from Employee &#101; where e.name &lt;&gt; &apos;JPQL&apos;</query>
The query is "select e from Employee e where e.name <> 'JPQL'"