Package org.apache.groovy.ginq.dsl

# Class GinqAstBuilder

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.apache.groovy.ginq.dsl.GinqAstBuilder

All Implemented Interfaces:
  `SyntaxErrorReportable`, `GroovyCodeVisitor`

public class GinqAstBuilder extends CodeVisitorSupport implements SyntaxErrorReportable
Build the AST for GINQ

Since:
  4.0.0

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `GINQ_SELECT_DISTINCT`
  Metadata key marking `select distinct`.
  `static final String`
  `ROOT_GINQ_EXPRESSION`
  Metadata key storing the root GINQ expression.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GinqAstBuilder(SourceUnit sourceUnit)`
  Creates a builder for the supplied source unit.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `AbstractGinqExpression`
  `buildAST(ASTNode astNode)`
  Builds a GINQ AST from the supplied AST node.
  `SourceUnit`
  `getSourceUnit()`
  Returns the source unit used for syntax reporting.
  `void`
  `visitArgumentlistExpression(ArgumentListExpression expression)`
  Visits argument lists and replaces nested `select` expressions with built GINQ AST nodes.
  `void`
  `visitBinaryExpression(BinaryExpression expression)`
  Visits binary expressions to wire nested GINQ expressions into filters.
  `void`
  `visitCastExpression(CastExpression expression)`
  Visits cast expressions and substitutes nested GINQ expressions when needed.
  `void`
  `visitDeclarationExpression(DeclarationExpression expression)`
  Visits declaration expressions and rejects assignments inside clause keywords.
  `void`
  `visitMethodCallExpression(MethodCallExpression call)`
  Visits method-call expressions while assembling GINQ clauses.
  `void`
  `visitPropertyExpression(PropertyExpression expression)`
  Visits property expressions and reports malformed aliases in `select`.
  `void`
  `visitVariableExpression(VariableExpression expression)`
  Visits variable expressions and validates GINQ keywords.

  ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

  `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArrayExpression, visitAssertStatement, visitAttributeExpression, visitBitwiseNegationExpression, visitBlockStatement, visitBooleanExpression, visitBreakStatement, visitBytecodeExpression, visitCaseStatement, visitCatchStatement, visitClassExpression, visitClosureExpression, visitClosureListExpression, visitConstantExpression, visitConstructorCallExpression, visitContinueStatement, visitDoWhileLoop, visitEmptyStatement, visitExpressionStatement, visitFieldExpression, visitForLoop, visitGStringExpression, visitIfElse, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitRangeExpression, visitReturnStatement, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitSwitch, visitSynchronizedStatement, visitTernaryExpression, visitThrowStatement, visitTryCatchFinally, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitWhileLoop`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor

  `visit, visit, visitEmptyExpression, visitListOfExpressions`

  ### Methods inherited from interface org.apache.groovy.ginq.dsl.SyntaxErrorReportable

  `collectSyntaxError`

- ## Field Details

  - ### ROOT_GINQ_EXPRESSION

    public static final String ROOT_GINQ_EXPRESSION
    Metadata key storing the root GINQ expression.
    See Also:
      - Constant Field Values

  - ### GINQ_SELECT_DISTINCT

    public static final String GINQ_SELECT_DISTINCT
    Metadata key marking `select distinct`.
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### GinqAstBuilder

    public GinqAstBuilder(SourceUnit sourceUnit)
    Creates a builder for the supplied source unit.
    Parameters:
      `sourceUnit` - the source unit being processed

- ## Method Details

  - ### buildAST

    public AbstractGinqExpression buildAST(ASTNode astNode)
    Builds a GINQ AST from the supplied AST node.
    Parameters:
      `astNode` - the node containing GINQ code
    Returns:
      the built GINQ expression

  - ### visitMethodCallExpression

    public void visitMethodCallExpression(MethodCallExpression call)
    Visits method-call expressions while assembling GINQ clauses.
    Specified by:
      `visitMethodCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitMethodCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `call` - the method call to visit

  - ### visitBinaryExpression

    public void visitBinaryExpression(BinaryExpression expression)
    Visits binary expressions to wire nested GINQ expressions into filters.
    Specified by:
      `visitBinaryExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitBinaryExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the expression to visit

  - ### visitVariableExpression

    public void visitVariableExpression(VariableExpression expression)
    Visits variable expressions and validates GINQ keywords.
    Specified by:
      `visitVariableExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitVariableExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the expression to visit

  - ### visitPropertyExpression

    public void visitPropertyExpression(PropertyExpression expression)
    Visits property expressions and reports malformed aliases in `select`.
    Specified by:
      `visitPropertyExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitPropertyExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the expression to visit

  - ### visitDeclarationExpression

    public void visitDeclarationExpression(DeclarationExpression expression)
    Visits declaration expressions and rejects assignments inside clause keywords.
    Specified by:
      `visitDeclarationExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitDeclarationExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the expression to visit

  - ### visitCastExpression

    public void visitCastExpression(CastExpression expression)
    Visits cast expressions and substitutes nested GINQ expressions when needed.
    Specified by:
      `visitCastExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCastExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the expression to visit

  - ### visitArgumentlistExpression

    public void visitArgumentlistExpression(ArgumentListExpression expression)
    Visits argument lists and replaces nested `select` expressions with built GINQ AST nodes.
    Specified by:
      `visitArgumentlistExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitArgumentlistExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the expression to visit

  - ### getSourceUnit

    public SourceUnit getSourceUnit()
    Returns the source unit used for syntax reporting.
    Specified by:
      `getSourceUnit` in interface `SyntaxErrorReportable`
    Returns:
      the current source unit