Spanned

Trait Spanned 

pub trait Spanned {
    // Required method
    fn span(&self) -> Span;
}
Expand description

Trait for AST nodes that have a source location information.

§Notes:

Source Span are not yet complete. They may be missing:

  1. keywords or other tokens
  2. span information entirely, in which case they return Span::empty().

Note Some impl blocks (rendered below) are annotated with which nodes are missing spans. See this ticket for additional information and status.

§Example

let dialect = GenericDialect {};
let sql = r#"SELECT *
  FROM table_1"#;
let statements = Parser::new(&dialect)
  .try_with_sql(sql)?
  .parse_statements()?;
// Get the span of the first statement (SELECT)
let span = statements[0].span();
// statement starts at line 1, column 1 (1 based, not 0 based)
assert_eq!(span.start, Location::new(1, 1));
// statement ends on line 2, column 15
assert_eq!(span.end, Location::new(2, 15));

Required Methods§

fn span(&self) -> Span

Return the Span (the minimum and maximum Location) for this AST node, by recursively combining the spans of its children.

Implementors§

§

impl Spanned for AccessExpr

§

impl Spanned for AlterColumnOperation

§partial span

Missing spans:

§

impl Spanned for AlterIndexOperation

§

impl Spanned for AlterSchemaOperation

§

impl Spanned for AlterTableOperation

§partial span

Missing spans:

§

impl Spanned for AssignmentTarget

§

impl Spanned for ColumnOption

§partial span

Missing spans:

§

impl Spanned for ColumnOptions

§

impl Spanned for ConditionalStatements

§

impl Spanned for ConflictTarget

§

impl Spanned for CopySource

§

impl Spanned for CreateTableOptions

§

impl Spanned for ExcludeSelectItem

§

impl Spanned for Expr

§partial span

Most expressions are missing keywords in their spans. f.e. IS NULL <expr> reports as <expr>::span.

Missing spans:

§

impl Spanned for FromTable

§

impl Spanned for FunctionArg

§

impl Spanned for FunctionArgExpr

§partial span

Missing spans:

§

impl Spanned for FunctionArgumentClause

§

impl Spanned for FunctionArguments

§partial span

The span of FunctionArguments::None is empty.

§

impl Spanned for GroupByExpr

§partial span

Missing spans:

§

impl Spanned for JoinConstraint

§partial span

Missing spans:

§

impl Spanned for JoinOperator

§partial span

Missing spans:

§

impl Spanned for JsonPathElem

§partial span

Missing spans:

§

impl Spanned for LimitClause

§

impl Spanned for MatchRecognizePattern

§missing span

§

impl Spanned for ObjectNamePart

§

impl Spanned for OnConflictAction

§partial span

Missing spans:

§

impl Spanned for OnInsert

§

impl Spanned for Partition

§

impl Spanned for PivotValueSource

§

impl Spanned for RaiseStatementValue

§

impl Spanned for ReferentialAction

§missing span

§

impl Spanned for RenameSelectItem

§

impl Spanned for RenameTableNameKind

§

impl Spanned for SelectItem

§

impl Spanned for SelectItemQualifiedWildcardKind

§

impl Spanned for SetExpr

§partial span

SetExpr::Table is not implemented.

§

impl Spanned for SqlOption

§

impl Spanned for Statement

§partial span

Missing spans:

§

impl Spanned for Subscript

§

impl Spanned for TableConstraint

§

impl Spanned for TableFactor

§partial span

Missing spans:

§

impl Spanned for TableObject

§

impl Spanned for TableOptionsClustered

§partial span

Missing spans:

§

impl Spanned for UpdateTableFromKind

§

impl Spanned for Use

§

impl Spanned for Value

The span is stored in the ValueWrapper struct

§

impl Spanned for AlterSchema

§

impl Spanned for Array

§

impl Spanned for Assignment

§

impl Spanned for BeginEndStatements

§

impl Spanned for CaseStatement

§

impl Spanned for ClusteredIndex

§

impl Spanned for ColumnDef

§

impl Spanned for ColumnOptionDef

§

impl Spanned for ConditionalStatementBlock

§

impl Spanned for ConnectBy

§

impl Spanned for ConstraintCharacteristics

§missing span

§

impl Spanned for CreateIndex

§

impl Spanned for CreateTable

§

impl Spanned for Cte

§

impl Spanned for Delete

§

impl Spanned for DoUpdate

§

impl Spanned for ExceptSelectItem

§

impl Spanned for ExprWithAlias

§

impl Spanned for Fetch

§

impl Spanned for Function

§

impl Spanned for FunctionArgumentList

§

impl Spanned for IfStatement

§

impl Spanned for IlikeSelectItem

§missing span

§

impl Spanned for IndexColumn

§

impl Spanned for Insert

§partial span

Missing spans:ever

§

impl Spanned for Interpolate

§

impl Spanned for InterpolateExpr

§

impl Spanned for Join

§

impl Spanned for JsonPath

§partial span

see Spanned impl for JsonPathElem for more information

§

impl Spanned for LateralView

§

impl Spanned for Measure

§

impl Spanned for NamedWindowDefinition

§

impl Spanned for ObjectName

§

impl Spanned for Offset

§

impl Spanned for OnConflict

§

impl Spanned for OpenStatement

§

impl Spanned for OrderBy

§partial span

Missing spans:

§

impl Spanned for OrderByExpr

§

impl Spanned for ProjectionSelect

§

impl Spanned for Query

§

impl Spanned for RaiseStatement

§

impl Spanned for ReplaceSelectElement

§

impl Spanned for ReplaceSelectItem

§

impl Spanned for Select

§

impl Spanned for SelectInto

§

impl Spanned for SymbolDefinition

§

impl Spanned for TableAlias

§

impl Spanned for TableAliasColumnDef

§

impl Spanned for TableWithJoins

§

impl Spanned for ValueWithSpan

§

impl Spanned for Values

§

impl Spanned for ViewColumnDef

§

impl Spanned for WhileStatement

§

impl Spanned for WildcardAdditionalOptions

§

impl Spanned for With

§

impl Spanned for WithFill