Package org.eclipse.persistence.jpa.jpql.parser

Examples of org.eclipse.persistence.jpa.jpql.parser.CollectionExpression


    validateAbstractSingleEncapsulatedExpression(expression, concatExpressionHelper());

    if (expression.hasLeftParenthesis() &&
        expression.hasExpression()) {

      CollectionExpression collectionExpression = getCollectionExpression(expression.getExpression());

      // Single element
      if (collectionExpression == null) {
        addProblem(expression, ConcatExpression_MissingExpression);
      }
      else {
        for (Expression child : collectionExpression.children()) {
          if (!isValid(child, expression.encapsulatedExpressionBNF())) {
            addProblem(child, ConcatExpression_InvalidExpression, child.toParsedText());
          }
        }
      }
View Full Code Here


    // Validate range variable declaration
    if (expression.hasRangeVariableDeclaration()) {

      // More than one entity abstract schema type is declared
      CollectionExpression collectionExpression = getCollectionExpression(expression.getRangeVariableDeclaration());

      if (collectionExpression != null) {
        Expression firstChild = collectionExpression.getChild(0);
        int startPosition = position(firstChild) + length(firstChild);
        int endPosition = position(collectionExpression) + length(collectionExpression);
        boolean malformed = false;

        for (int index = collectionExpression.childrenSize() - 1; --index >= 0; ) {
          if (!collectionExpression.hasComma(index)) {
            malformed = true;
          }
        }

        if (collectionExpression.toActualText().endsWith(" ")) {
          endPosition--;
        }

        addProblem(
          expression,
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public CollectionExpression buildCollectionExpression(UpdateClause expression) {
      CollectionExpression collectionExpression = getCollectionExpression(expression.getUpdateItems());
      if (collectionExpression == null) {
        collectionExpression = expression.buildCollectionExpression();
      }
      return collectionExpression;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public CollectionExpression buildCollectionExpression(ConstructorExpression expression) {
      CollectionExpression collectionExpression = getCollectionExpression(expression.getConstructorItems());
      if (collectionExpression == null) {
        collectionExpression = expression.buildCollectionExpression();
      }
      return collectionExpression;
    }
View Full Code Here

  protected void addSelectExpressionProposals(AbstractSelectClause expression, int length) {

    int position = getPosition(expression) - corrections.peek();

    // Now check for inside the select expression
    CollectionExpression collectionExpression = getCollectionExpression(expression.getSelectExpression());

    if (collectionExpression != null) {

      for (int index = 0, count = collectionExpression.childrenSize(); index < count; index++) {
        Expression child = collectionExpression.getChild(index);

        // At the beginning of the child expression
        if (position == length) {
          addAllIdentificationVariables();
          addAllFunctions(expression.selectItemBNF());
          break;
        }
        else {
          boolean withinChild = addSelectExpressionProposals(
            child,
            expression.selectItemBNF(),
            length,
            index,
            index + 1 == count
          );

          if (withinChild) {
            break;
          }
        }

        length += length(child);

        if (collectionExpression.hasComma(index)) {
          length++;
        }
        // Cannot do anything more since a comma is missing,
        // which means the query is not valid
        else {
          break;
        }

        // After ',', the proposals can be added
        if (position == length) {
          addAllIdentificationVariables();
          addAllFunctions(expression.selectItemBNF());
          break;
        }

        if (collectionExpression.hasSpace(index)) {
          length++;
        }
      }
    }
    else {
View Full Code Here

        helper.addProposals(expression, 0);
      }
      // Within the encapsulated expressions
      else {
        // Create a collection representation of the encapsulated expression(s)
        CollectionExpression collectionExpression = helper.buildCollectionExpression(expression);
        boolean hasComma = false;

        // Determine the maximum children count, it is possible the query contains more children
        // than the expession's grammar would actually allow. The content assist will only
        // provide assistance from the first child to the last allowed child
        int count = Math.min(collectionExpression.childrenSize(), helper.maxCollectionSize(expression));

        for (int index = 0; index < count; index++) {
          Expression child = collectionExpression.getChild(index);
          int childLength = 0;

          // At the beginning of the child expression
          if (position == length) {
            helper.addProposals(expression, index);
            break;
          }
          else {
            childLength = length(child);

            // At the end of the child expression
            if ((position == length + childLength + virtualSpaces.peek()) &&
                 isComplete(child)) {

              helper.addAtTheEndOfChild(expression, child, index);
              break;
            }
          }

          // Now add the child's length and length used by the comma and space
          length += childLength;

          // Move after the comma
          hasComma = collectionExpression.hasComma(index);

          if (hasComma) {
            length++;

            // After ',', the proposals can be added
            if (position == length) {
              helper.addProposals(expression, index + 1);
              break;
            }
          }

          // Move after the space that follows the comma
          if (collectionExpression.hasSpace(index)) {
            length++;
          }

          // Nothing more can be looked at
          if (position < length) {
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public CollectionExpression buildCollectionExpression(AbstractFromClause expression) {
      CollectionExpression collectionExpression = getCollectionExpression(expression.getDeclaration());
      if (collectionExpression == null) {
        collectionExpression = expression.buildCollectionExpression();
      }
      return collectionExpression;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public CollectionExpression buildCollectionExpression(GroupByClause expression) {
      CollectionExpression collectionExpression = getCollectionExpression(expression.getGroupByItems());
      if (collectionExpression == null) {
        collectionExpression = expression.buildCollectionExpression();
      }
      return collectionExpression;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public CollectionExpression buildCollectionExpression(IdentificationVariableDeclaration expression) {
      CollectionExpression collectionExpression = getCollectionExpression(expression.getJoins());
      if (collectionExpression == null) {
        collectionExpression = expression.buildCollectionExpression();
      }
      return collectionExpression;
    }
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public CollectionExpression buildCollectionExpression(OrderByClause expression) {
      CollectionExpression collectionExpression = getCollectionExpression(expression.getOrderByItems());
      if (collectionExpression == null) {
        collectionExpression = expression.buildCollectionExpression();
      }
      return collectionExpression;
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.jpa.jpql.parser.CollectionExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.