internal/encoding: don't simplify interpreted encodings
As this will cause file information to be lost.
The effect is relatively minor.
Change-Id: I25367088b202118ac16d24c3363f0c19553480a2
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6301
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Johan Euphrosine <proppy@google.com>
diff --git a/cmd/cue/cmd/testdata/script/def_jsonschema.txt b/cmd/cue/cmd/testdata/script/def_jsonschema.txt
index 5e0fce7..3552938 100644
--- a/cmd/cue/cmd/testdata/script/def_jsonschema.txt
+++ b/cmd/cue/cmd/testdata/script/def_jsonschema.txt
@@ -69,10 +69,8 @@
-- expect-stderr2 --
age: conflicting values "twenty" and >=0 (mismatched types string and number):
- 14:7
./data.yaml:1:7
-- expect-stderr3 --
age: conflicting values "twenty" and >=0 (mismatched types string and number):
- 14:7
./data.yaml:1:7
-- cue.mod --
diff --git a/cmd/cue/cmd/testdata/script/import_auto.txt b/cmd/cue/cmd/testdata/script/import_auto.txt
index 3a87889..6c9d655 100644
--- a/cmd/cue/cmd/testdata/script/import_auto.txt
+++ b/cmd/cue/cmd/testdata/script/import_auto.txt
@@ -2,6 +2,8 @@
cmp stdout expect-openapi
-- expect-openapi --
+
+
// An OpenAPI file
info: {
diff --git a/internal/encoding/encoding.go b/internal/encoding/encoding.go
index dbe069e..8606bcb 100644
--- a/internal/encoding/encoding.go
+++ b/internal/encoding/encoding.go
@@ -267,7 +267,9 @@
Strict: cfg.Strict,
}
- file, err = simplify(jsonschema.Extract(i, cfg))
+ file, err = jsonschema.Extract(i, cfg)
+ // TODO: simplify currently erases file line info. Reintroduce after fix.
+ // file, err = simplify(file, err)
return file, id, err
}
}
@@ -275,7 +277,9 @@
func openAPIFunc(c *Config, f *build.File) interpretFunc {
cfg := &openapi.Config{PkgName: c.PkgName}
return func(i *cue.Instance) (file *ast.File, id string, err error) {
- file, err = simplify(openapi.Extract(i, cfg))
+ file, err = openapi.Extract(i, cfg)
+ // TODO: simplify currently erases file line info. Reintroduce after fix.
+ // file, err = simplify(file, err)
return file, "", err
}
}
@@ -431,6 +435,8 @@
if err != nil {
return nil, err
}
+ // This needs to be a function that modifies f in order to maintain line
+ // number information.
b, err := format.Node(f, format.Simplify())
if err != nil {
return nil, err