| Summary: | [feature] Validation and content assist for Named Queries in Java source | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [WebTools] Dali JPA Tools | Reporter: | Neil Hauge <neil.hauge> | ||||||||||||||||||||||||||||
| Component: | General | Assignee: | Pascal Filion <pascal.filion> | ||||||||||||||||||||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||||||||||||||||||||
| Severity: | enhancement | ||||||||||||||||||||||||||||||
| Priority: | P3 | CC: | naci.dai, tranle1 | ||||||||||||||||||||||||||||
| Version: | 3.0 | Keywords: | plan | ||||||||||||||||||||||||||||
| Target Milestone: | 3.0 M7 | Flags: | neil.hauge:
pmc_approved?
(david_williams) neil.hauge: pmc_approved? (raghunathan.srinivasan) naci.dai: pmc_approved+ neil.hauge: pmc_approved? (deboer) neil.hauge: pmc_approved? (neil.hauge) neil.hauge: pmc_approved? (kaloyan) |
||||||||||||||||||||||||||||
| Hardware: | PC | ||||||||||||||||||||||||||||||
| OS: | Windows 7 | ||||||||||||||||||||||||||||||
| Whiteboard: | |||||||||||||||||||||||||||||||
| Attachments: |
|
||||||||||||||||||||||||||||||
|
Description
Neil Hauge
Created attachment 189609 [details]
JPQL Content assist support
This patch contains
- Hermes parser SPI implementation
- Content assist extension point to add content assist support to the query element of the @NamedQuery annotation
- Validation support for JPQL queries
Created attachment 189610 [details]
The 3 icons needed for JPQL content assist
The icons will go under
org.eclipse.jpt.jpa.ui/icons/full/obj16
Created attachment 189632 [details]
Updated code
The code was updated to move 2 methods with the exact code into a common place and opened up the API since the unit-tests are in a different package.
Created attachment 189633 [details]
Unit-Tests
This patch includes the unit-tests.
The underlying dependencies in EclipseLink that are required for this functionality are currently undergoing some necessary restructuring for the Indigo release. In addition, all of our recent build cycles have been spent integrating the JPA Diagram Editor and associated tests. As a result we were not able to add this code to Dali for M6. The new plan will be to introduce this functionality early in M7 as an exception. Created attachment 190326 [details] JPQL content assist support Latest update on the JPQL content assist, which was updated to use the new package structure used by Hermes parser, see bug 338138. Created attachment 190327 [details] Hermes parser integration tests Same comment as attachment 190326 [details]. Created attachment 191181 [details]
Full JPQL query support
This patch contains the full support for JPQL queries:
- Content assist support in orm.xml xml tags, in the Java source (@NamedQuery) and in the query editor of the JPA details view.
- Validation of JPQL queries in ORM, Java source and in the Query editor.
- Syntax highlighting in orm.xml, Java source and in the Query editor.
Created attachment 191182 [details]
Updated tests
Updated unit-tests as well.
Created attachment 191457 [details]
Latest changes
This patch contains:
- Clean up and refactoring of the computers
- Use SourceViewer for the query editor to add content assist support
- Added context menu to the editor
Feature exception for M7. Created attachment 191822 [details] Latest code This patch requires the patch for bug 340854 because some classes were renamed. Also, it contains a minor fix to the undo action. It will not delete the entire query after the pane is connected to the model. Created attachment 192304 [details] Latest code This patch includes the latest code and also depends on the latest Hermes API, see bug 341523. The Hermes validation and content assist got optimized and the public API changed as a result. Created attachment 192454 [details] JPQL content assist support This patch still depends on the latest Hermes API, see bug 341523. The changes made to this patch compared to the previous are: Problems: It seems when applying a content assist proposal, StyledText widget does not trigger a ModifyListener event because the change is applied to a IDocument and not to the StyledText directly. This results in an out of sync situation between the source (Java or XML document) and the text editor. Solution: Removed the code that binds a StyledText to a WritablePropertyValueModel and do it internally. The entire support for multi-line StyledText was removed since it's not longer used. Also: - Fixed couple issues with orm.xml in regards to \r and \n and positioning the problems. - The code that validates the JPQL query from within the model was moved to JpaJpqlQueryHelper instead of duplicating the code in 4 different places. - Added popup for additional info (it was not added to the query editor). I'm having trouble validating any query with a WHERE clause with the latest patch used against the latest jpql parser code. Not sure if this is an incompatibility between the Dali code and EL code. I get the following exception with the below test query. @NamedQuery(name="foo", query="SELECT o FROM Owner o WHERE o.address = 'foo'") at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1116) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:801) at org.eclipse.jpt.jpa.core.internal.jpql.JpaType.buildCompilationUnit(JpaType.java:156) at org.eclipse.jpt.jpa.core.internal.jpql.JpaType.compilationUnit(JpaType.java:261) at org.eclipse.jpt.jpa.core.internal.jpql.JpaType.buildTypeBinding(JpaType.java:199) at org.eclipse.jpt.jpa.core.internal.jpql.JpaType.getTypeBinding(JpaType.java:338) at org.eclipse.jpt.jpa.core.internal.jpql.JpaType.isAssignableTo(JpaType.java:397) at org.eclipse.persistence.jpa.jpql.TypeHelper.isEnumType(TypeHelper.java:284) at org.eclipse.persistence.jpa.internal.jpql.SemanticValidator$EnumTypeValidator.isRightType(SemanticValidator.java:2274) at org.eclipse.persistence.jpa.internal.jpql.SemanticValidator$AbstractTypeValidator.visit(SemanticValidator.java:2046) at org.eclipse.persistence.jpa.internal.jpql.parser.StateFieldPathExpression.accept(StateFieldPathExpression.java:62) at org.eclipse.persistence.jpa.internal.jpql.SemanticValidator.isEnumType(SemanticValidator.java:228) at org.eclipse.persistence.jpa.internal.jpql.SemanticValidator.access$1300(SemanticValidator.java:147) at org.eclipse.persistence.jpa.internal.jpql.SemanticValidator$ReferencedIdentificationVariableVisitor.visitAbstractPathExpression(SemanticValidator.java:2594) at org.eclipse.persistence.jpa.internal.jpql.SemanticValidator$ReferencedIdentificationVariableVisitor.visit(SemanticValidator.java:2585) at org.eclipse.persistence.jpa.internal.jpql.parser.StateFieldPathExpression.accept(StateFieldPathExpression.java:62) at org.eclipse.persistence.jpa.internal.jpql.parser.CompoundExpression.acceptChildren(CompoundExpression.java:60) at org.eclipse.persistence.jpa.internal.jpql.parser.AbstractTraverseChildrenVisitor.visit(AbstractTraverseChildrenVisitor.java:32) at org.eclipse.persistence.jpa.internal.jpql.parser.AnonymousExpressionVisitor.visit(AnonymousExpressionVisitor.java:142) at org.eclipse.persistence.jpa.internal.jpql.parser.ComparisonExpression.accept(ComparisonExpression.java:73) at org.eclipse.persistence.jpa.internal.jpql.parser.AbstractConditionalClause.acceptChildren(AbstractConditionalClause.java:64) at org.eclipse.persistence.jpa.internal.jpql.parser.AbstractTraverseChildrenVisitor.visit(AbstractTraverseChildrenVisitor.java:32) at org.eclipse.persistence.jpa.internal.jpql.parser.AnonymousExpressionVisitor.visit(AnonymousExpressionVisitor.java:626) at org.eclipse.persistence.jpa.internal.jpql.parser.WhereClause.accept(WhereClause.java:42) at org.eclipse.persistence.jpa.internal.jpql.parser.AbstractSelectStatement.acceptChildren(AbstractSelectStatement.java:92) at org.eclipse.persistence.jpa.internal.jpql.parser.SelectStatement.acceptChildren(SelectStatement.java:65) at org.eclipse.persistence.jpa.internal.jpql.parser.AbstractTraverseChildrenVisitor.visit(AbstractTraverseChildrenVisitor.java:32) at org.eclipse.persistence.jpa.internal.jpql.parser.AnonymousExpressionVisitor.visit(AnonymousExpressionVisitor.java:472) at org.eclipse.persistence.jpa.internal.jpql.parser.SelectStatement.accept(SelectStatement.java:57) at org.eclipse.persistence.jpa.internal.jpql.parser.JPQLExpression.acceptChildren(JPQLExpression.java:154) at org.eclipse.persistence.jpa.internal.jpql.parser.AbstractTraverseChildrenVisitor.visit(AbstractTraverseChildrenVisitor.java:32) at org.eclipse.persistence.jpa.internal.jpql.parser.AnonymousExpressionVisitor.visit(AnonymousExpressionVisitor.java:311) at org.eclipse.persistence.jpa.internal.jpql.parser.JPQLExpression.accept(JPQLExpression.java:147) at org.eclipse.persistence.jpa.internal.jpql.SemanticValidator.visitIdentificationVariable(SemanticValidator.java:1921) at org.eclipse.persistence.jpa.internal.jpql.SemanticValidator.visit(SemanticValidator.java:1227) at org.eclipse.persistence.jpa.internal.jpql.parser.JPQLExpression.accept(JPQLExpression.java:147) at org.eclipse.persistence.jpa.internal.jpql.AbstractJPQLQueryHelper.validateSemantic(AbstractJPQLQueryHelper.java:390) at org.eclipse.persistence.jpa.internal.jpql.AbstractJPQLQueryHelper.validate(AbstractJPQLQueryHelper.java:334) at org.eclipse.persistence.jpa.internal.jpql.AbstractJPQLQueryHelper.validate(AbstractJPQLQueryHelper.java:321) at org.eclipse.persistence.jpa.jpql.JPQLQueryHelper.validate(JPQLQueryHelper.java:146) at org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper.validate(JpaJpqlQueryHelper.java:230) at org.eclipse.jpt.jpa.core.internal.jpa2.context.java.GenericJavaNamedQuery2_0.validate(GenericJavaNamedQuery2_0.java:106) at org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaQueryContainer.validateQueries(GenericJavaQueryContainer.java:358) at org.eclipse.jpt.jpa.core.internal.jpa1.context.java.GenericJavaQueryContainer.validate(GenericJavaQueryContainer.java:311) at org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaEntity.validate(AbstractJavaEntity.java:1327) at org.eclipse.jpt.jpa.eclipselink.core.internal.context.java.JavaEclipseLinkEntityImpl.validate(JavaEclipseLinkEntityImpl.java:175) at org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaPersistentType.validateMapping(AbstractJavaPersistentType.java:649) at org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaPersistentType.validate(AbstractJavaPersistentType.java:643) at org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaPersistentType.validate(AbstractJavaPersistentType.java:636) at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericClassRef.validateJavaPersistentType(GenericClassRef.java:369) at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericClassRef.validate(GenericClassRef.java:363) at org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit.validateClassRefs(AbstractPersistenceUnit.java:1662) at org.eclipse.jpt.jpa.core.internal.context.persistence.AbstractPersistenceUnit.validate(AbstractPersistenceUnit.java:1607) at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistence.validatePersistenceUnit(GenericPersistence.java:299) at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistence.validate(GenericPersistence.java:251) at org.eclipse.jpt.jpa.core.internal.jpa1.context.persistence.GenericPersistenceXml.validate(GenericPersistenceXml.java:244) at org.eclipse.jpt.jpa.core.internal.jpa1.context.GenericRootContextNode.validate(GenericRootContextNode.java:213) at org.eclipse.jpt.jpa.core.internal.AbstractJpaProject.validate(AbstractJpaProject.java:1408) at org.eclipse.jpt.jpa.core.internal.AbstractJpaProject.getValidationMessages(AbstractJpaProject.java:1398) at org.eclipse.jpt.jpa.core.internal.validation.JpaValidator.getValidationMessages(JpaValidator.java:102) at org.eclipse.jpt.jpa.core.internal.validation.JpaValidator.validate(JpaValidator.java:87) at org.eclipse.jpt.jpa.core.internal.validation.JpaValidator.validate(JpaValidator.java:64) Created attachment 193077 [details]
JPQL content assist support
The exception seen is due to the missing source attachment on rt.jar. The updated patch support all 3 cases (Java source files, Java Compiled classes with and without source attachment).
A new IDE preference was also added: "Match Case of First Character", which override the default behavior if a character precede the cursor when invoking the content assist, the case is determined by that character.
Patch tested, reviewed and committed! Thanks Pascal! This is a fantastic feature add for the Dali project. |