Class ScopeBuilder

Object
gudusoft.gsqlparser.nodes.TParseTreeVisitor
gudusoft.gsqlparser.resolver2.ScopeBuilder

public class ScopeBuilder extends TParseTreeVisitor
Builds a complete scope tree using the Visitor pattern.

This class traverses the AST and creates a properly nested scope tree that reflects the SQL structure. All SELECT statements (including subqueries and CTEs) get their own SelectScope with correct parent-child relationships.

Key features:

  • Handles nested subqueries with correct parent scope
  • Handles CTEs with forward reference support
  • Collects all column references with their scope mappings
  • Supports complex SQL patterns (CTE + subquery combinations)

Usage:

 ScopeBuilder builder = new ScopeBuilder(context, nameMatcher);
 ScopeBuildResult result = builder.build(statements);