More miscellaneous renaming of ZCL to HCL.
This commit is contained in:
parent
b638b30f98
commit
5956c82199
@ -10,7 +10,7 @@ type File struct {
|
|||||||
Bytes []byte
|
Bytes []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *File) AsZCLFile() *hcl.File {
|
func (f *File) AsHCLFile() *hcl.File {
|
||||||
return &hcl.File{
|
return &hcl.File{
|
||||||
Body: f.Body,
|
Body: f.Body,
|
||||||
Bytes: f.Bytes,
|
Bytes: f.Bytes,
|
||||||
|
@ -7,8 +7,8 @@ import (
|
|||||||
"github.com/hashicorp/hcl2/hcl"
|
"github.com/hashicorp/hcl2/hcl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// AsZCLBlock returns the block data expressed as a *hcl.Block.
|
// AsHCLBlock returns the block data expressed as a *hcl.Block.
|
||||||
func (b *Block) AsZCLBlock() *hcl.Block {
|
func (b *Block) AsHCLBlock() *hcl.Block {
|
||||||
lastHeaderRange := b.TypeRange
|
lastHeaderRange := b.TypeRange
|
||||||
if len(b.LabelRanges) > 0 {
|
if len(b.LabelRanges) > 0 {
|
||||||
lastHeaderRange = b.LabelRanges[len(b.LabelRanges)-1]
|
lastHeaderRange = b.LabelRanges[len(b.LabelRanges)-1]
|
||||||
@ -52,11 +52,11 @@ func (b *Body) Range() hcl.Range {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *Body) Content(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Diagnostics) {
|
func (b *Body) Content(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Diagnostics) {
|
||||||
content, remainZCL, diags := b.PartialContent(schema)
|
content, remainHCL, diags := b.PartialContent(schema)
|
||||||
|
|
||||||
// No we'll see if anything actually remains, to produce errors about
|
// No we'll see if anything actually remains, to produce errors about
|
||||||
// extraneous items.
|
// extraneous items.
|
||||||
remain := remainZCL.(*Body)
|
remain := remainHCL.(*Body)
|
||||||
|
|
||||||
for name, attr := range b.Attributes {
|
for name, attr := range b.Attributes {
|
||||||
if _, hidden := remain.hiddenAttrs[name]; !hidden {
|
if _, hidden := remain.hiddenAttrs[name]; !hidden {
|
||||||
@ -156,7 +156,7 @@ func (b *Body) PartialContent(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Bod
|
|||||||
}
|
}
|
||||||
|
|
||||||
hiddenAttrs[name] = struct{}{}
|
hiddenAttrs[name] = struct{}{}
|
||||||
attrs[name] = attr.AsZCLAttribute()
|
attrs[name] = attr.AsHCLAttribute()
|
||||||
}
|
}
|
||||||
|
|
||||||
blocksWanted := make(map[string]hcl.BlockHeaderSchema)
|
blocksWanted := make(map[string]hcl.BlockHeaderSchema)
|
||||||
@ -215,7 +215,7 @@ func (b *Body) PartialContent(schema *hcl.BodySchema) (*hcl.BodyContent, hcl.Bod
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
blocks = append(blocks, block.AsZCLBlock())
|
blocks = append(blocks, block.AsHCLBlock())
|
||||||
}
|
}
|
||||||
|
|
||||||
// We hide blocks only after we've processed all of them, since otherwise
|
// We hide blocks only after we've processed all of them, since otherwise
|
||||||
@ -268,7 +268,7 @@ func (b *Body) JustAttributes() (hcl.Attributes, hcl.Diagnostics) {
|
|||||||
if _, hidden := b.hiddenAttrs[name]; hidden {
|
if _, hidden := b.hiddenAttrs[name]; hidden {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
attrs[name] = attr.AsZCLAttribute()
|
attrs[name] = attr.AsHCLAttribute()
|
||||||
}
|
}
|
||||||
|
|
||||||
return attrs, diags
|
return attrs, diags
|
||||||
@ -324,8 +324,8 @@ func (a *Attribute) Range() hcl.Range {
|
|||||||
return a.SrcRange
|
return a.SrcRange
|
||||||
}
|
}
|
||||||
|
|
||||||
// AsZCLAttribute returns the block data expressed as a *hcl.Attribute.
|
// AsHCLAttribute returns the block data expressed as a *hcl.Attribute.
|
||||||
func (a *Attribute) AsZCLAttribute() *hcl.Attribute {
|
func (a *Attribute) AsHCLAttribute() *hcl.Attribute {
|
||||||
return &hcl.Attribute{
|
return &hcl.Attribute{
|
||||||
Name: a.Name,
|
Name: a.Name,
|
||||||
Expr: a.Expr,
|
Expr: a.Expr,
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/hashicorp/hcl2/hcl"
|
"github.com/hashicorp/hcl2/hcl"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Token represents a sequence of bytes from some zcl code that has been
|
// Token represents a sequence of bytes from some HCL code that has been
|
||||||
// tagged with a type and its range within the source file.
|
// tagged with a type and its range within the source file.
|
||||||
type Token struct {
|
type Token struct {
|
||||||
Type TokenType
|
Type TokenType
|
||||||
@ -82,7 +82,7 @@ const (
|
|||||||
// The rest are not used in the language but recognized by the scanner so
|
// The rest are not used in the language but recognized by the scanner so
|
||||||
// we can generate good diagnostics in the parser when users try to write
|
// we can generate good diagnostics in the parser when users try to write
|
||||||
// things that might work in other languages they are familiar with, or
|
// things that might work in other languages they are familiar with, or
|
||||||
// simply make incorrect assumptions about the zcl language.
|
// simply make incorrect assumptions about the HCL language.
|
||||||
|
|
||||||
TokenBitwiseAnd TokenType = '&'
|
TokenBitwiseAnd TokenType = '&'
|
||||||
TokenBitwiseOr TokenType = '|'
|
TokenBitwiseOr TokenType = '|'
|
||||||
@ -102,7 +102,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (t TokenType) GoString() string {
|
func (t TokenType) GoString() string {
|
||||||
return fmt.Sprintf("zclsyntax.%s", t.String())
|
return fmt.Sprintf("hclsyntax.%s", t.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
type scanMode int
|
type scanMode int
|
||||||
@ -160,7 +160,7 @@ type heredocInProgress struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// checkInvalidTokens does a simple pass across the given tokens and generates
|
// checkInvalidTokens does a simple pass across the given tokens and generates
|
||||||
// diagnostics for tokens that should _never_ appear in ZCL source. This
|
// diagnostics for tokens that should _never_ appear in HCL source. This
|
||||||
// is intended to avoid the need for the parser to have special support
|
// is intended to avoid the need for the parser to have special support
|
||||||
// for them all over.
|
// for them all over.
|
||||||
//
|
//
|
||||||
|
@ -4,12 +4,12 @@ import (
|
|||||||
"github.com/zclconf/go-cty/cty"
|
"github.com/zclconf/go-cty/cty"
|
||||||
)
|
)
|
||||||
|
|
||||||
// File is the top-level node that results from parsing a ZCL file.
|
// File is the top-level node that results from parsing a HCL file.
|
||||||
type File struct {
|
type File struct {
|
||||||
Body Body
|
Body Body
|
||||||
Bytes []byte
|
Bytes []byte
|
||||||
|
|
||||||
// Nav is used to integrate with the "zcled" editor integration package,
|
// Nav is used to integrate with the "hcled" editor integration package,
|
||||||
// and with diagnostic information formatters. It is not for direct use
|
// and with diagnostic information formatters. It is not for direct use
|
||||||
// by a calling application.
|
// by a calling application.
|
||||||
Nav interface{}
|
Nav interface{}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user