Skip to content

Commit d13d661

Browse files
committed
internal/core/adt: set isOuterStruct field
This is only for debugging purposes: the visual debugger marks the ID as being used in an CloseInfo.outerID field. Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Icbb0baaf06b660eb58cd176993170ba66c2e1312 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1212019 TryBot-Result: CUEcueckoo <[email protected]> Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Matthew Sackman <[email protected]>
1 parent 5423873 commit d13d661

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

internal/core/adt/debug.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func (m *mermaidContext) vertexInfo(vc *mermaidVertex, recursive bool) {
396396
format = "%s((<s><i>%d%si</i></s>))\n"
397397
}
398398
flags := ""
399-
if d.placeholder {
399+
if d.isOuterStruct {
400400
flags += "S"
401401
}
402402
if d.exclude != 0 {

internal/core/adt/typocheck.go

+20-10
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,21 @@ func (c *OpContext) getNextDefID() defID {
184184
type refInfo struct {
185185
v *Vertex
186186
id defID
187-
// exclude
187+
188+
// exclude defines a subtree of CloseInfo.def that should not be
189+
// transitively added to the set of allowed fields.
190+
//
188191
// It would probably be more efficient to track a separate allow and deny
189192
// list, rather than tracking the entire tree except for the excluded.
190193
exclude defID
191194

192-
ignore bool
193-
placeholder bool
195+
// ignore defines whether we should not do typo checking for this defID.
196+
ignore bool
197+
198+
// isOuterStruct indicates that this struct is marked as "outerID" in a
199+
// CloseInfo. The debug visualization in ./debug.go uses this to show a
200+
// mark ("S") next to the defID to visualize that this fact.
201+
isOuterStruct bool
194202
}
195203

196204
type conjunctFlags uint8
@@ -323,7 +331,7 @@ func (n *nodeContext) addResolver(v *Vertex, id CloseInfo, forceIgnore bool) Clo
323331
if id.enclosingEmbed != 0 && !ignore {
324332
ph := id.outerID
325333
n.addReplacement(replaceID{from: dstID, to: ph, add: true})
326-
id, dstID = n.newGroup(id)
334+
id, dstID = n.newGroup(id, false)
327335
id.enclosingEmbed = dstID
328336
}
329337

@@ -337,13 +345,15 @@ func (c *OpContext) subField(ci CloseInfo) CloseInfo {
337345
return ci
338346
}
339347

340-
func (n *nodeContext) newGroup(id CloseInfo) (CloseInfo, defID) {
348+
func (n *nodeContext) newGroup(id CloseInfo, placeholder bool) (CloseInfo, defID) {
341349
srcID := id.defID
342350
dstID := n.ctx.getNextDefID()
351+
// TODO: consider only adding when record || OpenGraph
343352
n.reqDefIDs = append(n.reqDefIDs, refInfo{
344-
v: emptyNode,
345-
id: dstID,
346-
ignore: true,
353+
v: emptyNode,
354+
id: dstID,
355+
ignore: true,
356+
isOuterStruct: placeholder,
347357
})
348358
id.defID = dstID
349359
n.addReplacement(replaceID{from: srcID, to: dstID, add: true})
@@ -396,7 +406,7 @@ func (n *nodeContext) injectEmbedNode(x Decl, id CloseInfo) CloseInfo {
396406
}
397407
}
398408

399-
id, dstID := n.newGroup(id)
409+
id, dstID := n.newGroup(id, false)
400410
id.enclosingEmbed = dstID
401411

402412
return id
@@ -430,7 +440,7 @@ func (n *nodeContext) splitDefID(s *StructLit, id CloseInfo) CloseInfo {
430440
return id
431441
}
432442

433-
id, dstID := n.newGroup(id)
443+
id, dstID := n.newGroup(id, true)
434444

435445
if id.outerID == 0 {
436446
id.outerID = dstID

0 commit comments

Comments
 (0)