Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 189632 Details for
Bug 337930
[feature] Validation and content assist for Named Queries in Java source
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Updated code
jpql.dali.patch.2011.02.23b (text/plain), 135.13 KB, created by
Pascal Filion
on 2011-02-23 15:04:08 EST
(
hide
)
Description:
Updated code
Filename:
MIME Type:
Creator:
Pascal Filion
Created:
2011-02-23 15:04:08 EST
Size:
135.13 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jpt.jpa.core >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/META-INF/MANIFEST.MF,v >retrieving revision 1.2 >diff -u -r1.2 MANIFEST.MF >--- META-INF/MANIFEST.MF 7 Feb 2011 16:41:27 -0000 1.2 >+++ META-INF/MANIFEST.MF 23 Feb 2011 20:00:32 -0000 >@@ -25,6 +25,7 @@ > org.eclipse.jst.common.project.facet.core;bundle-version="[1.3.100,2.0.0)", > org.eclipse.jst.j2ee;bundle-version="[1.1.200,2.0.0)", > org.eclipse.jst.j2ee.core;bundle-version="[1.1.200,2.0.0)", >+ org.eclipse.persistence.utils.jpa.query;bundle-version="1.0.0", > org.eclipse.wst.common.emf;bundle-version="[1.1.200,2.0.0)", > org.eclipse.wst.common.emfworkbench.integration;bundle-version="[1.1.200,2.0.0)", > org.eclipse.wst.common.frameworks;bundle-version="[1.1.200,2.0.0)", >@@ -62,6 +63,7 @@ > org.eclipse.jpt.jpa.core.internal.jpa2.resource.java;x-internal:=true, > org.eclipse.jpt.jpa.core.internal.jpa2.resource.java.binary;x-internal:=true, > org.eclipse.jpt.jpa.core.internal.jpa2.resource.java.source;x-internal:=true, >+ org.eclipse.jpt.jpa.core.internal.jpql;x-friends:="org.eclipse.jpt.jpa.ui", > org.eclipse.jpt.jpa.core.internal.libprov;x-internal:=true, > org.eclipse.jpt.jpa.core.internal.libval;x-internal:=true, > org.eclipse.jpt.jpa.core.internal.operations;x-internal:=true, >Index: property_files/jpa_jpql_validation.properties >=================================================================== >RCS file: property_files/jpa_jpql_validation.properties >diff -N property_files/jpa_jpql_validation.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ property_files/jpa_jpql_validation.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,481 @@ >+################################################################################ >+# Copyright (c) 2011 Oracle. All rights reserved. >+# This program and the accompanying materials are made available under the >+# terms of the Eclipse Public License v1.0, which accompanies this distribution >+# and is available at http://www.eclipse.org/legal/epl-v10.html. >+# >+# Contributors: >+# Oracle - initial API and implementation >+################################################################################ >+ >+// AbsExpression - Grammar >+ABS_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+ABS_EXPRESSION_MISSING_EXPRESSION = The encapsulated expression must be provided for an ABS expression. >+ABS_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the ABS expression. >+ABS_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the ABS expression. >+// AbsExpression - Semantic >+ABS_EXPRESSION_INVALID_NUMERIC_EXPRESSION = The encapsulated expression is not a valid numeric expression. >+ >+// AbstractFromClause - Grammar >+ABSTRACT_FROM_CLAUSE_IDENTIFICATION_VARIABLE_DECLARATION_ENDS_WITH_COMMA = The FROM clause cannot end with a comma. >+ABSTRACT_FROM_CLAUSE_IDENTIFICATION_VARIABLE_DECLARATION_IS_MISSING_COMMA = The FROM clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+ABSTRACT_FROM_CLAUSE_MISSING_IDENTIFICATION_VARIABLE_DECLARATION = The FROM clause must defined at least one identification variable declaration. >+ABSTRACT_FROM_CLAUSE_WRONG_ORDER_OF_IDENTIFICATION_VARIABLE_DECLARATION = The identification variable ''{0}'' is declared after its usage. Identification variables are evaluated from left to right. >+ >+// AbstractPathExpression - Grammar >+ABSTRACT_PATH_EXPRESSION_CANNOT_END_WITH_COMMA = A path expression cannot end with a comma. >+ABSTRACT_PATH_EXPRESSION_MISSING_IDENTIFICATION_VARIABLE = A path expression must start with an identification variable. >+ >+// AbstractSchemaName - Grammar >+ABSTRACT_SCHEMA_NAME_INVALID = The abstract schema type ''{0}'' is unknown. >+ABSTRACT_SCHEMA_NAME_NOT_RESOLVABLE = ''{0}'' cannot be resolved to a type. >+// AbstractSchemaName - Semantic >+PATH_EXPRESSION_NOT_RELATIONSHIP_MAPPING = The derived path ''{0}'' does not represent an association field. >+ >+// AbstractSelectClause - Grammar >+ABSTRACT_SELECT_CLAUSE_SELECT_EXPRESSION_ENDS_WITH_COMMA = The select expression cannot end with a comma. >+ABSTRACT_SELECT_CLAUSE_SELECT_EXPRESSION_IS_MISSING_COMMA = The SELECT clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+ABSTRACT_SELECT_CLAUSE_SELECT_EXPRESSION_MALFORMED = The select expression is malformed. >+ABSTRACT_SELECT_CLAUSE_SELECT_MISSING_EXPRESSION = The select expression is missing from the SELECT clause. >+ >+// AbstractSelectStatement - Grammar >+ABSTRACT_SELECT_STATEMENT_FROM_CLAUSE_MSSING = A select statement must have a FROM clause. >+ >+// AdditionExpression - Semantic >+ADDITION_EXPRESSION_LEFT_EXPRESSION_WRONG_TYPE = The left side of the addition is not a valid arithmetic expression. >+ADDITION_EXPRESSION_RIGHT_EXPRESSION_WRONG_TYPE = The right side of the addition is not a valid arithmetic expression. >+ >+// AllOrAnyExpression - Grammar >+ALL_OR_ANY_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+ALL_OR_ANY_EXPRESSION_MISSING_EXPRESSION = The subquery must be provided for an {0} expression. >+ALL_OR_ANY_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the {0} expression. >+ALL_OR_ANY_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the {0} expression. >+ALL_OR_ANY_EXPRESSION_NOT_PART_OF_COMPARISON_EXPRESSION = The {0} expression must be part of a comparison expression. >+ >+// ArithmeticFactor - Grammar >+ARITHMETIC_FACTOR_MISSING_EXPRESSION = An arithmetic factor must be followed by an expression. >+// ArithmeticFactor - Semantic >+ARITHMETIC_FACTOR_INVALID_EXPRESSION = The expression must be an arithmetic expression. >+ >+// ArithmeticExpression - Grammar >+ARITHMETIC_EXPRESSION_INVALID_LEFT_EXPRESSION = The left expression is not an arithmetic expression. >+ARITHMETIC_EXPRESSION_INVALID_RIGHT_EXPRESSION = The right expression is not an arithmetic expression. >+ARITHMETIC_EXPRESSION_MISSING_LEFT_EXPRESSION = The left expression is missing from the arithmetic expression. >+ARITHMETIC_EXPRESSION_MISSING_RIGHT_EXPRESSION = The right expression is missing from the arithmetic expression. >+ >+// AvgFunction - Grammar >+AVG_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+AVG_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the AVG expression. >+AVG_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for an AVG expression. >+AVG_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the AVG expression. >+// AvgFunction - Semantic >+AVG_FUNCTION_INVALID_NUMERIC_EXPRESSION = The encapsulated expression is not a valid numeric expression. >+ >+// BetweenExpression - Grammar >+BETWEEN_EXPRESSION_MISSING_EXPRESSION = The result expression is missing from the BETWEEN expression. >+BETWEEN_EXPRESSION_MISSING_LOWER_BOUND_EXPRESSION = The lower bound expression is missing from the BETWEEN expression. >+BETWEEN_EXPRESSION_MISSING_AND = The identifier AND is missing from the BETWEEN expression. >+BETWEEN_EXPRESSION_MISSING_UPPER_BOUND_EXPRESSION = The upper bound expression is missing from the BETWEEN expression. >+// BetweenExpression - Semantic >+BETWEEN_EXPRESSION_WRONG_TYPE = The expression's type and the lower and upper bound expressions' type have to be the same type. >+ >+// CaseExpression - Grammar >+CASE_EXPRESSION_MISSING_ELSE_EXPRESSION = A CASE expression must have an ELSE expression. >+CASE_EXPRESSION_MISSING_ELSE_IDENTIFIER = The identifier ELSE is missing from the CASE expression. >+CASE_EXPRESSION_MISSING_END_IDENTIFIER = The identifier END is missing from the CASE expression. >+CASE_EXPRESSION_MISSING_WHEN_CLAUSE = A CASE expression must define at least one WHEN clause. >+CASE_EXPRESSION_WHEN_CLAUSES_END_WITH_COMMA = The WHEN clauses cannot end with a comma. >+CASE_EXPRESSION_WHEN_CLAUSES_HAS_COMMA = Two WHEN clauses cannot be separated by a comma. >+ >+// CoalesceExpression - Grammar >+COALESCE_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+COALESCE_EXPRESSION_MISSING_EXPRESSION = The encapsulated expressions must be provided for a COALESCE expression. >+COALESCE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the COALESCE expression. >+COALESCE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the COALESCE expression. >+ >+// CollectionMemberExpression - Grammar >+COLLECTION_MEMBER_EXPRESSION_MISSING_ENTITY_EXPRESSION = A collection member expression must define an entity expression. >+COLLECTION_MEMBER_EXPRESSION_MISSING_COLLECTION_VALUED_PATH_EXPRESSION = A collection member expression must define a collection valued path expression. >+// CollectionMemberExpression - Semantic >+COLLECTION_MEMBER_EXPRESSION_EMBEDDABLE = An embeddable type is not supported. >+ >+// CollectionMemberDeclaration - Grammar >+COLLECTION_MEMBER_DECLARATION_MISSING_COLLECTION_VALUED_PATH_EXPRESSION = The collection-valued path expression is missing from the collection member declaration. >+COLLECTION_MEMBER_DECLARATION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the collection member declaration. >+COLLECTION_MEMBER_DECLARATION_MISSING_IDENTIFICATION_VARIABLE = An identification variable must be specified for a collection member declaration. >+COLLECTION_MEMBER_DECLARATION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the collection member declaration. >+ >+// CollectionValuedPathExpression - Semantic >+COLLECTION_VALUED_PATH_EXPRESSION_NOT_RESOLVABLE" , "The collection-valued path ''{0}'' cannot be resolved to a valid association field. >+COLLECTION_VALUED_PATH_EXPRESSION_NOT_COLLECTION_TYPE = The collection-valued path ''{0}'' must resolve to an association field. >+ >+// ComparisonExpression - Grammar >+COMPARISON_EXPRESSION_MISSING_LEFT_EXPRESSION = A comparison expression must define the left side of the comparison. >+COMPARISON_EXPRESSION_MISSING_RIGHT_EXPRESSION = A comparison expression must define the right side of the comparison. >+// ComparisonExpression - Semantic >+COMPARISON_EXPRESSION_WRONG_COMPARISON_TYPE = The left and right expressions' type must be of the same type. >+ >+// ConcatExpression - Grammar >+CONCAT_EXPRESSION_INVALID_EXPRESSION = The expression ''{0}'' is not valid expression. >+CONCAT_EXPRESSION_MISSING_EXPRESSION = The encapsulated expression is missing from the CONCAT expression. >+CONCAT_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the CONCAT expression. >+CONCAT_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the CONCAT expression. >+// ConcatExpression - Semantic >+CONCAT_EXPRESSION_EXPRESSION_WRONG_TYPE = The expression ''{0}'' is not a String. >+ >+// ConstructorExpression - Grammar >+CONSTRUCTOR_EXPRESSION_CONSTRUCTOR_ITEM_ENDS_WITH_COMMA = The constructor items cannot end with a comma. >+CONSTRUCTOR_EXPRESSION_CONSTRUCTOR_ITEM_IS_MISSING_COMMA = The constructor expression has two constructor items (''{0}'' and ''{1}'') that are not separated by a comma. >+CONSTRUCTOR_EXPRESSION_MISSING_CONSTRUCTOR_ITEM = A constructor expression must define at least one constructor item. >+CONSTRUCTOR_EXPRESSION_MISSING_CONSTRUCTOR_NAME = The fully qualified class name must be specified. >+CONSTRUCTOR_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the constructor expression. >+CONSTRUCTOR_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the constructor expression. >+// ConstructorExpression - Semantic >+CONSTRUCTOR_EXPRESSION_MISMATCHED_PARAMETER_TYPES = No constructors can be found that match the argument types. >+CONSTRUCTOR_EXPRESSION_UNKNOWN_TYPE = ''{0}'' cannot be resolved to a type. >+ >+// CountFunction - Grammar >+COUNT_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+COUNT_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for a COUNT expression. >+COUNT_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the COUNT expression. >+COUNT_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the COUNT expression. >+// CountFunction - Semantic >+COUNT_FUNCTION_DISTINCT_EMBEDDABLE = The use of DISTINCT is not supported for arguments of embeddable types. >+ >+// DateTime - Grammar >+DATE_TIME_JDBC_ESCAPE_FORMAT_INVALID_SPECIFICATION = The JDBC escape format does not start with either 'd', 't' or 'ts'. >+DATE_TIME_JDBC_ESCAPE_FORMAT_MISSING_CLOSE_QUOTE = The JDBC escape format is missing the close quote. >+DATE_TIME_JDBC_ESCAPE_FORMAT_MISSING_OPEN_QUOTE = The JDBC escape format is missing the open quote. >+DATE_TIME_JDBC_ESCAPE_FORMAT_MISSING_RIGHT_CURLY_BRACE = The JDBC escape format is missing the right curly brace. >+ >+// DeleteClause - Grammar >+DELETE_CLAUSE_FROM_MISSING = The identifier FROM is missing from the DELETE FROM clause. >+DELETE_CLAUSE_MULTIPLE_RANGE_VARIABLE_DECLARATION = Only one entity abstract schema type can be defined. >+DELETE_CLAUSE_RANGE_VARIABLE_DECLARATION_MALFORMED = The entity abstract schema type declaration is malformed. >+DELETE_CLAUSE_RANGE_VARIABLE_DECLARATION_MISSING = A DELETE clause must define an entity abstract schema type. >+ >+// DivisionExpression - Semantic >+DIVISION_EXPRESSION_LEFT_EXPRESSION_WRONG_TYPE = The left side of the division is not a valid arithmetic expression. >+DIVISION_EXPRESSION_RIGHT_EXPRESSION_WRONG_TYPE = The right side of the division is not a valid arithmetic expression. >+ >+// EclipseLinkQueryBuilder - Validation >+ECLIPSE_LINK_QUERY_BUILDER_GRAMMAR_VALIDATOR_ERROR_MESSAGE = Syntax error parsing the query [{0}]. {1} >+ECLIPSE_LINK_QUERY_BUILDER_SEMANTIC_VALIDATOR_ERROR_MESSAGE = Problem compiling the query [{0}]. {1} >+ >+// EncapsulatedIdentificationVariableExpression - Semantic >+ENCAPSULATED_IDENTIFICATION_VARIABLE_EXPRESSION_NOT_MAP_VALUED = The {0} operator may only be applied to identification variables that correspond to map-valued associations or map-valued element collections. >+ >+// EmptyCollectionComparisonExpression - Grammar >+EMPTY_COLLECTION_COMPARISON_EXPRESSION_MISSING_EXPRESSION = The collection valued path expression must be defined. >+ >+// EntityTypeLiteral - Semantic >+ENTITY_TYPE_LITERAL_NOT_RESOLVABLE = ''{0}'' cannot be resolved to a type. >+ >+// EntryExpression - Grammar >+ENTRY_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+ENTRY_EXPRESSION_MISSING_EXPRESSION = An identification variable must be provided for an ENTRY expression. >+ENTRY_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the ENTRY expression. >+ENTRY_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the ENTRY expression. >+ >+// ExistsExpression - Grammar >+EXISTS_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+EXISTS_EXPRESSION_MISSING_EXPRESSION = A subquery must be provided for an EXISTS expression. >+EXISTS_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the EXISTS expression. >+EXISTS_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the EXISTS expression. >+ >+// FuncExpression - Grammar >+FUNC_EXPRESSION_MISSING_FUNCTION_NAME = The SQL function name must be specified. >+FUNC_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the FUNC expression. >+FUNC_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the FUNC expression. >+ >+// GroupByClause - Grammar >+GROUP_BY_CLAUSE_GROUP_BY_ITEM_ENDS_WITH_COMMA = The select expression cannot end with a comma. >+GROUP_BY_CLAUSE_GROUP_BY_ITEM_IS_MISSING_COMMA = The GROUP BY clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+GROUP_BY_CLAUSE_GROUP_BY_ITEM_MISSING = The grouping item is missing from the GROUP BY clause. >+ >+// HavingClause - Grammar >+HAVING_CLAUSE_INVALID_CONDITIONAL_EXPRESSION = The expression is not a valid conditional expression. >+HAVING_CLAUSE_MISSING_CONDITIONAL_EXPRESSION = The conditional expression is missing from the HAVING clause. >+ >+// IdentificationVariable - Grammar >+IDENTIFICATION_VARIABLE_INVALID_DUPLICATE = The identification variable ''{0}'' cannot be declared more than once. >+IDENTIFICATION_VARIABLE_INVALID_JAVA_IDENTIFIER = The identification variable ''{0}'' is not following the rules for a Java identifier. >+IDENTIFICATION_VARIABLE_INVALID_RESERVED_WORD = The identification variable ''{0}'' cannot be a reserved word. >+// IdentificationVariable - Semantic >+IDENTIFICATION_VARIABLE_ENTITY_NAME = An identification variable must not have the same name as any entity in the same persistence unit. >+IDENTIFICATION_VARIABLE_INVALID_NOT_DECLARED = The identification variable ''{0}'' is not defined in the FROM clause. >+ >+// IdentificationVariableDeclaration - Grammar >+IDENTIFICATION_VARIABLE_DECLARATION_MISSING_RANGE_VARIABLE_DECLARATION = The range variable declaration must be specified. >+ >+// IndexExpression - Grammar >+INDEX_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+INDEX_EXPRESSION_MISSING_EXPRESSION = An identification variable must be provided for an INDEX expression. >+INDEX_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the INDEX expression. >+INDEX_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the INDEX expression. >+// IndexExpression - Semantic >+INDEX_EXPRESSION_WRONG_VARIABLE = The identification variable ''{0}'' does not represent an association or element collection. >+ >+// InExpression - Grammar >+IN_EXPRESSION_IN_ITEM_ENDS_WITH_COMMA = The items cannot end with a comma. >+IN_EXPRESSION_IN_ITEM_IS_MISSING_COMMA = The IN expression has ''{0}'' and ''{1}'' that are not separated by a comma. >+IN_EXPRESSION_MALFORMED_EXPRESSION = The IN expression does not have a valid state field path expression or TYPE expession. >+IN_EXPRESSION_MISSING_IN_ITEMS = A least one item must be defined for the IN expression. >+IN_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the IN expression. >+IN_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the IN expression. >+IN_EXPRESSION_MISSING_EXPRESSION = A state field path expression or TYPE expression must be defined. >+ >+// InputParameter - Grammar >+INPUT_PARAMETER_JAVA_IDENTIFIER = The named input parameter ''{0}'' is not following the rules for a Java identifier. >+INPUT_PARAMETER_MISSING_PARAMETER = The parameter value is missing from the input parameter. >+INPUT_PARAMETER_MIXTURE = Named and positional input parameters must not be mixed in a single query. >+INPUT_PARAMETER_NOT_INTEGER = The positional input parameter ''{0}'' cannot use non-Integer characters. >+INPUT_PARAMETER_SMALLER_THAN_ONE = The number used for the positional input parameter ''{0}'' must be greater than 0. >+INPUT_PARAMETER_WRONG_CLAUSE_DECLARATION = Input parameters can only be used in the WHERE clause or HAVING clause of a query. >+ >+// Join - Grammar >+JOIN_MISSING_IDENTIFICATION_VARIABLE = An identification variable must be defined for a JOIN expression. >+JOIN_MISSING_JOIN_ASSOCIATION_PATH = The join association path is missing from the JOIN expression. >+ >+// JoinFetch - Grammar >+JOIN_FETCH_MISSING_JOIN_ASSOCIATION_PATH = The join association path is missing from the JOIN FETCH expression. >+JOIN_FETCH_WRONG_CLAUSE_DECLARATION = JOIN FETCH expressions cannot be used in a FROM clause of a subquery. >+ >+// JPQLExpression - Grammar >+JPQL_EXPRESSION_INVALID_QUERY = The query does not start with a valid identifier, has to be either SELECT, UPDATE or DELETE FROM. >+JPQL_EXPRESSION_UNKNOWN_ENDING = The query contains a malformed ending. >+ >+// KeyExpression - Grammar >+KEY_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+KEY_EXPRESSION_MISSING_EXPRESSION = The identification variable must be provided for an ABS expression. >+KEY_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the ABS expression. >+KEY_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the ABS expression. >+ >+// LengthExpression - Grammar >+LENGTH_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+LENGTH_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a LENGTH expression. >+LENGTH_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the LENGTH expression. >+LENGTH_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the LENGTH expression. >+// LikeExpression - Semantic >+LENGTH_EXPRESSION_WRONG_TYPE = The encapsulated expression is not of string type. >+ >+// LikeExpression - Grammar >+LIKE_EXPRESSION_INVALID_ESCAPE_CHARACTER = {0} is not a valid escape character. >+LIKE_EXPRESSION_MISSING_ESCAPE_CHARACTER = The escape character is missing from the LIKE expression. >+LIKE_EXPRESSION_MISSING_PATTERN_VALUE = The pattern value is missing from the LIKE expression. >+LIKE_EXPRESSION_MISSING_STRING_EXPRESSION = The string expression is missing from the LIKE expression. >+ >+// LocateExpression - Grammar >+LOCATE_EXPRESSION_INVALID_FIRST_EXPRESSION = The first argument is not a valid expression. >+LOCATE_EXPRESSION_INVALID_SECOND_EXPRESSION = The second argument is not a valid expression. >+LOCATE_EXPRESSION_INVALID_THIRD_EXPRESSION = The third argument is not a valid expression. >+LOCATE_EXPRESSION_MISSING_FIRST_EXPRESSION = The first argument is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_FIRST_COMMA = The first comma is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_SECOND_COMMA = The second comma is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_SECOND_EXPRESSION = The second argument is missing from the LOCATE expression. >+LOCATE_EXPRESSION_MISSING_THIRD_EXPRESSION = The third argument is missing from the LOCATE expression. >+// LocateExpression - Semantic >+LOCATE_EXPRESSION_FIRST_EXPRESSION_WRONG_TYPE = The first expression is not of string type. >+LOCATE_EXPRESSION_SECOND_EXPRESSION_WRONG_TYPE = The second expression is not of string type. >+LOCATE_EXPRESSION_THIRD_EXPRESSION_WRONG_TYPE = The third encapsulated expression is not of numeric type. >+ >+// LogicalExpression - Grammar >+LOGICAL_EXPRESSION_INVALID_LEFT_EXPRESSION = The left expression is missing from the logical expression. >+LOGICAL_EXPRESSION_INVALID_RIGHT_EXPRESSION = The right expression is missing from the logical expression. >+LOGICAL_EXPRESSION_MISSING_LEFT_EXPRESSION = The left expression is not a valid expression. >+LOGICAL_EXPRESSION_MISSING_RIGHT_EXPRESSION = The right expression is not a valid expression. >+ >+// LowerExpression - Grammar >+LOWER_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+LOWER_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a LOWER expression. >+LOWER_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the LOWER expression. >+LOWER_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the LOWER expression. >+// UpperExpression - Semantic >+LOWER_EXPRESSION_WRONG_TYPE = The expression is not a String. >+ >+// MaxFunction - Grammar >+MAX_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+MAX_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for a MAX expression. >+MAX_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the MAX expression. >+MAX_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the MAX expression. >+ >+// MinFunction - Grammar >+MIN_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+MIN_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for a MIN expression. >+MIN_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the MIN expression. >+MIN_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the MIN expression. >+ >+// ModExpression - Grammar >+MOD_EXPRESSION_INVALID_FIRST_EXPRESSION = The first argument is not a valid expression. >+MOD_EXPRESSION_INVALID_SECOND_PARENTHESIS = The second argument is not a valid expression. >+MOD_EXPRESSION_MISSING_COMMA = The comma is missing from the MOD expression. >+MOD_EXPRESSION_MISSING_FIRST_EXPRESSION = The first argument is missing from the MOD expression. >+MOD_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the MOD expression. >+MOD_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the MOD expression. >+MOD_EXPRESSION_MISSING_SECOND_EXPRESSION = The second argument is missing from the MOD expression. >+// ModExpression - Semantic >+MOD_EXPRESSION_FIRST_EXPRESSION_WRONG_TYPE = The first expression is not an Integer. >+MOD_EXPRESSION_SECOND_EXPRESSION_WRONG_TYPE = The second expression is not an Integer. >+ >+// MultiplicationExpression - Semantic >+MULTIPLICATION_EXPRESSION_LEFT_EXPRESSION_WRONG_TYPE = The left side of the multiplication is not a valid arithmetic expression. >+MULTIPLICATION_EXPRESSION_RIGHT_EXPRESSION_WRONG_TYPE = The right side of the multiplication is not a valid arithmetic expression. >+ >+// NotExpression - Grammar >+NOT_EXPRESSION_MISSING_EXPRESSION = The expression is missing after the identifier NOT. >+// NotExpression - Semantic >+NOT_EXPRESSION_WRONG_TYPE = The expression is not of boolean type. >+ >+// NullComparisonExpression - Grammar >+NULL_COMPARISON_EXPRESSION_MISSING_EXPRESSION = The expression is missing from the null comparison expression. >+// NullComparisonExpression - Semantic >+NULL_COMPARISON_EXPRESSION_INVALID_COLLECTION_EXPRESSION = ''{0}'' cannot be resolved to a collection type. >+ >+// NullIfExpression - Grammar >+NULL_IF_EXPRESSION_INVALID_FIRST_EXPRESSION = The first argument is not a valid expression. >+NULL_IF_EXPRESSION_INVALID_SECOND_EXPRESSION = The second argument is not a valid expression. >+NULL_IF_EXPRESSION_MISSING_COMMA = The comma is missing from the NULLIF expression. >+NULL_IF_EXPRESSION_MISSING_FIRST_EXPRESSION = The first argument is missing from the NULLIF expression. >+NULL_IF_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the NULLIF expression. >+NULL_IF_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the NULLIF expression. >+NULL_IF_EXPRESSION_MISSING_SECOND_EXPRESSION = The second argument is missing from the NULLIF expression. >+ >+// NumericLiteral - Grammar >+NUMERIC_LITERAL_INVALID = ''{0}'' is not a valid numeric value. >+ >+// ObjectByItem - Grammar >+ORDER_BY_ITEM_INVALID_PATH = ''{0}'' is not a valid state field path expression. >+ORDER_BY_ITEM_MISSING_STATE_FIELD_PATH_EXPRESSION = A state field path expression must be specified. >+ >+// ObjectExpression - Grammar >+OBJECT_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+OBJECT_EXPRESSION_MISSING_EXPRESSION = An identification variable must be provided for an OBJECT expression. >+OBJECT_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the OBJECT expression. >+OBJECT_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the OBJECT expression. >+ >+// OrderByClause - Grammar >+ORDER_BY_CLAUSE_ORDER_BY_ITEM_ENDS_WITH_COMMA = The select expression cannot end with a comma. >+ORDER_BY_CLAUSE_ORDER_BY_ITEM_IS_MISSING_COMMA = The ORDER BY clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+ORDER_BY_CLAUSE_ORDER_BY_ITEM_MISSING = The ordering item is missing from the ORDER BY clause. >+ >+// RangeVariableDeclaration - Grammar >+RANGE_VARIABLE_DECLARATION_MISSING_ABSTRACT_SCHEMA_NAME = An abstract schema name must be specified. >+RANGE_VARIABLE_DECLARATION_MISSING_IDENTIFICATION_VARIABLE = An identification variable must be provider for a range variable declaration. >+ >+// ResultVariable - Grammar >+RESULT_VARIABLE_MISSING_SELECT_EXPRESSION = The select item is missing from the result variable declaration. >+RESULT_VARIABLE_MISSING_RESULT_VARIABLE = The result variable is missing from the select item declaration. >+ >+// SelectStatement - Semantic >+SELECT_STATEMENT_SELECT_CLAUSE_HAS_NON_AGGREGATE_FUNCTIONS = The select list can only consist of aggregate functions because there is no GROUP BY clause and the HAVING clause is used. >+ >+// SimpleSelectClause - Grammar >+SIMPLE_SELECT_CLAUSE_NOT_SINGLE_EXPRESSION = Only one expression can be declared in a SELECT clause of a subquery. >+ >+// SizeExpression - Grammar >+SIZE_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+SIZE_EXPRESSION_MISSING_EXPRESSION = A collection-valued path expression must be provided for a SIZE expression. >+SIZE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the SIZE expression. >+SIZE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the SIZE expression. >+ >+// SqrtExpression - Grammar >+SQRT_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+SQRT_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a SQRT expression. >+SQRT_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the SQRT expression. >+SQRT_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the SQRT expression. >+// SqrtExpression - Semantic >+SQRT_EXPRESSION_WRONG_TYPE = The expression is not a numeric type. >+ >+// StateFieldPathExpression - Semantic >+STATE_FIELD_PATH_EXPRESSION_ASSOCIATION_FIELD = The association field ''{0}'' cannot be used as a state field path. >+STATE_FIELD_PATH_EXPRESSION_COLLECTION_TYPE = The state field path ''{0}'' cannot resolve to a collection type. >+STATE_FIELD_PATH_EXPRESSION_INVALID_ENUM_CONSTANT = ''{0}'' cannot be resolved to an Enum constant. >+STATE_FIELD_PATH_EXPRESSION_NO_MAPPING = No mapping is associated with the state field path ''{0}''. >+STATE_FIELD_PATH_EXPRESSION_NOT_RESOLVABLE = The state field path ''{0}'' cannot be resolved to a valid type. >+ >+// SubExpression - Grammar >+SUB_EXPRESSION_MISSING_EXPRESSION = The encapsulated expression is missing. >+SUB_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the sub-expression. >+ >+// SubstractionExpression - Semantic >+SUBSTRACTION_EXPRESSION_LEFT_EXPRESSION_WRONG_TYPE = The left side of the substraction is not a valid arithmetic expression. >+SUBSTRACTION_EXPRESSION_RIGHT_EXPRESSION_WRONG_TYPE = The right side of the substraction is not a valid arithmetic expression. >+ >+// SubstringExpression - Grammar >+SUBSTRING_EXPRESSION_INVALID_FIRST_EXPRESSION = The first argument is not a valid expression. >+SUBSTRING_EXPRESSION_INVALID_SECOND_EXPRESSION = The second argument is not a valid expression. >+SUBSTRING_EXPRESSION_INVALID_THIRD_EXPRESSION = The third argument is not a valid expression. >+SUBSTRING_EXPRESSION_MISSING_FIRST_COMMA = The first comma is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_FIRST_EXPRESSION = The first argument is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_SECOND_COMMA = The second comma is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_SECOND_EXPRESSION = The second argument is missing from the SUBSTRING expression. >+SUBSTRING_EXPRESSION_MISSING_THIRD_EXPRESSION = The third argument is missing from the SUBSTRING expression. >+// SubstringExpression - Semantic >+SUBSTRING_EXPRESSION_FIRST_EXPRESSION_WRONG_TYPE = The first argument is not a String value. >+SUBSTRING_EXPRESSION_SECOND_EXPRESSION_WRONG_TYPE = The first argument is not an integer value. >+SUBSTRING_EXPRESSION_THIRD_EXPRESSION_WRONG_TYPE = The first argument is not an integer value. >+ >+// SumFunction - Grammar >+SUM_FUNCTION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+SUM_FUNCTION_MISSING_EXPRESSION = The encapsulated expression must be provided for a SUM expression. >+SUM_FUNCTION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the SUM expression. >+SUM_FUNCTION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the SUM expression. >+// SumFunction - Semantic >+SUM_FUNCTION_WRONG_TYPE = The argument must be numeric. >+ >+// TrimExpression - Grammar >+TRIM_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+TRIM_EXPRESSION_INVALID_TRIM_CHARACTER = The trim character should be a single-character string literal or a character-valued input parameter (i.e., char or Character). >+TRIM_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a TRIM expression. >+TRIM_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the TRIM expression. >+TRIM_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the TRIM expression. >+TRIM_EXPRESSION_NOT_SINGLE_STRING_LITERAL = The trim character should be a single-character string literal. >+ >+// TypeExpression - Grammar >+TYPE_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+TYPE_EXPRESSION_MISSING_EXPRESSION = An identification variable or a path expression must be provided for a TYPE expression. >+TYPE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the TYPE expression. >+TYPE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the TYPE expression. >+// TypeExpression - Semantic >+ >+// UpdateClause - Grammar >+UPDATE_CLAUSE_MISSING_RANGE_VARIABLE_DECLARATION = The range variable declaration is missing from the UPDATE clause. >+UPDATE_CLAUSE_MISSING_SET = The SET identifier is missing from the UPDATE clause. >+UPDATE_CLAUSE_MISSING_UPDATE_ITEMS = At least one update item must be specified for an UPDATE clause. >+UPDATE_CLAUSE_UPDATE_ITEM_ENDS_WITH_COMMA = The update item cannot end with a comma. >+UPDATE_CLAUSE_UPDATE_ITEM_IS_MISSING_COMMA = The UPDATE clause has ''{0}'' and ''{1}'' that are not separated by a comma. >+ >+// UpdateItem - Grammar >+UPDATE_ITEM_MISSING_EQUAL_SIGN = The equal sign must be specified. >+UPDATE_ITEM_MISSING_NEW_VALUE = The new value must be specified. >+UPDATE_ITEM_MISSING_STATE_FIELD_PATH_EXPRESSION = The state field path expression is missing. >+// UpdateItem - Semantic >+UPDATE_ITEM_NOT_ASSIGNABLE = Type mismatch: cannot convert from {0} to {1}. >+UPDATE_ITEM_NOT_RESOLVABLE = The state field cannot be resolved. >+ >+// UpperExpression - Grammar >+UPPER_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+UPPER_EXPRESSION_MISSING_EXPRESSION = An expression must be provided for a UPPER expression. >+UPPER_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the UPPER expression. >+UPPER_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the UPPER expression. >+// UpperExpression - Semantic >+UPPER_EXPRESSION_WRONG_TYPE = The expression is not a String. >+ >+// ValueExpression - Grammar >+VALUE_EXPRESSION_INVALID_EXPRESSION = The encapsulated expression is not a valid expression. >+VALUE_EXPRESSION_MISSING_EXPRESSION = An identification variable must be provided for a VALUE expression. >+VALUE_EXPRESSION_MISSING_LEFT_PARENTHESIS = The left parenthesis is missing from the VALUE expression. >+VALUE_EXPRESSION_MISSING_RIGHT_PARENTHESIS = The right parenthesis is missing from the VALUE expression. >+ >+// WhenClause - Grammar >+WHEN_CLAUSE_MISSING_THEN_EXPRESSION = A conditional expression must be provider for a WHEN clause. >+WHEN_CLAUSE_MISSING_THEN_IDENTIFIER = The identifier THEN is missing from the WHEN clause. >+WHEN_CLAUSE_MISSING_WHEN_EXPRESSION = A WHEN expression must be provided for a WHEN clause. >+ >+// WhereClause - Grammar >+WHERE_CLAUSE_INVALID_CONDITIONAL_EXPRESSION = The expression is not a valid conditional expression. >+WHERE_CLAUSE_MISSING_CONDITIONAL_EXPRESSION = The conditional expression is missing from the WHERE clause. >Index: src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericJavaNamedQuery.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java 6 Feb 2011 02:07:16 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaNamedQuery.java 23 Feb 2011 20:00:35 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2007, 2010 Oracle. All rights reserved. >+ * Copyright (c) 2007, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -9,10 +9,17 @@ > ******************************************************************************/ > package org.eclipse.jpt.jpa.core.internal.jpa1.context.java; > >+import java.util.List; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; > import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery; > import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaQuery; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; > import org.eclipse.jpt.jpa.core.resource.java.NamedQueryAnnotation; >+import org.eclipse.persistence.utils.jpa.query.JPQLQueryProblem; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+import org.eclipse.wst.validation.internal.provisional.core.IReporter; > > /** > * Java named query >@@ -24,4 +31,25 @@ > public GenericJavaNamedQuery(JavaJpaContextNode parent, NamedQueryAnnotation queryAnnotation) { > super(parent, queryAnnotation); > } >-} >+ >+ >+ // ********** validation ********** >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { >+ super.validate(messages, reporter, astRoot); >+ >+ JpaJpqlQueryHelper helper = new JpaJpqlQueryHelper(this); >+ String parsedQuery = helper.getJPQLExpression().toParsedText(); >+ String jpqlQuery = getQuery(); >+ >+ for (JPQLQueryProblem problem : helper.validate()) { >+ TextRange textRange = this.getQueryAnnotation().getQueryTextRange(astRoot); >+ IMessage message = helper.buildProblem(problem, textRange, jpqlQuery, parsedQuery); >+ messages.add(message); >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericJavaQueryContainer.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java 6 Feb 2011 02:07:16 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa1/context/java/GenericJavaQueryContainer.java 23 Feb 2011 20:00:36 -0000 >@@ -308,10 +308,10 @@ > @Override > public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { > super.validate(messages, reporter, astRoot); >- this.validateQueries(messages, astRoot); >+ this.validateQueries(messages, reporter, astRoot); > } > >- protected void validateQueries(List<IMessage> messages, CompilationUnit astRoot) { >+ protected void validateQueries(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { > for (Iterator<JavaQuery> localQueries = this.queries(); localQueries.hasNext(); ) { > JavaQuery localQuery = localQueries.next(); > String name = localQuery.getName(); >@@ -354,6 +354,9 @@ > ) > ); > } >+ else { >+ localQuery.validate(messages, reporter, astRoot); >+ } > } > } > >Index: src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java,v >retrieving revision 1.1 >diff -u -r1.1 GenericJavaNamedQuery2_0.java >--- src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java 6 Feb 2011 02:07:24 -0000 1.1 >+++ src/org/eclipse/jpt/jpa/core/internal/jpa2/context/java/GenericJavaNamedQuery2_0.java 23 Feb 2011 20:00:36 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >-* Copyright (c) 2009, 2010 Oracle. All rights reserved. >+* Copyright (c) 2009, 2011 Oracle. All rights reserved. > * This program and the accompanying materials are made available under the > * terms of the Eclipse Public License v1.0, which accompanies this distribution > * and is available at http://www.eclipse.org/legal/epl-v10.html. >@@ -9,11 +9,18 @@ > *******************************************************************************/ > package org.eclipse.jpt.jpa.core.internal.jpa2.context.java; > >+import java.util.List; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jpt.common.core.utility.TextRange; > import org.eclipse.jpt.jpa.core.context.java.JavaJpaContextNode; > import org.eclipse.jpt.jpa.core.internal.context.java.AbstractJavaQuery; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; > import org.eclipse.jpt.jpa.core.jpa2.context.LockModeType2_0; > import org.eclipse.jpt.jpa.core.jpa2.context.java.JavaNamedQuery2_0; > import org.eclipse.jpt.jpa.core.jpa2.resource.java.NamedQuery2_0Annotation; >+import org.eclipse.persistence.utils.jpa.query.JPQLQueryProblem; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+import org.eclipse.wst.validation.internal.provisional.core.IReporter; > > /** > * JPA 2.0 >@@ -87,4 +94,24 @@ > return LockModeType2_0.NONE; > } > >-} >+ >+ // ********** validation ********** >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public void validate(List<IMessage> messages, IReporter reporter, CompilationUnit astRoot) { >+ super.validate(messages, reporter, astRoot); >+ >+ JpaJpqlQueryHelper helper = new JpaJpqlQueryHelper(this); >+ String parsedQuery = helper.getJPQLExpression().toParsedText(); >+ String jpqlQuery = getQuery(); >+ >+ for (JPQLQueryProblem problem : helper.validate()) { >+ TextRange textRange = this.getQueryAnnotation().getQueryTextRange(astRoot); >+ IMessage message = helper.buildProblem(problem, textRange, jpqlQuery, parsedQuery); >+ messages.add(message); >+ } >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaConstructor.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaConstructor.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaConstructor.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaConstructor.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,102 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jdt.core.dom.IMethodBinding; >+import org.eclipse.jdt.core.dom.ITypeBinding; >+import org.eclipse.jdt.core.dom.MethodDeclaration; >+import org.eclipse.persistence.utils.jpa.query.spi.IConstructor; >+import org.eclipse.persistence.utils.jpa.query.spi.IType; >+import org.eclipse.persistence.utils.jpa.query.spi.ITypeDeclaration; >+ >+/** >+ * The concrete implementation of {@link IConstructor} that is wrapping the design-time >+ * representation of a Java constructor. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaConstructor implements IConstructor { >+ >+ /** >+ * The design-time representation of a Java constructor. >+ */ >+ private final MethodDeclaration method; >+ >+ /** >+ * The cached {@link ITypeDeclaration ITypeDeclarations} representing each of the constructor's >+ * parameter types. >+ */ >+ private ITypeDeclaration[] typeDeclarations; >+ >+ /** >+ * The repository of Java types. >+ */ >+ private final JpaTypeRepository typeRepository; >+ >+ /** >+ * Creates a new <code>JpaConstructor</code>. >+ * >+ * @param typeRepository The repository of Java types >+ * @param method The design-time representation of a Java constructor >+ */ >+ JpaConstructor(JpaTypeRepository typeRepository, MethodDeclaration method) { >+ super(); >+ this.method = method; >+ this.typeRepository = typeRepository; >+ } >+ >+ private ITypeDeclaration buildTypeDeclaration(ITypeBinding parameterType) { >+ >+ boolean array = parameterType.isArray(); >+ String typeName = array ? parameterType.getComponentType().getBinaryName() : parameterType.getBinaryName(); >+ >+ // Retrieve the fully qualified name of the type >+ ITypeBinding[] typeArguments = parameterType.getTypeArguments(); >+ ITypeDeclaration[] genericTypes = new ITypeDeclaration[typeArguments.length]; >+ int index = 0; >+ >+ for (ITypeBinding typeArgument : typeArguments) { >+ String genericTypeName = typeArgument.getErasure().getBinaryName(); >+ IType genericType = typeRepository.getType(genericTypeName); >+ genericTypes[index++] = genericType.getTypeDeclaration(); >+ } >+ >+ return new JpaTypeDeclaration(typeRepository.getType(typeName), genericTypes, array); >+ } >+ >+ private ITypeDeclaration[] buildTypeDeclarations() { >+ >+ IMethodBinding binding = method.resolveBinding(); >+ ITypeBinding[] parameterTypes = binding.getParameterTypes(); >+ ITypeDeclaration[] declarations = new ITypeDeclaration[parameterTypes.length]; >+ >+ for (int index = declarations.length; --index >= 0; ) { >+ declarations[index] = buildTypeDeclaration(parameterTypes[index]); >+ } >+ >+ return declarations; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ITypeDeclaration[] getParameterTypes() { >+ if (typeDeclarations == null) { >+ typeDeclarations = buildTypeDeclarations(); >+ } >+ return typeDeclarations; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEmbeddable.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEmbeddable.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEmbeddable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEmbeddable.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.jpa.core.context.Embeddable; >+import org.eclipse.persistence.utils.jpa.query.spi.IEmbeddable; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedTypeVisitor; >+ >+/** >+ * The concrete implementation of {@link IEmbeddable} that is wrapping the design-time >+ * representation of a JPA embeddable. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaEmbeddable extends JpaManagedType >+ implements IEmbeddable { >+ >+ /** >+ * Creates a new <code>JpaEmbeddable</code>. >+ * >+ * @param provider The provider of JPA managed types >+ * @param embeddable The design-time model object wrapped by this class >+ */ >+ JpaEmbeddable(JpaManagedTypeProvider provider, Embeddable embeddable) { >+ super(provider, embeddable); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void accept(IManagedTypeVisitor visitor) { >+ visitor.visit(this); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ Embeddable getManagedType() { >+ return (Embeddable) super.getManagedType(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEntity.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEntity.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEntity.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaEntity.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,109 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.HashMap; >+import java.util.ListIterator; >+import java.util.Map; >+import org.eclipse.jpt.jpa.core.context.Entity; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping; >+import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType; >+import org.eclipse.persistence.utils.jpa.query.spi.IEntity; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedTypeVisitor; >+import org.eclipse.persistence.utils.jpa.query.spi.IQuery; >+ >+/** >+ * The concrete implementation of {@link IEntity} that is wrapping the design-time representation >+ * of a JPA entity. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaEntity extends JpaManagedType >+ implements IEntity { >+ >+ /** >+ * The cached used to quickly retrieve any queries that have been cached. >+ */ >+ private Map<String, IQuery> queries; >+ >+ /** >+ * Creates a new <code>JpaEntity</code>. >+ * >+ * @param provider The provider of JPA managed types >+ * @param entity The design-time model object wrapped by this class >+ */ >+ JpaEntity(JpaManagedTypeProvider provider, Entity entity) { >+ super(provider, entity); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void accept(IManagedTypeVisitor visitor) { >+ visitor.visit(this); >+ } >+ >+ private IQuery buildQuery(JpaManagedTypeProvider provider, NamedQuery namedQuery) { >+ return new JpaQuery(provider, namedQuery); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ Entity getManagedType() { >+ return (Entity) super.getManagedType(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IQuery getNamedQuery(String queryName) { >+ initializeQueries(); >+ return queries.get(queryName); >+ } >+ >+ private void initializeQueries() { >+ >+ if (queries == null) { >+ queries = new HashMap<String, IQuery>(); >+ JpaManagedTypeProvider provider = getProvider(); >+ >+ for (ListIterator<NamedQuery> iter = namedQueries(); iter.hasNext(); ) { >+ NamedQuery namedQuery = iter.next(); >+ queries.put(namedQuery.getName(), buildQuery(provider, namedQuery)); >+ } >+ >+ // TODO: Refactor this. ORM doesn't inherit the Java's named queries >+ if (getManagedType().getPersistentType() instanceof OrmPersistentType) { >+ OrmPersistentType type = (OrmPersistentType) getManagedType().getPersistentType(); >+ JavaTypeMapping mapping = type.getJavaPersistentType().getMapping(); >+ if (mapping instanceof Entity) { >+ Entity entity = ((Entity) mapping); >+ for (ListIterator<NamedQuery> iter = entity.getQueryContainer().namedQueries(); iter.hasNext(); ) { >+ NamedQuery namedQuery = iter.next(); >+ queries.put(namedQuery.getName(), buildQuery(provider, namedQuery)); >+ } >+ } >+ } >+ } >+ } >+ >+ private ListIterator<NamedQuery> namedQueries() { >+ return getManagedType().getQueryContainer().namedQueries(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaJpqlQueryHelper.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaJpqlQueryHelper.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaJpqlQueryHelper.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaJpqlQueryHelper.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,168 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.common.core.internal.utility.SimpleTextRange; >+import org.eclipse.jpt.common.core.utility.TextRange; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.internal.validation.DefaultJpaValidationMessages; >+import org.eclipse.persistence.utils.jpa.query.AbstractJPQLQueryHelper; >+import org.eclipse.persistence.utils.jpa.query.JPQLQueryProblem; >+import org.eclipse.persistence.utils.jpa.query.parser.ExpressionTools; >+import org.eclipse.persistence.utils.jpa.query.spi.IQuery; >+import org.eclipse.wst.validation.internal.provisional.core.IMessage; >+ >+/** >+ * This helper can perform the following operations over a JPQL query: >+ * <ul> >+ * <li>Calculates the result type of a query: {@link #getResultType()};</li> >+ * <li>Calculates the type of an input parameter: {@link #getParameterType(String)}.</li> >+ * <li>Calculates the possible choices to complete the query from a given >+ * position (used for content assist): {@link #buildContentAssistItems(int)}.</li> >+ * <li>Validates the query by introspecting its grammar and semantic: >+ * <ul> >+ * <li>{@link #validate()},</li> >+ * <li>{@link #validateGrammar()},</li> >+ * <li>{@link #validateSemantic()}.</li> >+ * </ul></li> >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+public final class JpaJpqlQueryHelper extends AbstractJPQLQueryHelper<NamedQuery> { >+ >+ /** >+ * The actual JPQL query, which can differ from the one owned by the model object, which happens >+ * when the model is out of sync because it has not been updated yet. >+ */ >+ private final String actualQuery; >+ >+ /** >+ * The external form of the JPQL query that was already created before this helper, which happens >+ * during the execution of the unit-tests. >+ */ >+ private IQuery localQuery; >+ >+ /** >+ * Creates a new <code>JpaJpqlQueryHelper</code>. This constructor is used only by the unit-tests. >+ * >+ * @param query The external form that is already wrapping the {@link MWNamedQuery} >+ * @exception NullPointerException If the query is <code>null</code> >+ */ >+ public JpaJpqlQueryHelper(IQuery query) { >+ this(((JpaQuery) query).getQuery()); >+ this.localQuery = query; >+ } >+ >+ /** >+ * Creates a new <code>JpaJpqlQueryHelper</code>. >+ * >+ * @param query The model object where the JPQL query is stored >+ * @exception NullPointerException If the given {@link NamedQuery} is <code>null</code> >+ */ >+ public JpaJpqlQueryHelper(NamedQuery query) { >+ this(query, query.getQuery()); >+ } >+ >+ /** >+ * Creates a new <code>JpaQueryHelper</code>. >+ * >+ * @param query The model object where the JPQL query is stored >+ * @param actualQuery The actual JPQL query, which can differ from the one owned by the model >+ * object, which happens when the model is out of sync because it has not been updated yet >+ * @exception NullPointerException If the given {@link NamedQuery} is <code>null</code> >+ */ >+ public JpaJpqlQueryHelper(NamedQuery query, String actualQuery) { >+ super(query); >+ this.actualQuery = actualQuery; >+ } >+ >+ /** >+ * Creates a new {@link IMessage} for the given {@link JPQLQueryProblem}. >+ * >+ * @param problem The {@link JPQLQueryProblem problem} that was found in the JPQL query, which is >+ * either a grammatical or semantic problem >+ * @param textRange The range of the JPQL query in the Java source file >+ * @param jpqlQuery The actual JPQL query that was parsed and validated >+ * @param parsedJpqlQuery The string representation of the parsed tree representation of the JPQL >+ * query, which may differ from the actual JPQL query since it does not keep more than one >+ * whitespace >+ * @return A new {@link IMessage} that has the required information to display the problem >+ * underline and the error message in the Problems view >+ */ >+ public IMessage buildProblem(JPQLQueryProblem problem, >+ TextRange textRange, >+ String parsedJpqlQuery, >+ String parsedQuery) { >+ >+ int length = parsedQuery.length(); >+ int startPosition = problem.getStartPosition(); >+ int endPosition = problem.getEndPosition(); >+ >+ // If the start and end positions are the same, then expand the text range >+ if (startPosition == endPosition) { >+ startPosition = Math.max(startPosition - 2, 0); >+ endPosition = Math.min(endPosition + 1, length); >+ } >+ >+ // Reposition the cursor so it's correctly positioned in the JPQL query, which is the >+ // since it may contains more than one whitespace for a single whitespace >+ int newStartPosition = ExpressionTools.repositionCursor(parsedJpqlQuery, parsedQuery, startPosition); >+ >+ if (newStartPosition != startPosition) { >+ endPosition += (newStartPosition - startPosition); >+ startPosition = newStartPosition; >+ } >+ >+ // Create the text range of the problem >+ textRange = new SimpleTextRange( >+ textRange.getOffset() + startPosition + 1, >+ endPosition - startPosition, >+ textRange.getLineNumber() >+ ); >+ >+ // Now create the message >+ IMessage message = DefaultJpaValidationMessages.buildMessage( >+ IMessage.HIGH_SEVERITY, >+ problem.getMessageKey(), >+ problem.getMessageArguments(), >+ this, >+ textRange >+ ); >+ message.setBundleName("jpa_jpql_validation"); >+ return message; >+ } >+ >+ private JpaManagedTypeProvider buildProvider(NamedQuery query) { >+ try { >+ return new JpaPersistenceUnit(query.getJpaProject(), query.getPersistenceUnit()); >+ } >+ catch (Exception e) { >+ return new JpaMappingFile(query.getJpaProject(), query.getMappingFileRoot().getParent()); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected IQuery buildQuery(NamedQuery query) { >+ if (localQuery == null) { >+ localQuery = new JpaQuery(buildProvider(query), query, actualQuery); >+ } >+ return localQuery; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedType.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedType.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,127 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+import org.eclipse.jpt.jpa.core.context.AttributeMapping; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedType; >+import org.eclipse.persistence.utils.jpa.query.spi.IMapping; >+ >+/** >+ * The abstract definition of {@link IManagedType} defined for wrapping the design-time mapped class >+ * object. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+abstract class JpaManagedType implements IManagedType { >+ >+ /** >+ * The design-time model object wrapped by this class. >+ */ >+ private final TypeMapping managedType; >+ >+ /** >+ * The cached collection of {@link IMapping mappings} that prevent rebuilding them every time one >+ * is requested. >+ */ >+ private Map<String, IMapping> mappings; >+ >+ /** >+ * The provider of JPA managed types. >+ */ >+ private final JpaManagedTypeProvider provider; >+ >+ /** >+ * The cached wrapper over {@link TODO}. >+ */ >+ private JpaType type; >+ >+ /** >+ * Creates a new <code>JDeveloperManagedType</code>. >+ * >+ * @param managedType The provider of JPA managed types >+ * @param mappedClass The design-time model object wrapped by this class >+ */ >+ JpaManagedType(JpaManagedTypeProvider provider, TypeMapping managedType) { >+ super(); >+ this.provider = provider; >+ this.managedType = managedType; >+ } >+ >+ private IMapping buildMapping(AttributeMapping mapping) { >+ return new JpaMapping(this, mapping); >+ } >+ >+ private Map<String, IMapping> buildMappings() { >+ Map<String, IMapping> mappings = new HashMap<String, IMapping>(); >+ for (Iterator<AttributeMapping> iter = managedType.allAttributeMappings(); iter.hasNext(); ) { >+ AttributeMapping mapping = iter.next(); >+ mappings.put(mapping.getName(), buildMapping(mapping)); >+ } >+ return mappings; >+ } >+ >+ /** >+ * Returns the encapsulated model object. >+ * >+ * @return The managed type wrapped by this external form >+ */ >+ TypeMapping getManagedType() { >+ return managedType; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final IMapping getMappingNamed(String name) { >+ initializeMappings(); >+ return mappings.get(name); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final JpaManagedTypeProvider getProvider() { >+ return provider; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final JpaType getType() { >+ if (type == null) { >+ type = provider.getTypeRepository().getType(managedType.getPersistentType().getName()); >+ } >+ return type; >+ } >+ >+ private void initializeMappings() { >+ if (mappings == null) { >+ mappings = buildMappings(); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public final Iterator<IMapping> mappings() { >+ initializeMappings(); >+ return mappings.values().iterator(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedTypeProvider.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedTypeProvider.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedTypeProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaManagedTypeProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,222 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.HashMap; >+import java.util.Iterator; >+import java.util.Map; >+import org.eclipse.jpt.jpa.core.JpaFacet; >+import org.eclipse.jpt.jpa.core.JpaPlatform; >+import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.core.context.Embeddable; >+import org.eclipse.jpt.jpa.core.context.Entity; >+import org.eclipse.jpt.jpa.core.context.MappedSuperclass; >+import org.eclipse.jpt.jpa.core.context.PersistentType; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+import org.eclipse.jpt.jpa.core.context.persistence.PersistentTypeContainer; >+import org.eclipse.persistence.utils.jpa.query.TypeHelper; >+import org.eclipse.persistence.utils.jpa.query.spi.IJPAVersion; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedType; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedTypeProvider; >+import org.eclipse.persistence.utils.jpa.query.spi.IPlatform; >+import org.eclipse.persistence.utils.jpa.query.spi.IType; >+ >+/** >+ * The abstract implementation of {@link IManagedTypeProvider} that is wrapping the design-time >+ * representation of a provider of managed types. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+abstract class JpaManagedTypeProvider implements IManagedTypeProvider { >+ >+ /** >+ * The project that gives access to the application's metadata. >+ */ >+ private final JpaProject jpaProject; >+ >+ /** >+ * The cached {@link IManagedType managed types}. >+ */ >+ private Map<String, IManagedType> managedTypes; >+ >+ /** >+ * The design-time provider of managed types. >+ */ >+ private final PersistentTypeContainer persistentTypeContainer; >+ >+ /** >+ * The external form of a type repository. >+ */ >+ private JpaTypeRepository typeRepository; >+ >+ /** >+ * The version of the Java Persistence this entity for which it was defined. >+ */ >+ private IJPAVersion version; >+ >+ /** >+ * Creates a new <code>JpaManagedTypeProvider</code>. >+ * >+ * @param jpaProject The project that gives access to the application's metadata >+ * @param persistentTypeContainer The design-time provider of managed types >+ */ >+ JpaManagedTypeProvider(JpaProject jpaProject, PersistentTypeContainer persistentTypeContainer) { >+ >+ super(); >+ this.jpaProject = jpaProject; >+ this.persistentTypeContainer = persistentTypeContainer; >+ } >+ >+ private IManagedType buildManagedType(PersistentType persistentType) { >+ >+ TypeMapping mappedClass = persistentType.getMapping(); >+ >+ if (mappedClass instanceof Entity) { >+ return new JpaEntity(this, (Entity) mappedClass); >+ } >+ >+ if (mappedClass instanceof MappedSuperclass) { >+ return new JpaMappedSuperclass(this, (MappedSuperclass) mappedClass); >+ } >+ >+ if (mappedClass instanceof Embeddable) { >+ return new JpaEmbeddable(this, (Embeddable) mappedClass); >+ } >+ >+ return new JpaNullManagedType(this, mappedClass); >+ } >+ >+ private Map<String, IManagedType> buildManagedTypes() { >+ Map<String, IManagedType> managedTypes = new HashMap<String, IManagedType>(); >+ for (Iterator<? extends PersistentType> iter = persistenceTypes(); iter.hasNext(); ) { >+ PersistentType persistentType = iter.next(); >+ managedTypes.put(persistentType.getMapping().getName(), buildManagedType(persistentType)); >+ } >+ return managedTypes; >+ } >+ >+ private IJPAVersion convert(JpaPlatform.Version version) { >+ >+ String jpaVersion = version.getJpaVersion(); >+ >+ if (JpaFacet.VERSION_1_0.getVersionString().equals(jpaVersion)) { >+ return IJPAVersion.VERSION_1_0; >+ } >+ >+ return IJPAVersion.VERSION_2_0; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Iterator<String> entityNames() { >+ initializeManagedTypes(); >+ return managedTypes.keySet().iterator(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IManagedType getManagedType(IType type) { >+ >+ initializeManagedTypes(); >+ >+ for (IManagedType managedType : managedTypes.values()) { >+ if (managedType.getType() == type) { >+ return managedType; >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IManagedType getManagedType(String abstractSchemaName) { >+ initializeManagedTypes(); >+ return managedTypes.get(abstractSchemaName); >+ } >+ >+ /** >+ * Returns the container of managed types. >+ * >+ * @return The container of managed types >+ */ >+ PersistentTypeContainer getPersistentTypeContainer() { >+ return persistentTypeContainer; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IPlatform getPlatform() { >+ return IPlatform.JAVA; >+ // TODO >+// return (jpaProject instanceof EclipseLinkJpaProject) ? IPlatform.ECLIPSE_LINK : IPlatform.JAVA; >+ } >+ >+ /** >+ * Returns the encapsulated {@link PersistentType}, which is the actual object. >+ * >+ * @return The design-time representation of a managed type provider >+ */ >+ PersistentTypeContainer getProvider() { >+ return persistentTypeContainer; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaTypeRepository getTypeRepository() { >+ if (typeRepository == null) { >+ typeRepository = new JpaTypeRepository(jpaProject.getJavaProject()); >+ TypeHelper.setTypeRepository(typeRepository); >+ } >+ return typeRepository; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IJPAVersion getVersion() { >+ if (version == null) { >+ version = convert(jpaProject.getJpaPlatform().getJpaVersion()); >+ } >+ return version; >+ } >+ >+ private void initializeManagedTypes() { >+ if (managedTypes == null) { >+ managedTypes = buildManagedTypes(); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Iterator<IManagedType> managedTypes() { >+ initializeManagedTypes(); >+ return managedTypes.values().iterator(); >+ } >+ >+ /** >+ * Retrieves the managed types from the design-time provider. >+ * >+ * @return The managed types that are defined only in the provider >+ */ >+ abstract Iterator<? extends PersistentType> persistenceTypes(); >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappedSuperclass.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappedSuperclass.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappedSuperclass.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappedSuperclass.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.jpa.core.context.MappedSuperclass; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedTypeVisitor; >+import org.eclipse.persistence.utils.jpa.query.spi.IMappedSuperclass; >+ >+/** >+ * The concrete implementation of {@link IMappedSuperclass} that is wrapping the design-time >+ * representation of a JPA mapped superclass. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaMappedSuperclass extends JpaManagedType >+ implements IMappedSuperclass { >+ >+ /** >+ * Creates a new <code>JpaMappedSuperclass</code>. >+ * >+ * @param provider The provider of JPA managed types >+ * @param mappedSuperclass The design-time model object wrapped by this class >+ */ >+ JpaMappedSuperclass(JpaManagedTypeProvider provider, MappedSuperclass mappedSuperclass) { >+ super(provider, mappedSuperclass); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void accept(IManagedTypeVisitor visitor) { >+ visitor.visit(this); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ MappedSuperclass getManagedType() { >+ return (MappedSuperclass) super.getManagedType(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMapping.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMapping.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMapping.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMapping.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,245 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.lang.annotation.Annotation; >+import java.util.Iterator; >+import java.util.List; >+import org.eclipse.jpt.common.utility.internal.CollectionTools; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator; >+import org.eclipse.jpt.jpa.core.MappingKeys; >+import org.eclipse.jpt.jpa.core.context.AttributeMapping; >+import org.eclipse.jpt.jpa.core.context.PersistentAttribute; >+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentAttribute; >+import org.eclipse.jpt.jpa.core.jpa2.MappingKeys2_0; >+import org.eclipse.jpt.jpa.core.resource.java.JavaResourcePersistentAttribute; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedType; >+import org.eclipse.persistence.utils.jpa.query.spi.IMapping; >+import org.eclipse.persistence.utils.jpa.query.spi.IMappingType; >+import org.eclipse.persistence.utils.jpa.query.spi.IType; >+import org.eclipse.persistence.utils.jpa.query.spi.ITypeDeclaration; >+ >+/** >+ * The concrete implementation of {@link IMapping} that is wrapping the design-time representation >+ * of a mapping. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+final class JpaMapping implements IMapping { >+ >+ /** >+ * The design-time {@link AttributeMapping} wrapped by this class. >+ */ >+ private final AttributeMapping mapping; >+ >+ /** >+ * The type of the actual mapping. >+ */ >+ private IMappingType mappingType; >+ >+ /** >+ * The parent of this mapping. >+ */ >+ private final JpaManagedType parent; >+ >+ /** >+ * The type declaration of the property represented by the mapping. >+ */ >+ private ITypeDeclaration typeDeclaration; >+ >+ /** >+ * Creates a new <code>JpaMapping</code>. >+ * >+ * @param parent The parent of this mapping >+ * @param mapping The design-time {@link AttributeMapping} wrapped by this class >+ */ >+ JpaMapping(JpaManagedType parent, AttributeMapping mapping) { >+ super(); >+ this.parent = parent; >+ this.mapping = mapping; >+ } >+ >+ private Iterator<ITypeDeclaration> buildGenericTypeDeclarations(JavaResourcePersistentAttribute resource) { >+ return new TransformationIterator<String, ITypeDeclaration>(resource.typeTypeArgumentNames()) { >+ @Override >+ protected ITypeDeclaration transform(String next) { >+ return getTypeRepository().getType(next).getTypeDeclaration(); >+ } >+ }; >+ } >+ >+ private ITypeDeclaration[] buildGenericTypeDeclarations() { >+ JavaPersistentAttribute javaPersistentAttribute = mapping.getPersistentAttribute().getJavaPersistentAttribute(); >+ JavaResourcePersistentAttribute resource = javaPersistentAttribute.getResourcePersistentAttribute(); >+ List<ITypeDeclaration> declarations = CollectionTools.list(buildGenericTypeDeclarations(resource)); >+ return declarations.toArray(new ITypeDeclaration[declarations.size()]); >+ } >+ >+ private ITypeDeclaration buildTypeDeclaration() { >+ return new JpaTypeDeclaration( >+ getTypeRepository().getType(mapping.getPersistentAttribute().getTypeName()), >+ buildGenericTypeDeclarations(), >+ false /*TODO*/ >+ ); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IMappingType getMappingType() { >+ if (mappingType == null) { >+ mappingType = mappingType(); >+ } >+ return mappingType; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getName() { >+ return mapping.getName(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IManagedType getParent() { >+ return parent; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IType getType() { >+ PersistentAttribute property = mapping.getPersistentAttribute(); >+ return getTypeRepository().getType(property.getTypeName()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ITypeDeclaration getTypeDeclaration() { >+ if (typeDeclaration == null) { >+ typeDeclaration = buildTypeDeclaration(); >+ } >+ return typeDeclaration; >+ } >+ >+ private JpaTypeRepository getTypeRepository() { >+ return parent.getType().getTypeRepository(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean hasAnnotation(Class<? extends Annotation> annotationType) { >+ JavaResourcePersistentAttribute attribute = mapping.getPersistentAttribute().getJavaPersistentAttribute().getResourcePersistentAttribute(); >+ return attribute.getAnnotation(annotationType.getName()) != null; >+ } >+ >+ private IMappingType mappingType() { >+ >+ String type = mapping.getKey(); >+ >+ // Basic >+ if (type == MappingKeys.BASIC_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.BASIC; >+ } >+ >+ // Embedded >+ if (type == MappingKeys.EMBEDDED_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.EMBEDDED; >+ } >+ >+ // Embedded Id >+ if (type == MappingKeys.EMBEDDED_ID_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.EMBEDDED_ID; >+ } >+ >+ // Id >+ if (type == MappingKeys.ID_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.ID; >+ } >+ >+ // M:M >+ if (type == MappingKeys.MANY_TO_MANY_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.MANY_TO_MANY; >+ } >+ >+ // 1:M >+ if (type == MappingKeys.ONE_TO_MANY_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.ONE_TO_MANY; >+ } >+ >+ // M:1 >+ if (type == MappingKeys.MANY_TO_ONE_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.MANY_TO_ONE; >+ } >+ >+ // 1:1 >+ if (type == MappingKeys.ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.ONE_TO_ONE; >+ } >+ >+ // Version >+ if (type == MappingKeys.VERSION_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.VERSION; >+ } >+ >+ // Element Collection >+ if (type == MappingKeys2_0.ELEMENT_COLLECTION_ATTRIBUTE_MAPPING_KEY) { >+ return IMappingType.ELEMENT_COLLECTION; >+ } >+ >+ // Basic Collection >+// if (type == EclipseLinkMappingKeys.BASIC_COLLECTION_ATTRIBUTE_MAPPING_KEY) { >+// return IMappingType.BASIC_COLLECTION; >+// } >+// >+// // Basic Map >+// if (type == EclipseLinkMappingKeys.BASIC_MAP_ATTRIBUTE_MAPPING_KEY) { >+// return IMappingType.BASIC_MAP; >+// } >+// >+// // Transformation >+// if (type == EclipseLinkMappingKeys.TRANSFORMATION_ATTRIBUTE_MAPPING_KEY) { >+// return IMappingType.TRANSFORMATION; >+// } >+// >+// // Variable 1:1 >+// if (type == EclipseLinkMappingKeys.VARIABLE_ONE_TO_ONE_ATTRIBUTE_MAPPING_KEY) { >+// return IMappingType.VARIABLE_ONE_TO_ONE; >+// } >+ >+ return IMappingType.TRANSIENT; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String toString() { >+ StringBuilder sb = new StringBuilder(); >+ StringTools.buildSimpleToStringOn(this, sb); >+ sb.append("name="); >+ sb.append(getName()); >+ sb.append(", mappingType="); >+ sb.append(getMappingType()); >+ return sb.toString(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappingFile.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappingFile.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappingFile.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaMappingFile.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,55 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.Iterator; >+import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.core.context.MappingFile; >+import org.eclipse.jpt.jpa.core.context.PersistentType; >+ >+/** >+ * The concrete implementation that is wrapping the design-time representation of a mapping file. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+public class JpaMappingFile extends JpaManagedTypeProvider { >+ >+ /** >+ * Creates a new <code>JpaMappingFile</code>. >+ * >+ * @param jpaProject The project that gives access to the application's metadata >+ * @param persistentTypeContainer The design-time provider of managed types >+ */ >+ public JpaMappingFile(JpaProject jpaProject, MappingFile persistentTypeContainer) { >+ super(jpaProject, persistentTypeContainer); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected MappingFile getPersistentTypeContainer() { >+ return (MappingFile) super.getPersistentTypeContainer(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ protected Iterator<? extends PersistentType> persistenceTypes() { >+ return getPersistentTypeContainer().getPersistentTypes().iterator(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaNullManagedType.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaNullManagedType.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaNullManagedType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaNullManagedType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.Iterator; >+import org.eclipse.jpt.common.utility.internal.iterators.EmptyIterator; >+import org.eclipse.jpt.jpa.core.context.TypeMapping; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedType; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedTypeProvider; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedTypeVisitor; >+import org.eclipse.persistence.utils.jpa.query.spi.IMapping; >+import org.eclipse.persistence.utils.jpa.query.spi.IType; >+ >+/** >+ * The concrete implementation of {@link IManagedType} that is wrapping the design-time >+ * representation a "null" managed type. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaNullManagedType implements IManagedType { >+ >+ /** >+ * The provider of JPA managed types. >+ */ >+ private final JpaManagedTypeProvider provider; >+ >+ /** >+ * The design-time model object wrapped by this class. >+ */ >+ private final TypeMapping typeMapping; >+ >+ /** >+ * Creates a new <code>JpaNullManagedType</code>. >+ * >+ * @param managedType The provider of JPA managed types >+ * @param typeMapping The design-time model object wrapped by this class >+ */ >+ JpaNullManagedType(JpaManagedTypeProvider provider, TypeMapping typeMapping) { >+ super(); >+ this.provider = provider; >+ this.typeMapping = typeMapping; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void accept(IManagedTypeVisitor visitor) { >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IMapping getMappingNamed(String name) { >+ return null; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IManagedTypeProvider getProvider() { >+ return provider; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IType getType() { >+ return provider.getTypeRepository().getType(typeMapping.getPersistentType().getName()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Iterator<IMapping> mappings() { >+ return EmptyIterator.instance(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnit.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnit.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnit.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaPersistenceUnit.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,71 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.Iterator; >+import org.eclipse.jpt.common.utility.internal.iterators.CompositeIterator; >+import org.eclipse.jpt.common.utility.internal.iterators.TransformationIterator; >+import org.eclipse.jpt.jpa.core.JpaProject; >+import org.eclipse.jpt.jpa.core.context.PersistentType; >+import org.eclipse.jpt.jpa.core.context.persistence.ClassRef; >+import org.eclipse.jpt.jpa.core.context.persistence.PersistenceUnit; >+ >+/** >+ * The concrete implementation that is wrapping the design-time representation of a persistence unit. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+public final class JpaPersistenceUnit extends JpaManagedTypeProvider { >+ >+ /** >+ * Creates a new <code>JpaPersistenceUnit</code>. >+ * >+ * @param jpaProject The project that gives access to the application's metadata >+ * @param persistentUnit The design-time persistence unit >+ */ >+ public JpaPersistenceUnit(JpaProject jpaProject, PersistenceUnit persistentUnit) { >+ super(jpaProject, persistentUnit); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ PersistenceUnit getPersistentTypeContainer() { >+ return (PersistenceUnit) super.getPersistentTypeContainer(); >+ } >+ >+ @SuppressWarnings("unchecked") >+ private Iterator<ClassRef> javaClassRefs() { >+ return new CompositeIterator<ClassRef>( >+ getPersistentTypeContainer().specifiedClassRefs(), >+ getPersistentTypeContainer().impliedClassRefs() >+ ); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ Iterator<? extends PersistentType> persistenceTypes() { >+ return new TransformationIterator<ClassRef, PersistentType>(javaClassRefs()) { >+ @Override >+ protected PersistentType transform(ClassRef classRef) { >+ return classRef.getJavaPersistentType(); >+ } >+ }; >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaQuery.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaQuery.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaQuery.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaQuery.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,115 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.persistence.utils.jpa.query.spi.IQuery; >+ >+/** >+ * The concrete implementation of {@link IQuery} that is wrapping the design-time representation >+ * of a JPQL query. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+public final class JpaQuery implements IQuery { >+ >+ /** >+ * The actual JPQL query, which can differ from the one owned by the model object, which happens >+ * when the model is out of sync because it has not been updated yet. >+ */ >+ private String actualQuery; >+ >+ /** >+ * The provider of managed types. >+ */ >+ private JpaManagedTypeProvider provider; >+ >+ /** >+ * The model object holding onto the JPQL query. >+ */ >+ private NamedQuery query; >+ >+ /** >+ * Creates a new <code>JpaQuery</code>. >+ * >+ * @param provider The provider of managed types >+ * @param query The model object of the JPQL query >+ */ >+ public JpaQuery(JpaManagedTypeProvider provider, NamedQuery query) { >+ this(provider, query, query.getQuery()); >+ } >+ >+ /** >+ * Creates a new <code>JpaQuery</code>. >+ * >+ * @param provider The provider of managed types >+ * @param query The model object of the JPQL query >+ * @param actualQuery The actual JPQL query, which can differ from the one owned by the model >+ * object, which happens when the model is out of sync because it has not been updated yet >+ */ >+ JpaQuery(JpaManagedTypeProvider provider, NamedQuery query, String actualQuery) { >+ super(); >+ initialize(provider, query, actualQuery); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getExpression() { >+ return actualQuery; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaManagedTypeProvider getProvider() { >+ return provider; >+ } >+ >+ /** >+ * Returns the encapsulated {@link NamedQuery}, which is the actual object. >+ * >+ * @return The design-time representation of a JPQL query >+ */ >+ NamedQuery getQuery() { >+ return query; >+ } >+ >+ private void initialize(JpaManagedTypeProvider provider, NamedQuery query, String actualQuery) { >+ >+ this.query = query; >+ this.provider = provider; >+ this.actualQuery = actualQuery; >+ >+ if (this.actualQuery == null) { >+ this.actualQuery = StringTools.EMPTY_STRING; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String toString() { >+ StringBuilder sb = new StringBuilder(); >+ sb.append(super.toString()); >+ sb.append(", query="); >+ sb.append(getExpression()); >+ return sb.toString(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaType.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaType.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaType.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaType.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,362 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.lang.annotation.Annotation; >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.List; >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.jdt.core.IField; >+import org.eclipse.jdt.core.IJavaElement; >+import org.eclipse.jdt.core.IType; >+import org.eclipse.jdt.core.ITypeHierarchy; >+import org.eclipse.jdt.core.dom.AST; >+import org.eclipse.jdt.core.dom.ASTNode; >+import org.eclipse.jdt.core.dom.ASTParser; >+import org.eclipse.jdt.core.dom.ASTVisitor; >+import org.eclipse.jdt.core.dom.MethodDeclaration; >+import org.eclipse.jpt.common.utility.internal.StringTools; >+import org.eclipse.persistence.utils.jpa.query.parser.ExpressionTools; >+import org.eclipse.persistence.utils.jpa.query.spi.IConstructor; >+import org.eclipse.persistence.utils.jpa.query.spi.ITypeDeclaration; >+ >+/** >+ * The concrete implementation of {@link org.eclipse.persistence.jpa.query.spi.IType IType} that is >+ * wrapping the design-time representation of a Java type. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaType implements org.eclipse.persistence.utils.jpa.query.spi.IType { >+ >+ /** >+ * The cached collection of {@link IConstructor constructors}. >+ */ >+ private Collection<IConstructor> constructors; >+ >+ /** >+ * The list of names for the {@link Enum}'s constants otherwise an empty array. >+ */ >+ private String[] enumConstants; >+ >+ /** >+ * The actual Java type. >+ */ >+ private Class<?> javaType; >+ >+ /** >+ * The design-time representation of a Java type. >+ */ >+ private IType type; >+ >+ /** >+ * Caches the type hierarchy of the {@link IType} in order to prevent rebuilding it each time. >+ */ >+ private ITypeDeclaration typeDeclaration; >+ >+ /** >+ * Caches the type hierarchy of the {@link IType} in order to prevent rebuilding it each time >+ * {@link #isAssignableTo(org.eclipse.persistence.jpa.query.spi.IType)} is called. >+ */ >+ private ITypeHierarchy typeHierarchy; >+ >+ /** >+ * The fully qualified name of the Java type. >+ */ >+ private final String typeName; >+ >+ /** >+ * The external form of a type repository. >+ */ >+ private final JpaTypeRepository typeRepository; >+ >+ /** >+ * Creates a new <code>JpaType</code>. >+ * >+ * @param typeRepository The external form of a type repository >+ * @param javaType The actual Java type >+ */ >+ JpaType(JpaTypeRepository typeRepository, Class<?> javaType) { >+ this(typeRepository, javaType.getName()); >+ this.javaType = javaType; >+ } >+ >+ /** >+ * Creates a new <code>JpaType</code>. >+ * >+ * @param typeRepository The external form of a type repository >+ * @param type The design-time representation of a Java type >+ */ >+ JpaType(JpaTypeRepository typeRepository, IType type) { >+ this(typeRepository, type.getFullyQualifiedName()); >+ this.type = type; >+ } >+ >+ /** >+ * Creates a new <code>JpaType</code>. >+ * >+ * @param typeRepository The external form of a type repository >+ * @param typeName The fully qualified name of the Java type >+ */ >+ JpaType(JpaTypeRepository typeRepository, String typeName) { >+ super(); >+ this.typeName = typeName; >+ this.typeRepository = typeRepository; >+ } >+ >+ private ASTNode buildASTNode() { >+ >+ ASTParser parser = ASTParser.newParser(AST.JLS3); >+ >+ if (type.getElementType() == IJavaElement.CLASS_FILE) { >+ parser.setSource(type.getClassFile()); >+ } >+ else { >+ parser.setSource(type.getTypeRoot()); >+ } >+ >+ parser.setIgnoreMethodBodies(true); // we don't need method bodies >+ parser.setResolveBindings(true); >+ parser.setBindingsRecovery(true); // see bugs 196200, 222735 >+ >+ return parser.createAST(new NullProgressMonitor()); >+ } >+ >+ private IConstructor buildConstructor(MethodDeclaration method) { >+ return new JpaConstructor(typeRepository, method); >+ } >+ >+ private Collection<IConstructor> buildConstructors() { >+ >+ if (type == null) { >+ return Collections.emptyList(); >+ } >+ >+ final Collection<IConstructor> constructors = new ArrayList<IConstructor>(); >+ ASTNode astNode = buildASTNode(); >+ >+ astNode.accept(new ASTVisitor() { >+ @Override >+ public boolean visit(MethodDeclaration node) { >+ if (node.isConstructor()) { >+ constructors.add(buildConstructor(node)); >+ } >+ return true; >+ } >+ }); >+ >+ return constructors; >+ } >+ >+ private String[] buildEnumConstants() { >+ >+ try { >+ if ((type != null) && type.isEnum()) { >+ >+ List<String> names = new ArrayList<String>(); >+ >+ for (IField field : type.getFields()) { >+ if (field.isEnumConstant()) { >+ names.add(field.getElementName()); >+ } >+ } >+ >+ return names.toArray(new String[names.size()]); >+ } >+ } >+ catch (Exception e) { >+ // Just ignore and return an empty array >+ } >+ >+ return ExpressionTools.EMPTY_STRING_ARRAY; >+ } >+ >+ private ITypeDeclaration buildTypeDeclaration() { >+ return new JpaTypeDeclaration(this, new ITypeDeclaration[0], false); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public Iterator<IConstructor> constructors() { >+ if (constructors == null) { >+ constructors = buildConstructors(); >+ } >+ return constructors.iterator(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public boolean equals(Object object) { >+ return (this == object) || equals((org.eclipse.persistence.utils.jpa.query.spi.IType) object); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean equals(org.eclipse.persistence.utils.jpa.query.spi.IType type) { >+ return (this == type) || typeName.equals(type.getName()); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String[] getEnumConstants() { >+ if (enumConstants == null) { >+ enumConstants = buildEnumConstants(); >+ } >+ return enumConstants; >+ } >+ >+ /** >+ * Returns the encapsulated Java {@link Class}, which is the actual type. >+ * >+ * @return The actual Java type >+ */ >+ Class<?> getJavaType() { >+ return javaType; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getName() { >+ return typeName; >+ } >+ >+ /** >+ * Returns the encapsulated {@link Type}, which is the actual type. >+ * >+ * @return The design-time representation of a Java type >+ */ >+ IType getType() { >+ return type; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ITypeDeclaration getTypeDeclaration() { >+ if (typeDeclaration == null) { >+ typeDeclaration = buildTypeDeclaration(); >+ } >+ return typeDeclaration; >+ } >+ >+ /** >+ * Returns the repository that gives access to the application's classes. >+ * >+ * @return The external form of the type repository >+ */ >+ JpaTypeRepository getTypeRepository() { >+ return typeRepository; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean hasAnnotation(Class<? extends Annotation> annotationType) { >+ >+ if (type != null) { >+ return type.getAnnotation(annotationType.getName()) != null; >+ } >+ >+ if (javaType != null) { >+ return javaType.isAnnotationPresent(annotationType); >+ } >+ >+ return false; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public int hashCode() { >+ return typeName.hashCode(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isAssignableTo(org.eclipse.persistence.utils.jpa.query.spi.IType type) { >+ >+ if (this == type) { >+ return true; >+ } >+ >+ JpaType jpaType = (JpaType) type; >+ >+ // Dealing with two IType >+ if ((this.type != null) && (jpaType.type != null)) { >+ try { >+ // TODO: Use ASTTools.typeIsSubTypeOf() instead >+ if (typeHierarchy == null) { >+ typeHierarchy = this.type.newTypeHierarchy(new NullProgressMonitor()); >+ } >+ return typeHierarchy.contains(jpaType.type); >+ } >+ catch (Exception e) { >+ return false; >+ } >+ } >+ >+ // Dealing with two Class<?> >+ if ((javaType != null) && (jpaType.javaType != null)) { >+ return jpaType.javaType.isAssignableFrom(javaType); >+ } >+ >+ // Anything else is always false >+ return false; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isEnum() { >+ >+ if (javaType != null) { >+ return javaType.isEnum(); >+ } >+ >+ try { >+ return (type != null) ? type.isEnum() : false; >+ } >+ catch (Exception e) { >+ // Simply ignore and return no >+ return false; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isResolvable() { >+ return (type != null) || (javaType != null); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String toString() { >+ return StringTools.buildToStringFor(this, typeName); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeDeclaration.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeDeclaration.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeDeclaration.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeDeclaration.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,94 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import org.eclipse.persistence.utils.jpa.query.spi.IType; >+import org.eclipse.persistence.utils.jpa.query.spi.ITypeDeclaration; >+ >+/** >+ * The concrete implementation of {@link ITypeDeclaration} that is wrapping the design-time >+ * representation of the declaration description of a type. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+final class JpaTypeDeclaration implements ITypeDeclaration { >+ >+ /** >+ * Determines whether this type represents an array or not. >+ */ >+ private boolean array; >+ >+ /** >+ * The generics of the given type or an empty list if the type is not parameterized. >+ */ >+ private final ITypeDeclaration[] genericTypes; >+ >+ /** >+ * The external form of the Java type. >+ */ >+ private final IType type; >+ >+ /** >+ * Creates a new <code>JpaTypeDeclaration</code>. >+ * >+ * @param type The external form of the Java type >+ * @param genericTypes The generics of the given type or an empty list if the type is not >+ * parameterized >+ * @param array Determines whether this type represents an array or not >+ */ >+ JpaTypeDeclaration(IType type, ITypeDeclaration[] genericTypes, boolean array) { >+ super(); >+ this.type = type; >+ this.genericTypes = genericTypes; >+ this.array = array; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public int getDimensionality() { >+ return array ? 1 : 0; // TODO >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public IType getType() { >+ return type; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public ITypeDeclaration[] getTypeParameters() { >+ return genericTypes; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public boolean isArray() { >+ return array; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @Override >+ public String toString() { >+ return type.getName(); >+ } >+} >\ No newline at end of file >Index: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeRepository.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeRepository.java >diff -N src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeRepository.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/core/internal/jpql/JpaTypeRepository.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,274 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.core.internal.jpql; >+ >+import java.util.HashMap; >+import java.util.Map; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.persistence.utils.jpa.query.spi.IType; >+import org.eclipse.persistence.utils.jpa.query.spi.ITypeRepository; >+ >+/** >+ * The concrete implementation of {@link ITypeRepository} that is wrapping the design-time >+ * representation of a type repository. >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+final class JpaTypeRepository implements ITypeRepository { >+ >+ /** >+ * The Java project that gives access the design-time objects representing the Java types. >+ */ >+ private final IJavaProject javaProject; >+ >+ /** >+ * Keeps a map of the primitives for fast access. >+ */ >+ private Map<String, Class<?>> primitives; >+ >+ /** >+ * The types that have been cached for faster access. >+ */ >+ private final Map<String, JpaType> types; >+ >+ /** >+ * Creates a new <code>JpaTypeRepository</code>. >+ * >+ * @param javaProject The Java project that gives access the design-time objects representing >+ * the Java types >+ */ >+ JpaTypeRepository(IJavaProject javaProject) { >+ super(); >+ this.javaProject = javaProject; >+ this.types = new HashMap<String, JpaType>(); >+ } >+ >+ private Map<String, Class<?>> buildPrimitives() { >+ Map<String, Class<?>> primitives = new HashMap<String, Class<?>>(); >+ primitives.put(Byte .TYPE.getName(), Byte .TYPE); >+ primitives.put(Short .TYPE.getName(), Short .TYPE); >+ primitives.put(Character.TYPE.getName(), Character.TYPE); >+ primitives.put(Integer .TYPE.getName(), Integer .TYPE); >+ primitives.put(Long .TYPE.getName(), Long .TYPE); >+ primitives.put(Float .TYPE.getName(), Float .TYPE); >+ primitives.put(Double .TYPE.getName(), Double .TYPE); >+ primitives.put(Boolean .TYPE.getName(), Boolean .TYPE); >+ return primitives; >+ } >+ >+ private JpaType buildType(Class<?> javaType) { >+ JpaType jpaType = new JpaType(this, javaType); >+ types.put(jpaType.getName(), jpaType); >+ return jpaType; >+ } >+ >+ private JpaType buildType(org.eclipse.jdt.core.IType type) { >+ JpaType jpaType = new JpaType(this, type); >+ types.put(jpaType.getName(), jpaType); >+ return jpaType; >+ } >+ >+ private JpaType buildType(String typeName) { >+ return new JpaType(this, typeName); >+ } >+ >+ private Class<?> findPrimitive(String typeName) { >+ if (primitives == null) { >+ primitives = buildPrimitives(); >+ } >+ return primitives.get(typeName); >+ } >+ >+ /** >+ * Retrieves the design-time Java type for the given type name, which has to be the fully >+ * qualified type name. >+ * >+ * @param typeName The fully qualified type name >+ * @return The design-time Java type if it could be retrieved; <code>null</code> otherwise >+ */ >+ private org.eclipse.jdt.core.IType findType(String typeName) { >+ try { >+ return javaProject.findType(typeName); >+ } >+ catch (JavaModelException e) { >+ return null; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaType getEnumType(String enumTypeName) { >+ >+ // Get the position of the last dot so we can remove the constant >+ int lastDotIndex = enumTypeName.lastIndexOf("."); >+ >+ if (lastDotIndex == -1) { >+ return null; >+ } >+ >+ // Retrieve the fully qualified enum type name >+ String typeName = enumTypeName.substring(0, lastDotIndex); >+ >+ // Attempt to load the enum type >+ JpaType type = getType(typeName); >+ return type.isEnum() ? type: null; >+ } >+ >+ /** >+ * Returns >+ * >+ * @return >+ */ >+ IJavaProject getJavaProject() { >+ return javaProject; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaType getType(Class<?> javaClass) { >+ return getType(javaClass.getName()); >+ } >+ >+ /** >+ * Retrieves the {@link org.eclipse.jdt.core.IType IType} for the given {@link IResource}. >+ * >+ * @param resource The workspace location of the {@link org.eclipse.jdt.core.IType IType} to >+ * retrieve >+ * @return The design-time representation of a Java type >+ */ >+ org.eclipse.jdt.core.IType getType(IResource resource) { >+ try { >+ return (org.eclipse.jdt.core.IType) javaProject.findElement((IPath) resource); >+ } >+ catch (Exception e) { >+ return null; >+ } >+ } >+ >+ /** >+ * Retrieves the {@link org.eclipse.jdt.core.IType IType} for the given {@link IResource}. >+ * >+ * @param resource The workspace location of the {@link org.eclipse.jdt.core.IType IType} to >+ * retrieve >+ * @return The design-time representation of a Java type >+ */ >+ IType getType(org.eclipse.jdt.core.IType type) { >+ try { >+ IType jpaType = types.get(type.getFullyQualifiedName()); >+ if (jpaType == null) { >+ jpaType = buildType(type); >+ } >+ return jpaType; >+ } >+ catch (Exception e) { >+ return null; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public JpaType getType(String typeName) { >+ if (typeName.charAt(0) == '[') { >+ return loadArrayType(typeName); >+ } >+ return loadTypeImp(typeName); >+ } >+ >+ private JpaType loadArrayType(String typeName) { >+ >+ JpaType type = types.get(typeName); >+ >+ if (type == null) { >+ try { >+ // Try to see if the type is a JDK class, otherwise, just use the type name >+ // since IType doesn't support array types >+ type = buildType(Class.forName(typeName)); >+ } >+ catch (Exception e) { >+ type = buildType(typeName); >+ } >+ >+ types.put(typeName, type); >+ } >+ >+ return type; >+ } >+ >+ private JpaType loadInnerType(String typeName) { >+ >+ int index = typeName.lastIndexOf("."); >+ >+ if (index == -1) { >+ return null; >+ } >+ >+ StringBuilder sb = new StringBuilder(); >+ sb.append(typeName.substring(0, index)); >+ sb.append("$"); >+ sb.append(typeName.substring(index + 1, typeName.length())); >+ typeName = sb.toString(); >+ >+ JpaType type = types.get(typeName); >+ >+ if (type == null) { >+ type = loadTypeImp(typeName); >+ } >+ >+ return type; >+ } >+ >+ private JpaType loadTypeImp(String typeName) { >+ >+ JpaType type = types.get(typeName); >+ >+ // The type was already cached, simply return it >+ if (type != null) { >+ return type; >+ } >+ >+ // First check for primitive, they don't have a corresponding IType >+ Class<?> primitive = findPrimitive(typeName); >+ >+ if (primitive != null) { >+ return buildType(primitive); >+ } >+ >+ // Attempt to load the Java type >+ org.eclipse.jdt.core.IType iType = findType(typeName); >+ >+ // A Java type exists, return it >+ if (iType != null) { >+ return buildType(iType); >+ } >+ >+ // Now try with a possible inner enum type >+ type = loadInnerType(typeName); >+ >+ // No Java type exists, create a "null" IType >+ if (type == null) { >+ type = buildType(typeName); >+ } >+ >+ return type; >+ } >+} >\ No newline at end of file >#P org.eclipse.jpt.jpa.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/webtools/org.eclipse.jpa/components/jpa/plugins/org.eclipse.jpt.jpa.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.3 >diff -u -r1.3 MANIFEST.MF >--- META-INF/MANIFEST.MF 22 Feb 2011 17:58:29 -0000 1.3 >+++ META-INF/MANIFEST.MF 23 Feb 2011 20:00:38 -0000 >@@ -32,6 +32,7 @@ > org.eclipse.jst.common.project.facet.ui;bundle-version="[1.3.100,2.0.0)", > org.eclipse.jst.j2ee;bundle-version="[1.1.200,2.0.0)", > org.eclipse.jst.j2ee.ui;bundle-version="[1.1.200,2.0.0)", >+ org.eclipse.persistence.utils.jpa.query;bundle-version="1.0.0", > org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ui.views.properties.tabbed;bundle-version="[3.4.0,4.0.0)", > org.eclipse.ui.navigator;bundle-version="[3.3.100,4.0.0)", >@@ -64,6 +65,7 @@ > org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.connection;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.jpa2.persistence.options;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.jpa2.platform.generic;x-internal:=true, >+ org.eclipse.jpt.jpa.ui.internal.jpql;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.listeners;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.menus;x-internal:=true, > org.eclipse.jpt.jpa.ui.internal.navigator;x-internal:=true, >Index: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlQueryCompletionProposalComputer.java >=================================================================== >RCS file: src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlQueryCompletionProposalComputer.java >diff -N src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlQueryCompletionProposalComputer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jpt/jpa/ui/internal/jpql/JpaJpqlQueryCompletionProposalComputer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,605 @@ >+/******************************************************************************* >+ * Copyright (c) 2011 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * Oracle - initial API and implementation >+ * >+ ******************************************************************************/ >+package org.eclipse.jpt.jpa.ui.internal.jpql; >+ >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.Iterator; >+import java.util.List; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.jdt.core.CompletionContext; >+import org.eclipse.jdt.core.ICompilationUnit; >+import org.eclipse.jdt.core.IJavaProject; >+import org.eclipse.jdt.core.JavaModelException; >+import org.eclipse.jdt.core.dom.CompilationUnit; >+import org.eclipse.jdt.ui.PreferenceConstants; >+import org.eclipse.jdt.ui.text.java.ContentAssistInvocationContext; >+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposalComputer; >+import org.eclipse.jdt.ui.text.java.JavaContentAssistInvocationContext; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.resource.ImageRegistry; >+import org.eclipse.jface.text.contentassist.CompletionProposal; >+import org.eclipse.jface.text.contentassist.ICompletionProposal; >+import org.eclipse.jpt.common.core.internal.utility.jdt.ASTTools; >+import org.eclipse.jpt.common.core.utility.TextRange; >+import org.eclipse.jpt.jpa.core.JpaFile; >+import org.eclipse.jpt.jpa.core.JpaStructureNode; >+import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; >+import org.eclipse.jpt.jpa.core.context.NamedQuery; >+import org.eclipse.jpt.jpa.core.context.java.JavaEntity; >+import org.eclipse.jpt.jpa.core.context.java.JavaNamedQuery; >+import org.eclipse.jpt.jpa.core.context.java.JavaPersistentType; >+import org.eclipse.jpt.jpa.core.context.java.JavaTypeMapping; >+import org.eclipse.jpt.jpa.core.internal.jpql.JpaJpqlQueryHelper; >+import org.eclipse.jpt.jpa.ui.JptJpaUiPlugin; >+import org.eclipse.jpt.jpa.ui.internal.JptUiIcons; >+import org.eclipse.persistence.utils.jpa.query.ContentAssistItems; >+import org.eclipse.persistence.utils.jpa.query.parser.Expression; >+import org.eclipse.persistence.utils.jpa.query.parser.IdentifierRole; >+import org.eclipse.persistence.utils.jpa.query.parser.JPQLExpression; >+import org.eclipse.persistence.utils.jpa.query.parser.WordParser; >+import org.eclipse.persistence.utils.jpa.query.spi.IEmbeddable; >+import org.eclipse.persistence.utils.jpa.query.spi.IEntity; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedType; >+import org.eclipse.persistence.utils.jpa.query.spi.IManagedTypeVisitor; >+import org.eclipse.persistence.utils.jpa.query.spi.IMappedSuperclass; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.widgets.Display; >+ >+/** >+ * This computer adds content completion to a JPQL query defined in a {@link javax.persistence.NamedQuery >+ * @NamedQuery}. >+ * >+ * TODO: Add style to the display string by implementing ICompletionProposalExtension6. >+ * StyledString.QUALIFIER_STYLER >+ * >+ * @version 3.0 >+ * @since 3.0 >+ * @author Pascal Filion >+ */ >+@SuppressWarnings("nls") >+public final class JpaJpqlQueryCompletionProposalComputer implements IJavaCompletionProposalComputer { >+ >+ /** >+ * Flag used to determine if the word following the cursor should be overwritten or not. >+ */ >+ private boolean completionOverwrite; >+ >+ /** >+ * The provider of content assist items based on the position of the cursor within the JPQL query. >+ */ >+ private ContentAssistItems contentAssistItems; >+ >+ /** >+ * The local registry containing the images used to display the possible choices. The registry is >+ * disposed when the session ended. >+ */ >+ private ImageRegistry imageRegistry; >+ >+ /** >+ * This helper is responsible to retrieve the possible choices to complete or to add more >+ * information to a JPQL based on the position of the cursor. >+ */ >+ private JpaJpqlQueryHelper queryHelper; >+ >+ /** >+ * Creates a new <code>JpaQueryCompletionProposalComputer</code>. >+ */ >+ public JpaJpqlQueryCompletionProposalComputer() { >+ super(); >+ } >+ >+ private Image abstractSchemaNameImage(String abstractSchemaName) { >+ IManagedType managedType = queryHelper.getQuery().getProvider().getManagedType(abstractSchemaName); >+ ManagedTypeVisitor visitor = new ManagedTypeVisitor(); >+ managedType.accept(visitor); >+ return getImage(visitor.imageKey); >+ } >+ >+ /** >+ * Adds {@link ICompletionProposal ICompletionProposals} for the abstract schema names that are >+ * possible choices. >+ * >+ * @param query The current value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @param offset The position of the cursor within the document >+ * @param proposals The list used to store the new {@link ICompletionProposal ICompletionProposals} >+ */ >+ private void addAbstractSchemaNames(String query, int position, int offset, List<ICompletionProposal> proposals) { >+ for (Iterator<String> iter = contentAssistItems.abstractSchemaNames(); iter.hasNext(); ) { >+ ICompletionProposal proposal = buildAbstractSchemaNameProposal(query, iter.next(), position, offset); >+ proposals.add(proposal); >+ } >+ } >+ >+ /** >+ * Adds {@link ICompletionProposal ICompletionProposals} for the identification variables that >+ * are possible choices. >+ * >+ * @param query The current value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @param offset The position of the cursor within the document >+ * @param proposals The list used to store the new {@link ICompletionProposal ICompletionProposals} >+ */ >+ private void addIdentificationVariables(String query, int position, int offset, List<ICompletionProposal> proposals) { >+ for (Iterator<String> iter = contentAssistItems.identificationVariables(); iter.hasNext(); ) { >+ ICompletionProposal proposal = buildIdentificationVariableProposal(query, iter.next(), position, offset); >+ proposals.add(proposal); >+ } >+ } >+ >+ /** >+ * Adds {@link ICompletionProposal ICompletionProposals} for the JPQL identifiers that are >+ * possible choices. >+ * >+ * @param query The current value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @param offset The position of the cursor within the document >+ * @param proposals The list used to store the new {@link ICompletionProposal ICompletionProposals} >+ */ >+ private void addIdentifiers(String query, int position, int offset, List<ICompletionProposal> proposals) { >+ for (Iterator<String> iter = contentAssistItems.identifiers(); iter.hasNext(); ) { >+ ICompletionProposal proposal = buildIdentifierProposal(query, iter.next(), position, offset); >+ proposals.add(proposal); >+ } >+ } >+ >+ /** >+ * Adds {@link ICompletionProposal ICompletionProposals} for the state fields and association >+ * fields that are possible choices. >+ * >+ * @param query The current value of the JPQL query >+ * @param position The position of the cursor within the JPQL query >+ * @param offset The position of the cursor within the document >+ * @param proposals The list used to store the new {@link ICompletionProposal ICompletionProposals} >+ */ >+ private void addProperties(String query, int position, int offset, List<ICompletionProposal> proposals) { >+ for (Iterator<String> iter = contentAssistItems.properties(); iter.hasNext(); ) { >+ ICompletionProposal proposal = buildPropertyProposal(query, iter.next(), position, offset); >+ proposals.add(proposal); >+ } >+ } >+ >+ private ICompletionProposal buildAbstractSchemaNameProposal(String query, >+ String choice, >+ int position, >+ int offset) { >+ return buildProposal( >+ query, >+ choice, >+ choice, >+ abstractSchemaNameImage(choice), >+ position, >+ offset >+ ); >+ } >+ >+ private String buildIdentificationVariableDisplayString(String identificationVariable) { >+ >+ String schemaName = contentAssistItems.getAbstractSchemaName(identificationVariable); >+ >+ if (schemaName != null) { >+ identificationVariable += " : " + schemaName; >+ } >+ >+ return identificationVariable; >+ } >+ >+ private ICompletionProposal buildIdentificationVariableProposal(String query, String choice, int position, int offset) { >+ return buildProposal( >+ query, >+ choice, >+ buildIdentificationVariableDisplayString(choice), >+ getImage("full/obj16/jpql.variable"), // TODO >+ position, >+ offset >+ ); >+ } >+ >+ private ICompletionProposal buildIdentifierProposal(String query, >+ String choice, >+ int position, >+ int offset) { >+ >+ IdentifierRole role = JPQLExpression.identifierRole(choice); >+ boolean realFunction = (role == IdentifierRole.FUNCTION) && isRealFunction(choice); >+ int cursorOffset = 0; >+ >+ // For JPQL function, we add () to the display string, example: AVG() >+ // But for TRUE, FALSE, etc, we don't add () >+ if (realFunction) { >+ choice += "()"; >+ cursorOffset--; >+ } >+ >+ return buildProposal( >+ query, >+ choice, >+ choice, >+ identifierImage(role, realFunction), >+ position, >+ offset, >+ cursorOffset >+ ); >+ } >+ >+ private ICompletionProposal buildPropertyProposal(String query, String choice, int position, int offset) { >+ return buildProposal(query, choice, choice, mappingImage(choice), position, offset); >+ } >+ >+ private ICompletionProposal buildProposal(String query, >+ String choice, >+ String displayString, >+ Image image, >+ int position, >+ int offset) { >+ >+ StringBuilder newQuery = new StringBuilder(query); >+ newQuery.insert(position, choice); >+ >+ return buildProposal( >+ query, >+ choice, >+ displayString, >+ image, >+ position, >+ offset, >+ 0 >+ ); >+ } >+ >+ /** >+ * TODO: Possibly remove the behavior used to manipulate the new query and move it to new >+ * subclasses of ICompletionProposal that would take care of it. A ICompletionProposal per >+ * proposal type. >+ */ >+ private ICompletionProposal buildProposal(String query, >+ String choice, >+ String displayString, >+ Image image, >+ int position, >+ int offset, >+ int cursorOffset) { >+ >+ StringBuilder newQuery = new StringBuilder(query); >+ >+ // First remove from the choice the partial word, which is the non-whitespace or delimiter >+ // characters before the cursor so when adding the choice, we don't add duplicate characters. >+ // Example: Emp|, we don't want to add EmpEmployee but Employee, so we remove Emp from the choice >+ WordParser wordParser = new WordParser(query); >+ wordParser.setPosition(position); >+ String partialWord = wordParser.partialWord(position); >+ >+ if (partialWord.length() > 0) { >+ // Don't remove path expression that is before the last dot, for example: >+ // e.z| or e.zipcode.|, we don't want to remove e. and e.zipcode respectively >+ int index = query.lastIndexOf('.', position); >+ if (index == -1) { >+ index = partialWord.length(); >+ choice = choice.substring(index); >+ } >+ else if (position - partialWord.length() < index) { >+ index = position - index - 1; >+ choice = choice.substring(index); >+ } >+ } >+ >+ // Now check if we should remove the rest of the word at the cursor position >+ // before adding the choice >+ if (completionOverwrite) { >+ String potentialWord = wordParser.potentialWord(); >+ newQuery.delete(position, position + potentialWord.length()); >+ } >+ >+ // Create what could be the new query if the choice was added >+ newQuery.insert(position, choice); >+ >+ return new CompletionProposal( >+ newQuery.toString(), >+ offset + 1, >+ query.length(), >+ position + choice.length() + cursorOffset, >+ image, >+ displayString, >+ null, >+ null >+ ); >+ } >+ >+ private List<ICompletionProposal> buildProposals(NamedQuery namedQuery, >+ String actualQuery, >+ int tokenStart, >+ int position, >+ CompletionContext completionContext) { >+ >+ completionOverwrite = isCompletionOverwrite(namedQuery.getJpaProject().getJavaProject()); >+ List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>(); >+ >+ queryHelper = new JpaJpqlQueryHelper(namedQuery, actualQuery); >+ contentAssistItems = queryHelper.buildContentAssistItems(position); >+ >+ addAbstractSchemaNames (actualQuery, position, tokenStart, proposals); >+ addIdentificationVariables(actualQuery, position, tokenStart, proposals); >+ addIdentifiers (actualQuery, position, tokenStart, proposals); >+ addProperties (actualQuery, position, tokenStart, proposals); >+ >+ return proposals; >+ } >+ >+ private void checkCanceled(IProgressMonitor monitor) throws InterruptedException { >+ if (monitor.isCanceled()) { >+ throw new InterruptedException(); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @SuppressWarnings("rawtypes") >+ public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { >+ >+ if (context instanceof JavaContentAssistInvocationContext) { >+ monitor.beginTask(null, 100); >+ try { >+ return computeCompletionProposals((JavaContentAssistInvocationContext) context, monitor); >+ } >+ catch (Exception e) { >+ Status status = new Status(IStatus.ERROR, JptJpaCorePlugin.PLUGIN_ID, "Can't retrieve JPQL proposals due to an internal error.", e); >+ JptJpaCorePlugin.log(status); >+ } >+ finally { >+ monitor.done(); >+ } >+ } >+ >+ return Collections.emptyList(); >+ } >+ >+ private List<ICompletionProposal> computeCompletionProposals(JavaContentAssistInvocationContext context, >+ IProgressMonitor monitor) throws Exception { >+ >+ ICompilationUnit compilationUnit = context.getCompilationUnit(); >+ if (compilationUnit == null) return Collections.emptyList(); >+ >+ IFile file = getCorrespondingResource(compilationUnit); >+ if (file == null) return Collections.emptyList(); >+ >+ JpaFile jpaFile = JptJpaCorePlugin.getJpaFile(file); >+ if (jpaFile == null) return Collections.emptyList(); >+ >+ monitor.worked(80); >+ checkCanceled(monitor); >+ >+ Iterator<JpaStructureNode> rootStructureNodes = jpaFile.rootStructureNodes(); >+ if (!rootStructureNodes.hasNext()) return Collections.emptyList(); >+ >+ CompletionContext completionContext = context.getCoreContext(); >+ >+ // The token "start" is the offset of the token's first character >+ int tokenStart = completionContext.getTokenStart(); >+ >+ // Not sure why this happens - see bug 242286 >+ if (tokenStart == -1) { >+ return Collections.emptyList(); >+ } >+ >+ CompilationUnit astRoot = ASTTools.buildASTRoot(compilationUnit); >+ >+ for (Iterator<JpaStructureNode> iter = rootStructureNodes; iter.hasNext(); ) { >+ // First find the Named Query node >+ JavaNamedQuery namedQuery = findNamedQuery(iter.next(), astRoot, tokenStart); >+ >+ if (namedQuery != null) { >+ // Make sure the position within the query (inside the double quotes) >+ TextRange textRange = namedQuery.getQueryAnnotation().getQueryTextRange(astRoot); >+ int position = completionContext.getOffset() - textRange.getOffset() - 1; >+ >+ if (position >= 0) { >+ // Retrieve the actual value of the element "query" since the content assist can be >+ // invoked before the model received the new content >+ int tokenEnd = completionContext.getTokenEnd(); >+ String actualQuery = context.getDocument().get(tokenStart + 1, tokenEnd - tokenStart - 1); >+ >+ // Now create the proposals >+ return buildProposals(namedQuery, actualQuery, tokenStart, position, completionContext); >+ } >+ } >+ } >+ >+ return Collections.emptyList(); >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ @SuppressWarnings("rawtypes") >+ public List computeContextInformation(ContentAssistInvocationContext context, >+ IProgressMonitor monitor) { >+ >+ return Collections.emptyList(); >+ } >+ >+ private JavaNamedQuery findNamedQuery(JpaStructureNode structureNode, >+ CompilationUnit astRoot, >+ int tokenStart) { >+ >+ if (structureNode instanceof JavaPersistentType) { >+ JavaPersistentType persistentType = (JavaPersistentType) structureNode; >+ JavaTypeMapping typeMapping = persistentType.getMapping(); >+ >+ if (typeMapping instanceof JavaEntity) { >+ JavaEntity entity = (JavaEntity) typeMapping; >+ >+ for (Iterator<JavaNamedQuery> queries = entity.getQueryContainer().namedQueries(); queries.hasNext(); ) { >+ JavaNamedQuery namedQuery = queries.next(); >+ TextRange textRange = namedQuery.getQueryAnnotation().getQueryTextRange(astRoot); >+ >+ if (textRange.includes(tokenStart)) { >+ return namedQuery; >+ } >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ private IFile getCorrespondingResource(ICompilationUnit compilationUnit) { >+ try { >+ return (IFile) compilationUnit.getCorrespondingResource(); >+ } >+ catch (JavaModelException ex) { >+ JptJpaCorePlugin.log(ex); >+ return null; >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public String getErrorMessage() { >+ return null; >+ } >+ >+ private Image getImage(String key) { >+ ImageRegistry imageRegistry = getImageRegistry(); >+ Image image = imageRegistry.get(key); >+ if (image == null) { >+ imageRegistry.put(key, getImageDescriptor(key)); >+ image = imageRegistry.get(key); >+ } >+ return image; >+ } >+ >+ /** >+ * Returns an image descriptor for the specified <code>.gif<code> file in the icons folder. >+ */ >+ private ImageDescriptor getImageDescriptor(String key) { >+ return JptJpaUiPlugin.getImageDescriptor(key); >+ } >+ >+ private ImageRegistry getImageRegistry() { >+ if (imageRegistry == null) { >+ imageRegistry = new ImageRegistry(Display.getCurrent()); >+ } >+ return imageRegistry; >+ } >+ >+ @SuppressWarnings("fallthrough") >+ private Image identifierImage(IdentifierRole role, boolean realFunction) { >+ >+ if (role != null) { >+ switch (role) { >+ case FUNCTION: { >+ if (realFunction) { >+ // TODO >+ return getImage("full/obj16/jpql.function"); >+ } >+ } >+ default: { >+ // TODO >+ return getImage("full/obj16/jpql.identifier"); >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ private boolean isCompletionOverwrite(IJavaProject javaProject) { >+ String value = PreferenceConstants.getPreference(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, javaProject); >+ return !Boolean.valueOf(value); >+ } >+ >+ private boolean isRealFunction(String identifier) { >+ return identifier != Expression.TRUE && >+ identifier != Expression.FALSE && >+ identifier != Expression.NULL && >+ identifier != Expression.CURRENT_DATE && >+ identifier != Expression.CURRENT_TIME && >+ identifier != Expression.CURRENT_TIMESTAMP; >+ } >+ >+ private Image mappingImage(String propertyName) { >+ switch (contentAssistItems.getMappingType(propertyName)) { >+ case BASIC: return getImage(JptUiIcons.BASIC); >+ case BASIC_COLLECTION: return getImage(JptUiIcons.ELEMENT_COLLECTION); >+ case BASIC_MAP: return getImage(JptUiIcons.ELEMENT_COLLECTION); >+ case ELEMENT_COLLECTION: return getImage(JptUiIcons.ELEMENT_COLLECTION); >+ case EMBEDDED: return getImage(JptUiIcons.EMBEDDED); >+ case EMBEDDED_ID: return getImage(JptUiIcons.EMBEDDED_ID); >+ case ID: return getImage(JptUiIcons.ID); >+ case MANY_TO_MANY: return getImage(JptUiIcons.MANY_TO_MANY); >+ case MANY_TO_ONE: return getImage(JptUiIcons.MANY_TO_ONE); >+ case ONE_TO_MANY: return getImage(JptUiIcons.ONE_TO_MANY); >+ case ONE_TO_ONE: return getImage(JptUiIcons.ONE_TO_ONE); >+ case TRANSFORMATION: return getImage(JptUiIcons.TRANSIENT); // TODO >+ case VARIABLE_ONE_TO_ONE: return getImage(JptUiIcons.ONE_TO_ONE); // TODO >+ case VERSION: return getImage(JptUiIcons.VERSION); >+ default: return getImage(JptUiIcons.TRANSIENT); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void sessionEnded() { >+ >+ queryHelper = null; >+ contentAssistItems = null; >+ >+ if (imageRegistry != null) { >+ imageRegistry.dispose(); >+ } >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void sessionStarted() { >+ // Nothing to do >+ } >+ >+ private class ManagedTypeVisitor implements IManagedTypeVisitor { >+ >+ /** >+ * The key used to retrieve the image representing the managed type. >+ */ >+ String imageKey; >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void visit(IEmbeddable embeddable) { >+ imageKey = JptUiIcons.EMBEDDABLE; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void visit(IEntity entity) { >+ imageKey = JptUiIcons.ENTITY; >+ } >+ >+ /** >+ * {@inheritDoc} >+ */ >+ public void visit(IMappedSuperclass mappedSuperclass) { >+ imageKey = JptUiIcons.MAPPED_SUPERCLASS; >+ } >+ } >+} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 337930
:
189609
|
189610
|
189632
|
189633
|
190326
|
190327
|
191181
|
191182
|
191457
|
191822
|
192304
|
192454
|
193077