hclparse: rename ParseZCL to ParseHCL

This commit is contained in:
Martin Atkins 2017-09-11 17:22:10 -07:00
parent 46b20d40af
commit b8b5e0be6d
3 changed files with 10 additions and 10 deletions

View File

@ -119,7 +119,7 @@ func processFile(fn string, in *os.File) error {
} }
if *check { if *check {
_, diags := parser.ParseZCL(inSrc, fn) _, diags := parser.ParseHCL(inSrc, fn)
diagWr.WriteDiagnostics(diags) diagWr.WriteDiagnostics(diags)
if diags.HasErrors() { if diags.HasErrors() {
checkErrs = true checkErrs = true

View File

@ -4,8 +4,8 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/hashicorp/hcl2/hclparse"
"github.com/hashicorp/hcl2/hcl" "github.com/hashicorp/hcl2/hcl"
"github.com/hashicorp/hcl2/hclparse"
) )
// FileResolver creates and returns a Resolver that interprets include paths // FileResolver creates and returns a Resolver that interprets include paths
@ -21,7 +21,7 @@ import (
// either absolute or relative to the given basePath. // either absolute or relative to the given basePath.
// //
// If the path given in configuration ends with ".json" then the referenced // If the path given in configuration ends with ".json" then the referenced
// file is interpreted as JSON. Otherwise, it is interpreted as zcl native // file is interpreted as JSON. Otherwise, it is interpreted as HCL native
// syntax. // syntax.
func FileResolver(baseDir string, parser *hclparse.Parser) Resolver { func FileResolver(baseDir string, parser *hclparse.Parser) Resolver {
return &fileResolver{ return &fileResolver{
@ -45,7 +45,7 @@ func (r fileResolver) ResolveBodyPath(path string, refRange hcl.Range) (hcl.Body
if strings.HasSuffix(targetFile, ".json") { if strings.HasSuffix(targetFile, ".json") {
f, diags = r.Parser.ParseJSONFile(targetFile) f, diags = r.Parser.ParseJSONFile(targetFile)
} else { } else {
f, diags = r.Parser.ParseZCLFile(targetFile) f, diags = r.Parser.ParseHCLFile(targetFile)
} }
return f.Body, diags return f.Body, diags

View File

@ -4,9 +4,9 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"github.com/hashicorp/hcl2/hcl"
"github.com/hashicorp/hcl2/hcl/hclsyntax" "github.com/hashicorp/hcl2/hcl/hclsyntax"
"github.com/hashicorp/hcl2/hcl/json" "github.com/hashicorp/hcl2/hcl/json"
"github.com/hashicorp/hcl2/hcl"
) )
// NOTE: This is the public interface for parsing. The actual parsers are // NOTE: This is the public interface for parsing. The actual parsers are
@ -34,10 +34,10 @@ func NewParser() *Parser {
} }
} }
// ParseZCL parses the given buffer (which is assumed to have been loaded from // ParseHCL parses the given buffer (which is assumed to have been loaded from
// the given filename) as a native-syntax configuration file and returns the // the given filename) as a native-syntax configuration file and returns the
// hcl.File object representing it. // hcl.File object representing it.
func (p *Parser) ParseZCL(src []byte, filename string) (*hcl.File, hcl.Diagnostics) { func (p *Parser) ParseHCL(src []byte, filename string) (*hcl.File, hcl.Diagnostics) {
if existing := p.files[filename]; existing != nil { if existing := p.files[filename]; existing != nil {
return existing, nil return existing, nil
} }
@ -47,10 +47,10 @@ func (p *Parser) ParseZCL(src []byte, filename string) (*hcl.File, hcl.Diagnosti
return file, diags return file, diags
} }
// ParseZCLFile reads the given filename and parses it as a native-syntax zcl // ParseHCLFile reads the given filename and parses it as a native-syntax HCL
// configuration file. An error diagnostic is returned if the given file // configuration file. An error diagnostic is returned if the given file
// cannot be read. // cannot be read.
func (p *Parser) ParseZCLFile(filename string) (*hcl.File, hcl.Diagnostics) { func (p *Parser) ParseHCLFile(filename string) (*hcl.File, hcl.Diagnostics) {
if existing := p.files[filename]; existing != nil { if existing := p.files[filename]; existing != nil {
return existing, nil return existing, nil
} }
@ -66,7 +66,7 @@ func (p *Parser) ParseZCLFile(filename string) (*hcl.File, hcl.Diagnostics) {
} }
} }
return p.ParseZCL(src, filename) return p.ParseHCL(src, filename)
} }
// ParseJSON parses the given JSON buffer (which is assumed to have been loaded // ParseJSON parses the given JSON buffer (which is assumed to have been loaded