Skip to content

Commit

Permalink
cue: advance deprecation of Iterator methods
Browse files Browse the repository at this point in the history
Iterator.Label had been hidden and slated for deprecation since 2021,
so it's time to formally deprecate it now.

Iterator.IsHidden and Iterator.IsDefinition have been hidden and
deprecated since 2021, so they can be removed at this point.

Signed-off-by: Daniel Martí <[email protected]>
Change-Id: I1a236ff0e26d145010f291f2e30310e2b0af0670
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202284
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Roger Peppe <[email protected]>
  • Loading branch information
mvdan committed Oct 10, 2024
1 parent 44cceca commit d170b1c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
16 changes: 1 addition & 15 deletions cue/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ func (i *Iterator) Selector() Selector {
// Label reports the label of the value if i iterates over struct fields and ""
// otherwise.
//
// Slated to be deprecated: use [Iterator.Selector] and [Selector.String].
// Deprecated: use [Iterator.Selector] and [Selector.String].
// Note that this will give more accurate string representations.
func (i *hiddenIterator) Label() string {
if i.f == 0 {
Expand All @@ -268,13 +268,6 @@ func (i *hiddenIterator) Label() string {
return i.idx.LabelStr(i.f)
}

// IsHidden reports if a field is hidden from the data model.
//
// Deprecated: use i.Selector().PkgPath() != ""
func (i *hiddenIterator) IsHidden() bool {
return i.f.IsHidden()
}

// IsOptional reports if a field is optional.
func (i *Iterator) IsOptional() bool {
return i.arcType == adt.ArcOptional
Expand All @@ -285,13 +278,6 @@ func (i *Iterator) FieldType() SelectorType {
return featureToSelType(i.f, i.arcType)
}

// IsDefinition reports if a field is a definition.
//
// Deprecated: use i.Selector().IsDefinition()
func (i *hiddenIterator) IsDefinition() bool {
return i.f.IsDef()
}

// marshalJSON iterates over the list and generates JSON output. HasNext
// will return false after this operation.
func listAppendJSON(b []byte, l *Iterator) ([]byte, error) {
Expand Down
2 changes: 1 addition & 1 deletion encoding/openapi/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (c *Config) compose(inst cue.InstanceOrValue, schemas *ast.StructLit) (x *a
var info *ast.StructLit

for i, _ := val.Fields(cue.Definitions(true)); i.Next(); {
if i.IsDefinition() {
if i.Selector().IsDefinition() {
continue
}
label := i.Label()
Expand Down

0 comments on commit d170b1c

Please sign in to comment.