Skip to content

Commit

Permalink
internal/filetypes: remove deprecated API usage
Browse files Browse the repository at this point in the history
This removes some deprecated API usages in the filetypes package.

While here, fix some unordered imports.

Updates #2480.

Signed-off-by: Noam Dolovich <noam.tzvi.dolovich@gmail.com>
Change-Id: Ic578b5a25a8839caa28da69930b7dcb597d6c2ec
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194645
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
  • Loading branch information
NoamTD authored and mvdan committed May 13, 2024
1 parent 64bbf1b commit 9a0cae9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions internal/filetypes/filetypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func FromFile(b *build.File, mode Mode) (*FileInfo, error) {
typesInit()
modeVal := typesValue.LookupPath(cue.MakePath(cue.Str("modes"), cue.Str(mode.String())))
fileVal := modeVal.LookupPath(cue.MakePath(cue.Str("FileInfo")))
fileVal = fileVal.Fill(b)
fileVal = fileVal.FillPath(cue.Path{}, b)

if b.Encoding == "" {
ext := modeVal.LookupPath(cue.MakePath(cue.Str("extensions"), cue.Str(fileExt(b.Filename))))
Expand Down Expand Up @@ -319,7 +319,7 @@ func parseType(scope string, mode Mode) (modeVal, fileVal cue.Value, _ error) {
for _, tag := range strings.Split(scope, "+") {
tagName, tagVal, ok := strings.Cut(tag, "=")
if ok {
fileVal = fileVal.Fill(tagVal, "tags", tagName)
fileVal = fileVal.FillPath(cue.MakePath(cue.Str("tags"), cue.Str(tagName)), tagVal)
} else {
info := typesValue.LookupPath(cue.MakePath(cue.Str("tags"), cue.Str(tag)))
if !info.Exists() {
Expand Down
5 changes: 3 additions & 2 deletions internal/filetypes/filetypes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ import (
"strings"
"testing"

"cuelang.org/go/cue/build"
"cuelang.org/go/cue/errors"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"

"cuelang.org/go/cue/build"
"cuelang.org/go/cue/errors"
)

func check(t *testing.T, want, x interface{}, err error) {
Expand Down

0 comments on commit 9a0cae9

Please sign in to comment.