github.com/hashicorp/hcl/v2@v2.20.0/hcldec/block_labels.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package hcldec
     5  
     6  import (
     7  	"github.com/hashicorp/hcl/v2"
     8  )
     9  
    10  type blockLabel struct {
    11  	Value string
    12  	Range hcl.Range
    13  }
    14  
    15  func labelsForBlock(block *hcl.Block) []blockLabel {
    16  	ret := make([]blockLabel, len(block.Labels))
    17  	for i := range block.Labels {
    18  		ret[i] = blockLabel{
    19  			Value: block.Labels[i],
    20  			Range: block.LabelRanges[i],
    21  		}
    22  	}
    23  	return ret
    24  }