@@ -300,8 +300,8 @@ func (c *spoc) markAndSubstElements(
300300 elemList * []ast.Element , ctx string , m map [string ]* ast.TopList ,
301301 isUsed map [string ]bool ) {
302302
303- expand := func (el ast.Element ) groupObjList {
304- l := c .expandGroup1 ([]ast.Element {el }, ctx , false , false )
303+ expand := func (el ast.Element , visible bool ) groupObjList {
304+ l := c .expandGroup1 ([]ast.Element {el }, ctx , visible , false )
305305 // Remove duplicates from dual stack objects.
306306 slices .SortFunc (l , func (e1 , e2 groupObj ) int {
307307 return strings .Compare (e1 .String (), e2 .String ())
@@ -395,8 +395,8 @@ func (c *spoc) markAndSubstElements(
395395 }
396396 return result
397397 }
398- var traverse func (l []ast.Element ) []ast.Element
399- traverse = func (l []ast.Element ) []ast.Element {
398+ var traverse func (l []ast.Element , visible bool ) []ast.Element
399+ traverse = func (l []ast.Element , visible bool ) []ast.Element {
400400 var expanded groupObjList
401401 j := 0
402402 for _ , el := range l {
@@ -408,7 +408,7 @@ func (c *spoc) markAndSubstElements(
408408 }
409409 switch x .Type {
410410 case "any" , "network" :
411- for _ , obj := range expand (el ) {
411+ for _ , obj := range expand (el , visible ) {
412412 markUnconnectedObj (obj .(* network ), isUsed )
413413 }
414414 case "group" :
@@ -419,29 +419,29 @@ func (c *spoc) markAndSubstElements(
419419 isUsed [typedName ] = true
420420 case ast.AutoElem :
421421 // Ignore empty automatic group
422- if len (expand (el )) == 0 {
422+ if len (expand (el , false )) == 0 {
423423 continue
424424 }
425425 // Remove sub elements that would evaluate to empty list.
426- l2 := traverse (x .GetElements ())
426+ l2 := traverse (x .GetElements (), false )
427427 j2 := 0
428428 for _ , el2 := range l2 {
429- if len (expand (el2 )) != 0 {
429+ if len (expand (el2 , false )) != 0 {
430430 l2 [j2 ] = el2
431431 j2 ++
432432 }
433433 }
434434 x .SetElements (l2 [:j2 ])
435435 case * ast.IntfRef :
436- for _ , obj := range expand (el ) {
436+ for _ , obj := range expand (el , visible ) {
437437 switch x := obj .(type ) {
438438 case * routerIntf :
439439 setIntfUsed (x , isUsed )
440440 setRouterUsed (x .router , isUsed )
441441 }
442442 }
443443 case * ast.Intersection :
444- expanded = append (expanded , expand (el )... )
444+ expanded = append (expanded , expand (el , visible )... )
445445 continue // Ignore original intersection.
446446 }
447447 l [j ] = el
@@ -453,7 +453,7 @@ func (c *spoc) markAndSubstElements(
453453 }
454454 return result
455455 }
456- * elemList = traverse (* elemList )
456+ * elemList = traverse (* elemList , true )
457457}
458458
459459func (c * spoc ) markElements (
0 commit comments