Skip to content

Commit

Permalink
cue/load: replace readimports with cueimports.Read
Browse files Browse the repository at this point in the history
Pretty much the same code inherited from Go.
The way cue/load used it already matched the cueimports.Read API.

While here, fileProcessor.add only needs to use cue/parser to read
a CUE file's package clause and imported package paths,
so there is no need to parse comments at all.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I67c5349dd691b282a8c4c1fbd3dd5daaf7f10163
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194965
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
  • Loading branch information
mvdan committed May 20, 2024
1 parent 7d93bcc commit 7d49080
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 459 deletions.
2 changes: 1 addition & 1 deletion cue/load/loader_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (fp *fileProcessor) add(root string, file *build.File, mode importMode) (ad
return false
}

pf, perr := parser.ParseFile(fullPath, data, parser.ImportsOnly, parser.ParseComments)
pf, perr := parser.ParseFile(fullPath, data, parser.ImportsOnly)
if perr != nil {
badFile(errors.Promote(perr, "add failed"))
return true
Expand Down
3 changes: 2 additions & 1 deletion cue/load/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"cuelang.org/go/cue/build"
"cuelang.org/go/cue/errors"
"cuelang.org/go/cue/token"
"cuelang.org/go/internal/cueimports"
)

// A match represents the result of matching a single package pattern.
Expand Down Expand Up @@ -74,7 +75,7 @@ func matchFile(cfg *Config, file *build.File, returnImports bool, allTags map[st
return false, nil, err
}

data, err = readImports(f, false, nil)
data, err = cueimports.Read(f)
f.Close()
if err != nil {
return false, nil,
Expand Down
247 changes: 0 additions & 247 deletions cue/load/read.go

This file was deleted.

Loading

0 comments on commit 7d49080

Please sign in to comment.