file

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTableNameFromTablePathExpressionNode

func CreateTableNameFromTablePathExpressionNode(node *googlesql.ASTTablePathExpression) (string, bool)

func ListAstNode

func ListAstNode[T googlesql.ASTNode](n *googlesql.ASTScript) []T

func ListResolvedAstNode

func ListResolvedAstNode[T googlesql.ResolvedNode](output *googlesql.AnalyzerOutput) []T

func LookupNode

func LookupNode[T astNode](n googlesql.ASTNode) (T, bool)

func ParseLocEnd added in v0.5.0

func ParseLocEnd(loc *googlesql.ParseLocationRange) int

func ParseLocStart added in v0.5.0

func ParseLocStart(loc *googlesql.ParseLocationRange) int

ParseLocStart/End are exported wrappers for use from other packages.

func SearchAstNode

func SearchAstNode[T googlesql.ASTNode](node googlesql.ASTNode, termOffset int) (T, bool)

func SearchResolvedAstNode

func SearchResolvedAstNode[T googlesql.ResolvedNode](output *googlesql.AnalyzerOutput, termOffset int) (T, bool)

func Walk added in v0.5.0

func Walk(node googlesql.ASTNode, fn func(googlesql.ASTNode) error) error

Walk traverses an ASTNode tree in depth-first order, calling fn for each node. If fn returns an error, Walk stops and returns that error.

func WalkResolved added in v0.5.0

func WalkResolved(node googlesql.ResolvedNode, fn func(googlesql.ResolvedNode) error) error

WalkResolved traverses a ResolvedNode tree in depth-first order.

Types

type Analyzer

type Analyzer struct {
	// contains filtered or unexported fields
}

func NewAnalyzer

func NewAnalyzer(logger *logrus.Logger, bqClient bigquery.Client) *Analyzer

func (*Analyzer) AnalyzeStatement

func (a *Analyzer) AnalyzeStatement(rawText string, stmt googlesql.ASTStatementNode, catalog *Catalog) (*googlesql.AnalyzerOutput, error)

func (*Analyzer) GetTableMetadataFromPath

func (a *Analyzer) GetTableMetadataFromPath(ctx context.Context, path string) (*bq.TableMetadata, error)

func (*Analyzer) ParseFile

func (a *Analyzer) ParseFile(uri lsp.DocumentURI, src string) ParsedFile

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

func NewCatalog

func NewCatalog(bqClient bigquery.Client) *Catalog

func (*Catalog) AddFunctionWithName

func (c *Catalog) AddFunctionWithName(name string, fn *googlesql.Function)

func (*Catalog) CatalogNode added in v0.5.0

func (c *Catalog) CatalogNode() *googlesql.SimpleCatalog

CatalogNode returns the underlying SimpleCatalog which implements CatalogNode.

func (*Catalog) Clone

func (c *Catalog) Clone() *Catalog

func (*Catalog) EnsureTable added in v0.5.0

func (c *Catalog) EnsureTable(path []string) error

EnsureTable loads a table from BigQuery if not already in the catalog.

func (*Catalog) FindTableMetadata added in v0.5.0

func (c *Catalog) FindTableMetadata(path string) (*bq.TableMetadata, error)

FindTableMetadata returns the BigQuery metadata for a table path (e.g., "project.dataset.table").

func (*Catalog) PreloadTablesFromAST added in v0.5.0

func (c *Catalog) PreloadTablesFromAST(node *googlesql.ASTScript)

PreloadTablesFromAST walks the AST to find all table path expressions and pre-loads them.

func (*Catalog) TypeFactory added in v0.5.0

func (c *Catalog) TypeFactory() *googlesql.TypeFactory

TypeFactory returns the TypeFactory for creating types.

type Error

type Error struct {
	Msg                  string
	Position             lsp.Position
	TermLength           int
	IncompleteColumnName string
	Severity             lsp.DiagnosticSeverity
}

func (Error) Error

func (e Error) Error() string

type FixOffset

type FixOffset struct {
	Offset int
	Length int
}

type ParsedFile

type ParsedFile struct {
	URI lsp.DocumentURI
	Src string

	// googlesql AST node
	Node *googlesql.ASTScript
	// index is Node's statement order
	RNode []*googlesql.AnalyzerOutput

	// tree-sitter node
	TsTree *ts.Tree

	FixOffsets []FixOffset
	Errors     []Error
}

func (ParsedFile) Close added in v0.5.0

func (p ParsedFile) Close()

func (ParsedFile) ExtractSQL

func (p ParsedFile) ExtractSQL(locationRange *googlesql.ParseLocationRange) (string, bool)

func (*ParsedFile) FindIncompleteColumnName

func (p *ParsedFile) FindIncompleteColumnName(pos lsp.Position) string

func (*ParsedFile) FindTargetAnalyzeOutput

func (p *ParsedFile) FindTargetAnalyzeOutput(termOffset int) (*googlesql.AnalyzerOutput, bool)

func (ParsedFile) FindTargetStatementNode

func (p ParsedFile) FindTargetStatementNode(termOffset int) (googlesql.ASTStatementNode, bool)

func (ParsedFile) TermOffset

func (p ParsedFile) TermOffset(pos lsp.Position) int

func (ParsedFile) ToLspRange

func (p ParsedFile) ToLspRange(r *googlesql.ParseLocationRange) (lsp.Range, bool)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL