コード例 #1
0
 public String getName() {
   if (name == null) {
     AST n = getFirstChild().getNextSibling();
     name = n.getText();
   }
   return name;
 }
コード例 #2
0
  public final void type(AST _t) throws RecognitionException {

    AST type_AST_in = (_t == ASTNULL) ? null : (AST) _t;

    if (_t == null) _t = ASTNULL;
    switch (_t.getType()) {
      case INT:
        {
          AST tmp5_AST_in = (AST) _t;
          match(_t, INT);
          _t = _t.getNextSibling();
          break;
        }
      case FLOAT:
        {
          AST tmp6_AST_in = (AST) _t;
          match(_t, FLOAT);
          _t = _t.getNextSibling();
          break;
        }
      default:
        {
          throw new NoViableAltException(_t);
        }
    }
    _retTree = _t;
  }
コード例 #3
0
  /** {@inheritDoc} */
  public void print(AST node, NodeWriter out) throws IOException {
    printBlankLinesBefore((JavaNode) node, out);

    for (AST child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
      PrinterFactory.create(child, out).print(child, out);
    }

    switch (out.last) {
      case JavaTokenTypes.CLASS_DEF:
        switch (((JavaNode) node).getParent().getType()) {
            // anonymous inner class is a VARIABLE_DEF assignment, let
            // VariableDeclarationPrinter.java handle the masquerading
          case JavaTokenTypes.ASSIGN:
            break;

            // anonymous inner class is a return expression
          case JavaTokenTypes.LITERAL_return:
            break;

            // anonymous inner class is a METHOD_CALL param expression
          case JavaTokenTypes.SLIST:
          case JavaTokenTypes.ELIST:
            break;

            // anonymous inner class is local assignment
          default:
            out.last = JavaTokenTypes.RCURLY;
            out.printNewline();

            break;
        }

        break;
    }
  }
コード例 #4
0
 public String getName() {
   AST node = getFirstChild();
   if (node != null) {
     return node.getText();
   }
   return null;
 }
コード例 #5
0
ファイル: HqlParser.java プロジェクト: rocky-bgta/JARS
 public void processMemberOf(Token n, AST p, ASTPair currentAST) {
   AST inAst = n == null ? astFactory.create(IN, "in") : astFactory.create(NOT_IN, "not in");
   astFactory.makeASTRoot(currentAST, inAst);
   AST ast = createSubquery(p);
   ast = ASTUtil.createParent(astFactory, IN_LIST, "inList", ast);
   inAst.addChild(ast);
 }
コード例 #6
0
  protected void createFromJoinElement(
      AST path, AST alias, int joinType, AST fetchNode, AST propertyFetch, AST with)
      throws SemanticException {
    boolean fetch = fetchNode != null;
    if (fetch && isSubQuery()) {
      throw new QueryException("fetch not allowed in subquery from-elements");
    }
    // The path AST should be a DotNode, and it should have been evaluated already.
    if (path.getType() != SqlTokenTypes.DOT) {
      throw new SemanticException("Path expected for join!");
    }
    DotNode dot = (DotNode) path;
    int hibernateJoinType = JoinProcessor.toHibernateJoinType(joinType);
    dot.setJoinType(hibernateJoinType); // Tell the dot node about the join type.
    dot.setFetch(fetch);
    // Generate an explicit join for the root dot node.   The implied joins will be collected and
    // passed up
    // to the root dot node.
    dot.resolve(true, false, alias == null ? null : alias.getText());
    FromElement fromElement = dot.getImpliedJoin();
    fromElement.setAllPropertyFetch(propertyFetch != null);

    if (with != null) {
      if (fetch) {
        throw new SemanticException("with-clause not allowed on fetched associations; use filters");
      }
      handleWithFragment(fromElement, with);
    }

    if (log.isDebugEnabled()) {
      log.debug(
          "createFromJoinElement() : "
              + getASTPrinter().showAsString(fromElement, "-- join tree --"));
    }
  }
コード例 #7
0
 protected AST lookupProperty(AST dot, boolean root, boolean inSelect) throws SemanticException {
   DotNode dotNode = (DotNode) dot;
   FromReferenceNode lhs = dotNode.getLhs();
   AST rhs = lhs.getNextSibling();
   switch (rhs.getType()) {
     case SqlTokenTypes.ELEMENTS:
     case SqlTokenTypes.INDICES:
       if (log.isDebugEnabled()) {
         log.debug(
             "lookupProperty() "
                 + dotNode.getPath()
                 + " => "
                 + rhs.getText()
                 + "("
                 + lhs.getPath()
                 + ")");
       }
       CollectionFunction f = (CollectionFunction) rhs;
       // Re-arrange the tree so that the collection function is the root and the lhs is the path.
       f.setFirstChild(lhs);
       lhs.setNextSibling(null);
       dotNode.setFirstChild(f);
       resolve(lhs); // Don't forget to resolve the argument!
       f.resolve(inSelect); // Resolve the collection function now.
       return f;
     default:
       // Resolve everything up to this dot, but don't resolve the placeholders yet.
       dotNode.resolveFirstChild();
       return dotNode;
   }
 }
コード例 #8
0
  private void handleWithFragment(FromElement fromElement, AST hqlWithNode)
      throws SemanticException {
    try {
      withClause(hqlWithNode);
      AST hqlSqlWithNode = returnAST;
      if (log.isDebugEnabled()) {
        log.debug(
            "handleWithFragment() : "
                + getASTPrinter().showAsString(hqlSqlWithNode, "-- with clause --"));
      }
      WithClauseVisitor visitor = new WithClauseVisitor();
      NodeTraverser traverser = new NodeTraverser(visitor);
      traverser.traverseDepthFirst(hqlSqlWithNode);
      FromElement referencedFromElement = visitor.getReferencedFromElement();
      if (referencedFromElement != fromElement) {
        throw new SemanticException(
            "with-clause expressions did not reference from-clause element to which the with-clause was associated");
      }
      SqlGenerator sql = new SqlGenerator(getSessionFactoryHelper().getFactory());
      sql.whereExpr(hqlSqlWithNode.getFirstChild());
      fromElement.setWithClauseFragment(visitor.getJoinAlias(), "(" + sql.getSQL() + ")");

    } catch (SemanticException e) {
      throw e;
    } catch (Exception e) {
      throw new SemanticException(e.getMessage());
    }
  }
コード例 #9
0
ファイル: EJBQLTest.java プロジェクト: Centriam/hibernate-orm
  private AST parse(String input, boolean logging)
      throws RecognitionException, TokenStreamException {
    if (logging) {
      System.out.println("input: ->" + input + "<-");
    }

    HqlParser parser = HqlParser.getInstance(input);
    parser.setFilter(false);
    parser.statement();
    AST ast = parser.getAST();

    if (logging) {
      System.out.println("AST  :  " + ast.toStringTree() + "");
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      parser.showAst(ast, new PrintStream(baos));
      System.out.println(baos.toString());
    }

    assertEquals(
        "At least one error occurred during parsing!",
        0,
        parser.getParseErrorHandler().getErrorCount());

    return ast;
  }
コード例 #10
0
  protected void processQuery(AST select, AST query) throws SemanticException {
    if (log.isDebugEnabled()) {
      log.debug("processQuery() : " + query.toStringTree());
    }

    try {
      QueryNode qn = (QueryNode) query;

      // Was there an explicit select expression?
      boolean explicitSelect = select != null && select.getNumberOfChildren() > 0;

      if (!explicitSelect) {
        // No explicit select expression; render the id and properties
        // projection lists for every persister in the from clause into
        // a single 'token node'.
        // TODO: the only reason we need this stuff now is collection filters,
        //      we should get rid of derived select clause completely!
        createSelectClauseFromFromClause(qn);
      } else {
        // Use the explicitly declared select expression; determine the
        // return types indicated by each select token
        useSelectClause(select);
      }

      // After that, process the JOINs.
      // Invoke a delegate to do the work, as this is farily complex.
      JoinProcessor joinProcessor = new JoinProcessor(astFactory, queryTranslatorImpl);
      joinProcessor.processJoins(qn, isSubQuery());

      // Attach any mapping-defined "ORDER BY" fragments
      Iterator itr = qn.getFromClause().getProjectionList().iterator();
      while (itr.hasNext()) {
        final FromElement fromElement = (FromElement) itr.next();
        //			if ( fromElement.isFetch() && fromElement.isCollectionJoin() ) {
        if (fromElement.isFetch() && fromElement.getQueryableCollection() != null) {
          // Does the collection referenced by this FromElement
          // specify an order-by attribute?  If so, attach it to
          // the query's order-by
          if (fromElement.getQueryableCollection().hasOrdering()) {
            String orderByFragment =
                fromElement
                    .getQueryableCollection()
                    .getSQLOrderByString(fromElement.getCollectionTableAlias());
            qn.getOrderByClause().addOrderFragment(orderByFragment);
          }
          if (fromElement.getQueryableCollection().hasManyToManyOrdering()) {
            String orderByFragment =
                fromElement
                    .getQueryableCollection()
                    .getManyToManyOrderByString(fromElement.getTableAlias());
            qn.getOrderByClause().addOrderFragment(orderByFragment);
          }
        }
      }
    } finally {
      popFromClause();
    }
  }
コード例 #11
0
 /**
  * Returns the number of direct child tokens that have the specified type.
  *
  * @param type the token type to match
  * @return the number of matching token
  */
 public int getChildCount(int type) {
   int count = 0;
   for (AST i = getFirstChild(); i != null; i = i.getNextSibling()) {
     if (i.getType() == type) {
       count++;
     }
   }
   return count;
 }
コード例 #12
0
ファイル: SelectClause.java プロジェクト: hth/hibernate-orm
 protected AST getFirstSelectExpression() {
   AST n = getFirstChild();
   // Skip 'DISTINCT' and 'ALL', so we return the first expression node.
   while (n != null
       && (n.getType() == SqlTokenTypes.DISTINCT || n.getType() == SqlTokenTypes.ALL)) {
     n = n.getNextSibling();
   }
   return n;
 }
コード例 #13
0
 public AST fastForwardTo(int nodeType) {
   while (hasNext()) {
     AST ast = next();
     if (ast.getType() == nodeType) {
       return ast;
     }
   }
   return null;
 }
コード例 #14
0
ファイル: StructVisitor.java プロジェクト: liucong/jms4cxf2
  private void visitStructMembers(
      AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) {
    AST memberTypeNode = identifierNode.getNextSibling();
    while (memberTypeNode != null) {
      AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);

      XmlSchemaType schemaType = null;
      CorbaTypeImpl corbaType = null;
      Scope fqName = null;
      try {
        TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null);
        visitor.visit(memberTypeNode);
        schemaType = visitor.getSchemaType();
        corbaType = visitor.getCorbaType();
        fqName = visitor.getFullyQualifiedName();
      } catch (Exception ex) {
        throw new RuntimeException(ex);
      }

      // Handle multiple struct member declarators
      // <declarators> :== <declarator> { "," <declarator> }*
      //
      // A multiple declarator must be an identifier (i.e. of type IDENT)
      // and cannot be a previous declared (or forward declared) type
      // (hence the ScopedNameVisitor.accept() call).
      while (memberNode != null
          && memberNode.getType() == IDLTokenTypes.IDENT
          && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor)) {

        XmlSchemaType memberSchemaType = schemaType;
        CorbaTypeImpl memberCorbaType = corbaType;
        // needed for anonymous arrays in structs
        if (ArrayVisitor.accept(memberNode)) {
          Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode));
          ArrayVisitor arrayVisitor =
              new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName);
          arrayVisitor.setSchemaType(schemaType);
          arrayVisitor.setCorbaType(corbaType);
          arrayVisitor.visit(memberNode);
          memberSchemaType = arrayVisitor.getSchemaType();
          memberCorbaType = arrayVisitor.getCorbaType();
          fqName = arrayVisitor.getFullyQualifiedName();
        }

        XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName);
        sequence.getItems().add(member);
        MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName);
        struct.getMember().add(memberType);

        memberNode = memberNode.getNextSibling();
      }

      memberTypeNode = memberNode;
    }
  }
コード例 #15
0
  @Override
  public void visitToken(DetailAST aAST) {
    // no need to check for nulls here, == and != always have two children
    final AST firstChild = aAST.getFirstChild();
    final AST secondChild = firstChild.getNextSibling();

    if ((firstChild.getType() == TokenTypes.STRING_LITERAL)
        || (secondChild.getType() == TokenTypes.STRING_LITERAL)) {
      log(aAST.getLineNo(), aAST.getColumnNo(), "string.literal.equality", aAST.getText());
    }
  }
コード例 #16
0
  private Sequence processQuery(String select) throws SAXException {
    XQueryContext context = null;
    try {
      context = new XQueryContext(broker.getBrokerPool(), accessCtx);
      context.setStaticallyKnownDocuments(documentSet);
      Map.Entry<String, String> namespaceEntry;
      for (final Iterator<Map.Entry<String, String>> i = namespaces.entrySet().iterator();
          i.hasNext(); ) {
        namespaceEntry = (Map.Entry<String, String>) i.next();
        context.declareNamespace(namespaceEntry.getKey(), namespaceEntry.getValue());
      }
      Map.Entry<String, Object> entry;
      for (final Iterator<Map.Entry<String, Object>> i = variables.entrySet().iterator();
          i.hasNext(); ) {
        entry = (Map.Entry<String, Object>) i.next();
        context.declareVariable(entry.getKey().toString(), entry.getValue());
      }
      // TODO(pkaminsk2): why replicate XQuery.compile here?
      final XQueryLexer lexer = new XQueryLexer(context, new StringReader(select));
      final XQueryParser parser = new XQueryParser(lexer);
      final XQueryTreeParser treeParser = new XQueryTreeParser(context);
      parser.xpath();
      if (parser.foundErrors()) {
        throw new SAXException(parser.getErrorMessage());
      }

      final AST ast = parser.getAST();

      if (LOG.isDebugEnabled()) {
        LOG.debug("generated AST: " + ast.toStringTree());
      }

      final PathExpr expr = new PathExpr(context);
      treeParser.xpath(ast, expr);
      if (treeParser.foundErrors()) {
        throw new SAXException(treeParser.getErrorMessage());
      }
      expr.analyze(new AnalyzeContextInfo());
      final Sequence seq = expr.eval(null, null);
      return seq;
    } catch (final RecognitionException e) {
      LOG.warn("error while creating variable", e);
      throw new SAXException(e);
    } catch (final TokenStreamException e) {
      LOG.warn("error while creating variable", e);
      throw new SAXException(e);
    } catch (final XPathException e) {
      throw new SAXException(e);
    } finally {
      if (context != null) {
        context.reset(false);
      }
    }
  }
コード例 #17
0
 private void createSelectClauseFromFromClause(QueryNode qn) throws SemanticException {
   AST select = astFactory.create(SELECT_CLAUSE, "{derived select clause}");
   AST sibling = qn.getFromClause();
   qn.setFirstChild(select);
   select.setNextSibling(sibling);
   selectClause = (SelectClause) select;
   selectClause.initializeDerivedSelectClause(currentFromClause);
   if (log.isDebugEnabled()) {
     log.debug("Derived SELECT clause created.");
   }
 }
コード例 #18
0
  /**
   * Returns the number of child nodes one level below this node. That is is does not recurse down
   * the tree.
   *
   * @return the number of child nodes
   */
  public int getChildCount() {
    // lazy init
    if (childCount == NOT_INITIALIZED) {
      childCount = 0;
      AST child = getFirstChild();

      while (child != null) {
        childCount += 1;
        child = child.getNextSibling();
      }
    }
    return childCount;
  }
コード例 #19
0
ファイル: StructVisitor.java プロジェクト: liucong/jms4cxf2
  public void visit(AST node) {
    // <struct_type> ::= "struct" <identifier> "{" <member_list> "}"
    // <member_list> ::= <member>+
    // <member> ::= <type_spec> <declarators> ";"

    AST identifierNode = node.getFirstChild();
    // Check if its a forward declaration
    if (identifierNode.getFirstChild() == null && identifierNode.getNextSibling() == null) {
      visitForwardDeclaredStruct(identifierNode);
    } else {
      visitDeclaredStruct(identifierNode);
    }
  }
コード例 #20
0
  public AssignmentSpecification(AST eq, Queryable persister) {
    if (eq.getType() != HqlSqlTokenTypes.EQ) {
      throw new QueryException("assignment in set-clause not associated with equals");
    }

    this.eq = eq;
    this.factory = persister.getFactory();

    // Needed to bump this up to DotNode, because that is the only thing which currently
    // knows about the property-ref path in the correct format; it is either this, or
    // recurse over the DotNodes constructing the property path just like DotNode does
    // internally
    final PathSeparatorNode lhs = (PathSeparatorNode) eq.getFirstChild();
    final SqlNode rhs = (SqlNode) lhs.getNextSibling();

    validateLhs(lhs);

    final String propertyPath = lhs.getPropertyPath();
    Set<String> temp = new HashSet<String>();
    // yuck!
    if (persister instanceof UnionSubclassEntityPersister) {
      final String[] tables = persister.getConstraintOrderedTableNameClosure();
      Collections.addAll(temp, tables);
    } else {
      temp.add(
          persister.getSubclassTableName(persister.getSubclassPropertyTableNumber(propertyPath)));
    }
    this.tableNames = Collections.unmodifiableSet(temp);

    if (rhs == null) {
      hqlParameters = new ParameterSpecification[0];
    } else if (isParam(rhs)) {
      hqlParameters =
          new ParameterSpecification[] {((ParameterNode) rhs).getHqlParameterSpecification()};
    } else {
      List parameterList =
          ASTUtil.collectChildren(
              rhs,
              new ASTUtil.IncludePredicate() {
                public boolean include(AST node) {
                  return isParam(node);
                }
              });
      hqlParameters = new ParameterSpecification[parameterList.size()];
      Iterator itr = parameterList.iterator();
      int i = 0;
      while (itr.hasNext()) {
        hqlParameters[i++] = ((ParameterNode) itr.next()).getHqlParameterSpecification();
      }
    }
  }
コード例 #21
0
  public final void expr(AST _t) throws RecognitionException {

    AST expr_AST_in = (_t == ASTNULL) ? null : (AST) _t;

    if (_t == null) _t = ASTNULL;
    switch (_t.getType()) {
      case IDENTIFIER:
      case INT:
      case FLOAT:
        {
          operand(_t);
          _t = _retTree;
          break;
        }
      case PLUS:
        {
          AST __t64 = _t;
          AST tmp7_AST_in = (AST) _t;
          match(_t, PLUS);
          _t = _t.getFirstChild();
          expr(_t);
          _t = _retTree;
          expr(_t);
          _t = _retTree;
          _t = __t64;
          _t = _t.getNextSibling();
          break;
        }
      case MINUS:
        {
          AST __t65 = _t;
          AST tmp8_AST_in = (AST) _t;
          match(_t, MINUS);
          _t = _t.getFirstChild();
          expr(_t);
          _t = _retTree;
          expr(_t);
          _t = _retTree;
          _t = __t65;
          _t = _t.getNextSibling();
          break;
        }
      default:
        {
          throw new NoViableAltException(_t);
        }
    }
    _retTree = _t;
  }
コード例 #22
0
  private AST generateSyntheticDotNodeForNonQualifiedPropertyRef(
      AST property, FromElement fromElement) {
    AST dot = getASTFactory().create(DOT, "{non-qualified-property-ref}");
    // TODO : better way?!?
    ((DotNode) dot).setPropertyPath(((FromReferenceNode) property).getPath());

    IdentNode syntheticAlias = (IdentNode) getASTFactory().create(IDENT, "{synthetic-alias}");
    syntheticAlias.setFromElement(fromElement);
    syntheticAlias.setResolved();

    dot.setFirstChild(syntheticAlias);
    dot.addChild(property);

    return dot;
  }
コード例 #23
0
 public void beginRoot(AST rootNode) {
   findAllPackageNames(rootNode, allPackageNames);
   setPackageName(rootNode.getFirstChild());
   openOutputFile(dir, "__XmlDumper.java");
   String result = dumperTmpl.generate(this);
   out.print(result);
 }
コード例 #24
0
ファイル: TypeDclVisitor.java プロジェクト: liucong/jms4cxf2
  public void visit(AST node) {
    // <type_dcl> ::= "typedef" <type_declarator>
    //              | <struct_type>
    //              | <union_type>
    //              | <enum_type>
    //              | "native" <simple_declarator>
    //              | <constr_forward_decl>

    Visitor visitor = null;

    if (TypedefVisitor.accept(node)) {
      // "typedef" <type_declarator>
      visitor = new TypedefVisitor(getScope(), definition, schema, wsdlVisitor);
    } else if (StructVisitor.accept(node)) {
      // <struct_type>
      visitor = new StructVisitor(getScope(), definition, schema, wsdlVisitor);
    } else if (UnionVisitor.accept(node)) {
      // <union_type>
      visitor = new UnionVisitor(getScope(), definition, schema, wsdlVisitor);
    } else if (EnumVisitor.accept(node)) {
      // <enum_type>
      visitor = new EnumVisitor(getScope(), definition, schema, wsdlVisitor);
    } else if (node.getType() == IDLTokenTypes.LITERAL_native) {
      // "native" <simple_declarator>
      //
      // native type not supported
      throw new RuntimeException("[TypeDclVisitor: native type not supported!]");
    }

    // TODO forward declaration <constr_forward_declaration>

    visitor.visit(node);
  }
コード例 #25
0
 private AST createFromElement(String text) {
   AST ast =
       ASTUtil.create(
           fromClause.getASTFactory(),
           implied
               ? IMPLIED_FROM
               : FROM_FRAGMENT, // This causes the factory to instantiate the desired class.
           text);
   // Reset the node type, because the rest of the system is expecting FROM_FRAGMENT, all we wanted
   // was
   // for the factory to create the right sub-class.  This might get reset again later on anyway to
   // make the
   // SQL generation simpler.
   ast.setType(FROM_FRAGMENT);
   return ast;
 }
コード例 #26
0
ファイル: FromClause.java プロジェクト: rocky-bgta/JARS
 /**
  * Adds a new from element to the from node.
  *
  * @param path The reference to the class.
  * @param alias The alias AST.
  * @return FromElement - The new FROM element.
  */
 public FromElement addFromElement(String path, AST alias) throws SemanticException {
   // The path may be a reference to an alias defined in the parent query.
   String classAlias = (alias == null) ? null : alias.getText();
   checkForDuplicateClassAlias(classAlias);
   FromElementFactory factory = new FromElementFactory(this, null, path, classAlias, null, false);
   return factory.addFromElement();
 }
コード例 #27
0
 protected AST createFromFilterElement(AST filterEntity, AST alias) throws SemanticException {
   FromElement fromElement = currentFromClause.addFromElement(filterEntity.getText(), alias);
   FromClause fromClause = fromElement.getFromClause();
   QueryableCollection persister =
       sessionFactoryHelper.getCollectionPersister(filterCollectionRole);
   // Get the names of the columns used to link between the collection
   // owner and the collection elements.
   String[] keyColumnNames = persister.getKeyColumnNames();
   String fkTableAlias =
       persister.isOneToMany()
           ? fromElement.getTableAlias()
           : fromClause.getAliasGenerator().createName(filterCollectionRole);
   JoinSequence join = sessionFactoryHelper.createJoinSequence();
   join.setRoot(persister, fkTableAlias);
   if (!persister.isOneToMany()) {
     join.addJoin(
         (AssociationType) persister.getElementType(),
         fromElement.getTableAlias(),
         JoinFragment.INNER_JOIN,
         persister.getElementColumnNames(fkTableAlias));
   }
   join.addCondition(fkTableAlias, keyColumnNames, " = ?");
   fromElement.setJoinSequence(join);
   fromElement.setFilter(true);
   if (log.isDebugEnabled()) {
     log.debug("createFromFilterElement() : processed filter FROM element.");
   }
   return fromElement;
 }
コード例 #28
0
ファイル: UnionVisitor.java プロジェクト: liucong/jms4cxf2
  private void removeRecursiveScopedName(AST identifierNode) {
    String structName = identifierNode.toString();
    Scope structScope = new Scope(getScope(), structName);

    ScopeNameCollection scopedNames = wsdlVisitor.getScopedNames();
    scopedNames.remove(structScope);
  }
コード例 #29
0
  public ReturnNode(AST statement) {
    super(statement, RETURN);
    _expression = statement.getFirstChild();

    if (_expression != null) {
      _statementInfo = new StatementInfo(this, _expression);
    }
  }
コード例 #30
0
  protected void prepareVersioned(AST updateNode, AST versioned) throws SemanticException {
    UpdateStatement updateStatement = (UpdateStatement) updateNode;
    FromClause fromClause = updateStatement.getFromClause();
    if (versioned != null) {
      // Make sure that the persister is versioned
      Queryable persister = fromClause.getFromElement().getQueryable();
      if (!persister.isVersioned()) {
        throw new SemanticException(
            "increment option specified for update of non-versioned entity");
      }

      VersionType versionType = persister.getVersionType();
      if (versionType instanceof UserVersionType) {
        throw new SemanticException(
            "user-defined version types not supported for increment option");
      }

      AST eq = getASTFactory().create(HqlSqlTokenTypes.EQ, "=");
      AST versionPropertyNode = generateVersionPropertyNode(persister);

      eq.setFirstChild(versionPropertyNode);

      AST versionIncrementNode = null;
      if (Date.class.isAssignableFrom(versionType.getReturnedClass())) {
        versionIncrementNode = getASTFactory().create(HqlSqlTokenTypes.PARAM, "?");
        ParameterSpecification paramSpec = new VersionTypeSeedParameterSpecification(versionType);
        ((ParameterNode) versionIncrementNode).setHqlParameterSpecification(paramSpec);
        parameters.add(0, paramSpec);
      } else {
        // Not possible to simply re-use the versionPropertyNode here as it causes
        // OOM errors due to circularity :(
        versionIncrementNode = getASTFactory().create(HqlSqlTokenTypes.PLUS, "+");
        versionIncrementNode.setFirstChild(generateVersionPropertyNode(persister));
        versionIncrementNode.addChild(getASTFactory().create(HqlSqlTokenTypes.IDENT, "1"));
      }

      eq.addChild(versionIncrementNode);

      evaluateAssignment(eq, persister, 0);

      AST setClause = updateStatement.getSetClause();
      AST currentFirstSetElement = setClause.getFirstChild();
      setClause.setFirstChild(eq);
      eq.setNextSibling(currentFirstSetElement);
    }
  }