Skip to content

Commit b35cd68

Browse files
committed
implement spanned for ObjectNamePart
1 parent fe05be7 commit b35cd68

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

src/ast/spans.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ use super::{
2828
FunctionArg, FunctionArgExpr, FunctionArgumentClause, FunctionArgumentList, FunctionArguments,
2929
GroupByExpr, HavingBound, IlikeSelectItem, Insert, Interpolate, InterpolateExpr, Join,
3030
JoinConstraint, JoinOperator, JsonPath, JsonPathElem, LateralView, MatchRecognizePattern,
31-
Measure, NamedWindowDefinition, ObjectName, Offset, OnConflict, OnConflictAction, OnInsert,
32-
OrderBy, OrderByExpr, Partition, PivotValueSource, ProjectionSelect, Query, ReferentialAction,
31+
Measure, NamedWindowDefinition, ObjectName, ObjectNamePart, Offset, OnConflict, OnConflictAction, OnInsert, OrderBy,
32+
OrderByExpr, Partition, PivotValueSource, ProjectionSelect, Query, ReferentialAction,
3333
RenameSelectItem, ReplaceSelectElement, ReplaceSelectItem, Select, SelectInto, SelectItem,
3434
SetExpr, SqlOption, Statement, Subscript, SymbolDefinition, TableAlias, TableAliasColumnDef,
3535
TableConstraint, TableFactor, TableObject, TableOptionsClustered, TableWithJoins,
36-
UpdateTableFromKind, Use, Value, Values, ViewColumnDef, WildcardAdditionalOptions, With,
37-
WithFill,
36+
UpdateTableFromKind, Use, Value, Values,
37+
ViewColumnDef, WildcardAdditionalOptions, With, WithFill,
3838
};
3939

4040
/// Given an iterator of spans, return the [Span::union] of all spans.
@@ -1358,7 +1358,7 @@ impl Spanned for Expr {
13581358
.union_opt(&overlay_for.as_ref().map(|i| i.span())),
13591359
Expr::Collate { expr, collation } => expr
13601360
.span()
1361-
.union(&union_spans(collation.0.iter().map(|i| i.span))),
1361+
.union(&union_spans(collation.0.iter().map(|i| i.span()))),
13621362
Expr::Nested(expr) => expr.span(),
13631363
Expr::Value(value) => value.span(),
13641364
Expr::TypedString { .. } => Span::empty(),
@@ -1462,7 +1462,7 @@ impl Spanned for Expr {
14621462
object_name
14631463
.0
14641464
.iter()
1465-
.map(|i| i.span)
1465+
.map(|i| i.span())
14661466
.chain(iter::once(token.0.span)),
14671467
),
14681468
Expr::OuterJoin(expr) => expr.span(),
@@ -1507,7 +1507,15 @@ impl Spanned for ObjectName {
15071507
fn span(&self) -> Span {
15081508
let ObjectName(segments) = self;
15091509

1510-
union_spans(segments.iter().map(|i| i.span))
1510+
union_spans(segments.iter().map(|i| i.span()))
1511+
}
1512+
}
1513+
1514+
impl Spanned for ObjectNamePart {
1515+
fn span(&self) -> Span {
1516+
match self {
1517+
ObjectNamePart::Identifier(ident) => ident.span,
1518+
}
15111519
}
15121520
}
15131521

@@ -1538,7 +1546,7 @@ impl Spanned for Function {
15381546
union_spans(
15391547
name.0
15401548
.iter()
1541-
.map(|i| i.span)
1549+
.map(|i| i.span())
15421550
.chain(iter::once(args.span()))
15431551
.chain(iter::once(parameters.span()))
15441552
.chain(filter.iter().map(|i| i.span()))
@@ -1624,7 +1632,7 @@ impl Spanned for SelectItem {
16241632
object_name
16251633
.0
16261634
.iter()
1627-
.map(|i| i.span)
1635+
.map(|i| i.span())
16281636
.chain(iter::once(wildcard_additional_options.span())),
16291637
),
16301638
SelectItem::Wildcard(wildcard_additional_options) => wildcard_additional_options.span(),
@@ -1734,7 +1742,7 @@ impl Spanned for TableFactor {
17341742
} => union_spans(
17351743
name.0
17361744
.iter()
1737-
.map(|i| i.span)
1745+
.map(|i| i.span())
17381746
.chain(alias.as_ref().map(|alias| {
17391747
union_spans(
17401748
iter::once(alias.name.span)
@@ -1779,7 +1787,7 @@ impl Spanned for TableFactor {
17791787
} => union_spans(
17801788
name.0
17811789
.iter()
1782-
.map(|i| i.span)
1790+
.map(|i| i.span())
17831791
.chain(args.iter().map(|i| i.span()))
17841792
.chain(alias.as_ref().map(|alias| alias.span())),
17851793
),
@@ -1930,7 +1938,7 @@ impl Spanned for FunctionArgExpr {
19301938
match self {
19311939
FunctionArgExpr::Expr(expr) => expr.span(),
19321940
FunctionArgExpr::QualifiedWildcard(object_name) => {
1933-
union_spans(object_name.0.iter().map(|i| i.span))
1941+
union_spans(object_name.0.iter().map(|i| i.span()))
19341942
}
19351943
FunctionArgExpr::Wildcard => Span::empty(),
19361944
}

0 commit comments

Comments
 (0)