this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: remove obsolete CloseInfo methods

Remove CloseInfo methods that became obsolete after
EvalV2 removal. These methods now return constants.

- Remove RootSpanType method (unused)
- Remove span and IsInOneOf from public interface
- Simplify IsRecursivelyClosed and isClosed
- Update equality check to reflect span() returns 0
- Keep Location and AddPositions as still referenced

Signed-off-by: Marcel van Lohuizen <mpvl@gmail.com>
Change-Id: I0591287b6265487ad1e57f389fbf4561e5399e0e
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1219982
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>

+5 -44
+2 -40
internal/core/adt/closed.go
··· 70 70 // TODO(errors): return a dedicated ConflictError that can track original 71 71 // positions on demand. 72 72 73 - // IsInOneOf reports whether any of the Structs associated with v is contained 74 - // within any of the span types in the given mask. 75 - func (v *Vertex) IsInOneOf(mask SpanType) bool { 76 - for _, s := range v.Structs { 77 - if s.CloseInfo.IsInOneOf(mask) { 78 - return true 79 - } 80 - } 81 - return false 82 - } 83 - 84 73 // IsRecursivelyClosed returns true if this value is either a definition or unified 85 74 // with a definition. 86 75 func (v *Vertex) IsRecursivelyClosed() bool { 87 - return v.ClosedRecursive || v.IsInOneOf(DefinitionSpan) 76 + return v.ClosedRecursive 88 77 } 89 78 90 79 type CloseInfo struct { ··· 125 114 return nil 126 115 } 127 116 128 - func (c CloseInfo) span() SpanType { 129 - return 0 130 - } 131 - 132 - func (c CloseInfo) RootSpanType() SpanType { 133 - return 0 134 - } 135 - 136 - // IsInOneOf reports whether c is contained within any of the span types in the 137 - // given mask. 138 - func (c CloseInfo) IsInOneOf(t SpanType) bool { 139 - return c.span()&t != 0 140 - } 141 - 142 117 // TODO(perf): remove: error positions should always be computed on demand 143 118 // in dedicated error types. 144 119 func (c *CloseInfo) AddPositions(ctx *OpContext) { ··· 178 153 return isDef, depth 179 154 } 180 155 181 - // A SpanType is used to indicate whether a CUE value is within the scope of 182 - // a certain CUE language construct, the span type. 183 - type SpanType uint8 184 - 185 - const ( 186 - // EmbeddingSpan means that this value was embedded at some point and should 187 - // not be included as a possible root node in the todo field of OpContext. 188 - EmbeddingSpan SpanType = 1 << iota 189 - ConstraintSpan 190 - ComprehensionSpan 191 - DefinitionSpan 192 - ) 193 - 194 156 // isClosed reports whether v is closed at this level (so not recursively). 195 157 func isClosed(v *Vertex) bool { 196 158 // We could have used IsRecursivelyClosed here, but (effectively) ··· 201 163 } 202 164 // TODO(evalv3): this can be removed once we delete the evalv2 code. 203 165 for _, s := range v.Structs { 204 - if s.IsClosed || s.IsInOneOf(DefinitionSpan) { 166 + if s.IsClosed { 205 167 return true 206 168 } 207 169 }
+3 -4
internal/core/adt/equality.go
··· 160 160 if (flags&IgnoreOptional != 0) && !s.StructLit.HasOptional() { 161 161 continue 162 162 } 163 - if s.span()&DefinitionSpan == 0 { 164 - if !s.StructLit.HasOptional() { 165 - continue 166 - } 163 + // span() always returns 0 after EvalV2 removal, so this check is always true 164 + if !s.StructLit.HasOptional() { 165 + continue 167 166 } 168 167 for _, t := range y.Structs { 169 168 if s.StructLit == t.StructLit {