Skip to content

Commit 6f05bcf

Browse files
committed
implement spanned for ObjectNamePart
1 parent a77b1ea commit 6f05bcf

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/ast/spans.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use super::{
1111
FunctionArgumentClause, FunctionArgumentList, FunctionArguments, GroupByExpr, HavingBound,
1212
IlikeSelectItem, Insert, Interpolate, InterpolateExpr, Join, JoinConstraint, JoinOperator,
1313
JsonPath, JsonPathElem, LateralView, MatchRecognizePattern, Measure, NamedWindowDefinition,
14-
ObjectName, Offset, OnConflict, OnConflictAction, OnInsert, OrderBy, OrderByExpr, Partition,
14+
ObjectName, ObjectNamePart, Offset, OnConflict, OnConflictAction, OnInsert, OrderBy, OrderByExpr, Partition,
1515
PivotValueSource, ProjectionSelect, Query, ReferentialAction, RenameSelectItem,
1616
ReplaceSelectElement, ReplaceSelectItem, Select, SelectInto, SelectItem, SetExpr, SqlOption,
1717
Statement, Subscript, SymbolDefinition, TableAlias, TableAliasColumnDef, TableConstraint,
@@ -1302,7 +1302,7 @@ impl Spanned for Expr {
13021302
.union_opt(&overlay_for.as_ref().map(|i| i.span())),
13031303
Expr::Collate { expr, collation } => expr
13041304
.span()
1305-
.union(&union_spans(collation.0.iter().map(|i| i.span))),
1305+
.union(&union_spans(collation.0.iter().map(|i| i.span()))),
13061306
Expr::Nested(expr) => expr.span(),
13071307
Expr::Value(value) => value.span(),
13081308
Expr::TypedString { .. } => Span::empty(),
@@ -1411,7 +1411,7 @@ impl Spanned for Expr {
14111411
object_name
14121412
.0
14131413
.iter()
1414-
.map(|i| i.span)
1414+
.map(|i| i.span())
14151415
.chain(iter::once(token.0.span)),
14161416
),
14171417
Expr::OuterJoin(expr) => expr.span(),
@@ -1447,7 +1447,15 @@ impl Spanned for ObjectName {
14471447
fn span(&self) -> Span {
14481448
let ObjectName(segments) = self;
14491449

1450-
union_spans(segments.iter().map(|i| i.span))
1450+
union_spans(segments.iter().map(|i| i.span()))
1451+
}
1452+
}
1453+
1454+
impl Spanned for ObjectNamePart {
1455+
fn span(&self) -> Span {
1456+
match self {
1457+
ObjectNamePart::Identifier(ident) => ident.span,
1458+
}
14511459
}
14521460
}
14531461

@@ -1477,7 +1485,7 @@ impl Spanned for Function {
14771485
union_spans(
14781486
name.0
14791487
.iter()
1480-
.map(|i| i.span)
1488+
.map(|i| i.span())
14811489
.chain(iter::once(args.span()))
14821490
.chain(iter::once(parameters.span()))
14831491
.chain(filter.iter().map(|i| i.span()))
@@ -1563,7 +1571,7 @@ impl Spanned for SelectItem {
15631571
object_name
15641572
.0
15651573
.iter()
1566-
.map(|i| i.span)
1574+
.map(|i| i.span())
15671575
.chain(iter::once(wildcard_additional_options.span())),
15681576
),
15691577
SelectItem::Wildcard(wildcard_additional_options) => wildcard_additional_options.span(),
@@ -1672,7 +1680,7 @@ impl Spanned for TableFactor {
16721680
} => union_spans(
16731681
name.0
16741682
.iter()
1675-
.map(|i| i.span)
1683+
.map(|i| i.span())
16761684
.chain(alias.as_ref().map(|alias| {
16771685
union_spans(
16781686
iter::once(alias.name.span)
@@ -1717,7 +1725,7 @@ impl Spanned for TableFactor {
17171725
} => union_spans(
17181726
name.0
17191727
.iter()
1720-
.map(|i| i.span)
1728+
.map(|i| i.span())
17211729
.chain(args.iter().map(|i| i.span()))
17221730
.chain(alias.as_ref().map(|alias| alias.span())),
17231731
),
@@ -1868,7 +1876,7 @@ impl Spanned for FunctionArgExpr {
18681876
match self {
18691877
FunctionArgExpr::Expr(expr) => expr.span(),
18701878
FunctionArgExpr::QualifiedWildcard(object_name) => {
1871-
union_spans(object_name.0.iter().map(|i| i.span))
1879+
union_spans(object_name.0.iter().map(|i| i.span()))
18721880
}
18731881
FunctionArgExpr::Wildcard => Span::empty(),
18741882
}

0 commit comments

Comments
 (0)