@@ -138,7 +138,7 @@ func (s *state) makeCUERef(n cue.Value, u *url.URL, fragmentParts []string) (_e
138
138
return s .rootRef ()
139
139
}
140
140
141
- ident , fragmentParts = s .getNextIdent (n , fragmentParts )
141
+ ident , fragmentParts = s .getNextIdent (n . Pos () , fragmentParts )
142
142
143
143
case u .Host != "" :
144
144
// Reference not found within scope. Create an import reference.
@@ -206,22 +206,22 @@ func (s *state) makeCUERef(n cue.Value, u *url.URL, fragmentParts []string) (_e
206
206
}
207
207
return newSel (e , s .idRef [1 ])
208
208
}
209
- ident , fragmentParts = s .getNextIdent (n , fragmentParts )
209
+ ident , fragmentParts = s .getNextIdent (n . Pos () , fragmentParts )
210
210
ident .Node = s .obj
211
211
break
212
212
}
213
213
}
214
214
215
- return s .newSel (ident , n , fragmentParts )
215
+ return s .newSel (n . Pos (), ident , fragmentParts )
216
216
}
217
217
218
218
// getNextSelector translates a JSON Reference path into a CUE path by consuming
219
219
// the first path elements and returning the corresponding CUE label.
220
- func (s * state ) getNextSelector (v cue. Value , a []string ) (l label , tail []string ) {
220
+ func (s * state ) getNextSelector (pos token. Pos , a []string ) (l label , tail []string ) {
221
221
switch elem := a [0 ]; elem {
222
222
case "$defs" , "definitions" :
223
223
if len (a ) == 1 {
224
- s .errf ( v , "cannot refer to %s section: must refer to one of its elements" , a [0 ])
224
+ s .warnf ( pos , "cannot refer to %s section: must refer to one of its elements" , a [0 ])
225
225
return label {}, nil
226
226
}
227
227
@@ -233,7 +233,7 @@ func (s *state) getNextSelector(v cue.Value, a []string) (l label, tail []string
233
233
234
234
case "properties" :
235
235
if len (a ) == 1 {
236
- s .errf ( v , "cannot refer to %s section: must refer to one of its elements" , a [0 ])
236
+ s .warnf ( pos , "cannot refer to %s section: must refer to one of its elements" , a [0 ])
237
237
return label {}, nil
238
238
}
239
239
@@ -245,7 +245,7 @@ func (s *state) getNextSelector(v cue.Value, a []string) (l label, tail []string
245
245
"additionalItems" :
246
246
// TODO: as a temporary workaround, include the schema verbatim.
247
247
// TODO: provide definitions for these in CUE.
248
- s .errf ( v , "referring to field %q not yet supported" , elem )
248
+ s .warnf ( pos , "referring to field %q not yet supported" , elem )
249
249
250
250
// Other known fields cannot be supported.
251
251
return label {}, nil
@@ -255,12 +255,12 @@ func (s *state) getNextSelector(v cue.Value, a []string) (l label, tail []string
255
255
}
256
256
}
257
257
258
- // newSel converts a JSON Reference path and initial CUE identifier to
259
- // a CUE selection path.
260
- func (s * state ) newSel (e ast. Expr , v cue. Value , a []string ) ast.Expr {
258
+ // newSel converts an initial CUE identifier and a relative JSON Reference path
259
+ // to a CUE selection path.
260
+ func (s * state ) newSel (pos token. Pos , e ast. Expr , a []string ) ast.Expr {
261
261
for len (a ) > 0 {
262
262
var label label
263
- label , a = s .getNextSelector (v , a )
263
+ label , a = s .getNextSelector (pos , a )
264
264
e = newSel (e , label )
265
265
}
266
266
return e
@@ -310,8 +310,8 @@ func (s *state) setRef(lab label, r refs) {
310
310
311
311
// getNextIdent gets the first CUE reference from a JSON Reference path and
312
312
// converts it to a CUE identifier.
313
- func (s * state ) getNextIdent (v cue. Value , a []string ) (resolved * ast.Ident , tail []string ) {
314
- lab , a := s .getNextSelector (v , a )
313
+ func (s * state ) getNextIdent (pos token. Pos , a []string ) (resolved * ast.Ident , tail []string ) {
314
+ lab , a := s .getNextSelector (pos , a )
315
315
316
316
x := s .getRef (lab )
317
317
ident := ast .NewIdent (x .ident )
0 commit comments