Skip to content

Commit 781f140

Browse files
committed
encoding/jsonschema: remove isSchema field
This field is no longer used: in general we can't make assumptions about whether a given node is inside a schema, so we always emit the ellipses, leaving ellipsis removal for a later processing stage. Signed-off-by: Roger Peppe <[email protected]> Change-Id: If8e5c3b918989a31a5f388aac01cdb9ec3f2e258 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1205046 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent 6ef4f68 commit 781f140

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

encoding/jsonschema/constraints_generic.go

-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@ func constraintAddDefinitions(key string, n cue.Value, s *state) {
2828
s.errf(n, `"definitions" expected an object, found %s`, n.Kind())
2929
}
3030

31-
old := s.isSchema
32-
s.isSchema = true
33-
defer func() { s.isSchema = old }()
34-
3531
s.processMap(n, func(key string, n cue.Value) {
3632
name := key
3733

encoding/jsonschema/decode.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ func (d *decoder) schema(ref []ast.Label, v cue.Value) (a []ast.Decl) {
126126

127127
if inner >= 0 {
128128
name = ref[inner]
129-
root.isSchema = true
130129
}
131130

132131
expr, state := root.schemaState(v, allTypes, nil)
@@ -401,8 +400,6 @@ type state struct {
401400
*decoder
402401
schemaInfo
403402

404-
isSchema bool // for omitting ellipsis in an ast.File
405-
406403
up *state
407404

408405
path []string
@@ -739,11 +736,10 @@ func (s0 *state) schemaState(n cue.Value, types cue.Kind, idRef []label) (ast.Ex
739736
allowedTypes: types,
740737
knownTypes: allTypes,
741738
},
742-
isSchema: s0.isSchema,
743-
decoder: s0.decoder,
744-
idRef: idRef,
745-
pos: n,
746-
isRoot: s0.isRoot && n == s0.pos,
739+
decoder: s0.decoder,
740+
idRef: idRef,
741+
pos: n,
742+
isRoot: s0.isRoot && n == s0.pos,
747743
}
748744
if n.Kind() == cue.BoolKind {
749745
if vfrom(VersionDraft6).contains(s.schemaVersion) {

0 commit comments

Comments
 (0)