本文整理汇总了Java中antlr.collections.AST.setNextSibling方法的典型用法代码示例。如果您正苦于以下问题:Java AST.setNextSibling方法的具体用法?Java AST.setNextSibling怎么用?Java AST.setNextSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类antlr.collections.AST
的用法示例。
在下文中一共展示了AST.setNextSibling方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getOrderByClause
import antlr.collections.AST; //导入方法依赖的package包/类
public final OrderByClause getOrderByClause() {
if ( orderByClause == null ) {
orderByClause = locateOrderByClause();
// if there is no order by, make one
if ( orderByClause == null ) {
LOG.debug( "getOrderByClause() : Creating a new ORDER BY clause" );
orderByClause = (OrderByClause) getWalker().getASTFactory().create( SqlTokenTypes.ORDER, "ORDER" );
// Find the WHERE; if there is no WHERE, find the FROM...
AST prevSibling = ASTUtil.findTypeInChildren( this, SqlTokenTypes.WHERE );
if ( prevSibling == null ) {
prevSibling = ASTUtil.findTypeInChildren( this, SqlTokenTypes.FROM );
}
// Now, inject the newly built ORDER BY into the tree
orderByClause.setNextSibling( prevSibling.getNextSibling() );
prevSibling.setNextSibling( orderByClause );
}
}
return orderByClause;
}
示例2: getWhereClause
import antlr.collections.AST; //导入方法依赖的package包/类
@Override
public final AST getWhereClause() {
if ( whereClause == null ) {
whereClause = locateWhereClause();
// If there is no WHERE node, make one.
if ( whereClause == null ) {
getLog().debug( "getWhereClause() : Creating a new WHERE clause..." );
whereClause = getWalker().getASTFactory().create( HqlSqlTokenTypes.WHERE, "WHERE" );
// inject the WHERE after the parent
AST parent = ASTUtil.findTypeInChildren( this, getWhereClauseParentTokenType() );
whereClause.setNextSibling( parent.getNextSibling() );
parent.setNextSibling( whereClause );
}
}
return whereClause;
}
示例3: mutateRowValueConstructorSyntax
import antlr.collections.AST; //导入方法依赖的package包/类
private void mutateRowValueConstructorSyntax(int operandColumnSpan) {
final int comparisonType = getType();
final String comparisonText = getText();
final int expansionConnectorType = getExpansionConnectorType();
final String expansionConnectorText = getExpansionConnectorText();
setType( expansionConnectorType );
setText( expansionConnectorText );
String[] mutationTexts = extractMutationTexts( getOperand(), operandColumnSpan );
AST container = this;
for ( int i = operandColumnSpan - 1; i > 0; i-- ) {
if ( i == 1 ) {
AST op1 = getASTFactory().create( comparisonType, comparisonText );
AST operand1 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[0] );
op1.setFirstChild( operand1 );
container.setFirstChild( op1 );
AST op2 = getASTFactory().create( comparisonType, comparisonText );
AST operand2 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[1] );
op2.setFirstChild( operand2 );
op1.setNextSibling( op2 );
}
else {
AST op = getASTFactory().create( comparisonType, comparisonText );
AST operand = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, mutationTexts[i] );
op.setFirstChild( operand );
AST newContainer = getASTFactory().create( expansionConnectorType, expansionConnectorText );
container.setFirstChild( newContainer );
newContainer.setNextSibling( op );
container = newContainer;
}
}
}
示例4: makeSiblingOfParent
import antlr.collections.AST; //导入方法依赖的package包/类
/**
* Makes the child node a sibling of the parent, reconnecting all siblings.
*
* @param parent the parent
* @param child the child
*/
public static void makeSiblingOfParent(AST parent, AST child) {
AST prev = findPreviousSibling( parent, child );
if ( prev != null ) {
prev.setNextSibling( child.getNextSibling() );
}
else { // child == parent.getFirstChild()
parent.setFirstChild( child.getNextSibling() );
}
child.setNextSibling( parent.getNextSibling() );
parent.setNextSibling( child );
}
示例5: insertChild
import antlr.collections.AST; //导入方法依赖的package包/类
/**
* Inserts the child as the first child of the parent, all other children are shifted over to the 'right'.
*
* @param parent the parent
* @param child the new first child
*/
public static void insertChild(AST parent, AST child) {
if ( parent.getFirstChild() == null ) {
parent.setFirstChild( child );
}
else {
AST n = parent.getFirstChild();
parent.setFirstChild( child );
child.setNextSibling( n );
}
}
示例6: createSelectClauseFromFromClause
import antlr.collections.AST; //导入方法依赖的package包/类
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 );
LOG.debug( "Derived SELECT clause created." );
}
示例7: processIsEmpty
import antlr.collections.AST; //导入方法依赖的package包/类
private AST processIsEmpty(AST node, boolean negated) {
node.setNextSibling( null );
// NOTE: Because we're using ASTUtil.createParent(), the tree must be created from the bottom up.
// IS EMPTY x => (EXISTS (QUERY (SELECT_FROM (FROM x) ) ) )
AST ast = createSubquery( node );
ast = ASTUtil.createParent( astFactory, EXISTS, "exists", ast );
// Add NOT if it's negated.
if ( !negated ) {
ast = ASTUtil.createParent( astFactory, NOT, "not", ast );
}
return ast;
}
示例8: dupList
import antlr.collections.AST; //导入方法依赖的package包/类
/** Duplicate tree including siblings of root. */
public AST dupList(AST t) {
AST result = dupTree(t); // if t == null, then result==null
AST nt = result;
while (t != null) { // for each sibling of the root
t = t.getNextSibling();
nt.setNextSibling(dupTree(t)); // dup each subtree, building new tree
nt = nt.getNextSibling();
}
return result;
}
示例9: make
import antlr.collections.AST; //导入方法依赖的package包/类
/** Make a tree from a list of nodes. The first element in the
* array is the root. If the root is null, then the tree is
* a simple list not a tree. Handles null children nodes correctly.
* For example, build(a, b, null, c) yields tree (a b c). build(null,a,b)
* yields tree (nil a b).
*/
public AST make(AST[] nodes) {
if (nodes == null || nodes.length == 0) return null;
AST root = nodes[0];
AST tail = null;
if (root != null) {
root.setFirstChild(null); // don't leave any old pointers set
}
// link in children;
for (int i = 1; i < nodes.length; i++) {
if (nodes[i] == null) continue; // ignore null nodes
if (root == null) {
// Set the root and set it up for a flat list
root = tail = nodes[i];
}
else if (tail == null) {
root.setFirstChild(nodes[i]);
tail = root.getFirstChild();
}
else {
tail.setNextSibling(nodes[i]);
tail = tail.getNextSibling();
}
// Chase tail to last sibling
while (tail.getNextSibling() != null) {
tail = tail.getNextSibling();
}
}
return root;
}
示例10: translate
import antlr.collections.AST; //导入方法依赖的package包/类
protected void translate(
int valueElements, int comparisonType,
String comparisonText, String[] lhsElementTexts,
String[] rhsElementTexts,
ParameterSpecification lhsEmbeddedCompositeParameterSpecification,
ParameterSpecification rhsEmbeddedCompositeParameterSpecification,
AST container) {
for ( int i = valueElements - 1; i > 0; i-- ) {
if ( i == 1 ) {
AST op1 = getASTFactory().create( comparisonType, comparisonText );
AST lhs1 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[0] );
AST rhs1 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[0] );
op1.setFirstChild( lhs1 );
lhs1.setNextSibling( rhs1 );
container.setFirstChild( op1 );
AST op2 = getASTFactory().create( comparisonType, comparisonText );
AST lhs2 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[1] );
AST rhs2 = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[1] );
op2.setFirstChild( lhs2 );
lhs2.setNextSibling( rhs2 );
op1.setNextSibling( op2 );
// "pass along" our initial embedded parameter node(s) to the first generated
// sql fragment so that it can be handled later for parameter binding...
SqlFragment fragment = (SqlFragment) lhs1;
if ( lhsEmbeddedCompositeParameterSpecification != null ) {
fragment.addEmbeddedParameter( lhsEmbeddedCompositeParameterSpecification );
}
if ( rhsEmbeddedCompositeParameterSpecification != null ) {
fragment.addEmbeddedParameter( rhsEmbeddedCompositeParameterSpecification );
}
}
else {
AST op = getASTFactory().create( comparisonType, comparisonText );
AST lhs = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, lhsElementTexts[i] );
AST rhs = getASTFactory().create( HqlSqlTokenTypes.SQL_TOKEN, rhsElementTexts[i] );
op.setFirstChild( lhs );
lhs.setNextSibling( rhs );
AST newContainer = getASTFactory().create( HqlSqlTokenTypes.AND, "AND" );
container.setFirstChild( newContainer );
newContainer.setNextSibling( op );
container = newContainer;
}
}
}
示例11: appendSibling
import antlr.collections.AST; //导入方法依赖的package包/类
public static void appendSibling(AST n, AST s) {
while ( n.getNextSibling() != null ) {
n = n.getNextSibling();
}
n.setNextSibling( s );
}
示例12: prepareVersioned
import antlr.collections.AST; //导入方法依赖的package包/类
@Override
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 ( isTimestampBasedVersion( versionType ) ) {
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 );
}
}
示例13: createIsNullParent
import antlr.collections.AST; //导入方法依赖的package包/类
private AST createIsNullParent(AST node, boolean negated) {
node.setNextSibling( null );
int type = negated ? IS_NOT_NULL : IS_NULL;
String text = negated ? "is not null" : "is null";
return ASTUtil.createParent( astFactory, type, text, node );
}
示例14: insertSibling
import antlr.collections.AST; //导入方法依赖的package包/类
/**
* Inserts a node into a child subtree as a particularly positioned
* sibling taking care to properly reorganize the tree to account for this
* new addition.
*
* @param node The node to insert
* @param prevSibling The previous node at the sibling position
* where we want this node inserted.
*
* @return The return is the same as the node parameter passed in.
*/
public static AST insertSibling(AST node, AST prevSibling) {
node.setNextSibling( prevSibling.getNextSibling() );
prevSibling.setNextSibling( node );
return node;
}