Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 188940

Summary: code completion proposals in JPA XML Mapping file
Product: [WebTools] Dali JPA Tools Reporter: Karen Butzke <karenfbutzke>
Component: JPAAssignee: Nan Li <nan.n.li>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: mlists, neil.hauge, paul.fullbright, thatnitind
Version: 1.0Keywords: plan
Target Milestone: 3.2 M6Flags: neil.hauge: review+
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed patch
none
proposed patch
none
proposed patch
none
proposed patch neil.hauge: iplog+

Description Karen Butzke CLA 2007-05-24 11:19:06 EDT
We need code completion proposals in xml like we have for java:

columns
tables
attributeOverride names
mappedBy
etc
Comment 1 Neil Hauge CLA 2007-07-27 15:39:11 EDT
Proposed for 2.0.
Comment 2 Nitin Dahyabhai CLA 2007-07-30 14:48:41 EDT
I'm not sure I understand the request.  Could someone explain it some more?
Comment 3 Neil Hauge CLA 2008-03-25 23:09:46 EDT
Ran out of time for this in 2.0.  Will look at this for the next feature release.

This feature involves providing code assist for XML attributes and element values where the Dali JPA model can provide assistance, similar to the support we provide in Java Entities.
Comment 4 Paul Fullbright CLA 2010-04-12 13:24:21 EDT
According to a forum post (http://www.eclipse.org/forums/index.php?t=msg&th=165775&start=0&) there is now extension support for xml content assist in wtp.
Comment 5 Karen Butzke CLA 2010-06-03 12:22:10 EDT
I think we should consider this for the next release
Comment 6 Neil Hauge CLA 2011-07-01 16:25:21 EDT
Moving JPA specific bugs to new JPA component in bugzilla.
Comment 7 Nan Li CLA 2012-02-17 17:32:51 EST
Created attachment 211221 [details]
proposed patch
Comment 8 Nan Li CLA 2012-02-20 11:27:40 EST
Besides columns, tables, etc mentioned in the bug description, content assist for the following items (not exhausted) is also supported:

- schema, category, package element of entity-mappings
- elements of persistence-unit-metadata
- type mapping classes
- attribute mapping names
- association-override names
- unique-constraint columns
- generated-value
- convert element
...   ...

Please let me know if anything should be there, but not. Thanks!
Comment 9 Nan Li CLA 2012-02-28 19:50:14 EST
Created attachment 211771 [details]
proposed patch

merged with the latest HEAD code
Comment 10 Nan Li CLA 2012-02-28 19:55:31 EST
Created attachment 211772 [details]
proposed patch

attached as patch file
Comment 11 Neil Hauge CLA 2012-03-05 17:47:51 EST
Review:

In general, things look pretty good. Testing has only turned up a couple of issues which are covered below.

JpaXmlStructureNode

-Class header should be corrected with accurate date and version references

AbstractOrmPersistenceUnitDefaults

-schemaTouches() and catalogTouches() methods need to check for null xmlDefaults to avoid NPE.

DefaultJpaXmlCompletionProposalComputer

-Was thinking this class should either be removed or commented further to indicate that its existence is needed to isolate WTP code that will be removed pending the referenced bug fix.  Most of that is there in the comments, but maybe just add the part about isolating the WTP code so it can be more easily removed.  When it can be removed, we should try to eliminate the subclassing of this "default" implementation.

-If this class stays (which I think is fine for now) it will need a license header

JpaXmlCompletionProposalComputer

computeCompletionProposals()
-In general we don't want swallow RuntimeExceptions except for very special conditions.  The question is whether this situation is similar to the Java completion situation.  I think that this is a bit different given the more synchronous nature of XML editing.  Since there is no delay, it may be less likely to be in a bad state at the time of invoking content assist.  Also, for testing purposes I think it would make sense to at least log errors until we lock down for the release.  Please add:

JptJpaUiPlugin.log(ex);

before returning the empty list

-Also, there should be a comment any time a general rule is broken, such as swallowing a runtime exception.  Please add a comment explaining why we are doing what we are doing in regard to exception handling in computeCompletionProposals().
Comment 12 Nan Li CLA 2012-03-06 15:44:16 EST
Created attachment 212164 [details]
proposed patch

incorporated Neil's comments
Comment 13 Neil Hauge CLA 2012-03-06 23:49:21 EST
Changes committed to head for M6.