Skip to content

Commit

Permalink
cue/load: remove unused functionality
Browse files Browse the repository at this point in the history
The `readComments` function is never actually invoked.

Signed-off-by: Roger Peppe <[email protected]>
Change-Id: Ia41d9c8626aa46ed3ca675245dbc21eb639d56d4
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1172688
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
  • Loading branch information
rogpeppe committed Nov 24, 2023
1 parent 361ae4f commit b727189
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 40 deletions.
12 changes: 0 additions & 12 deletions cue/load/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,18 +208,6 @@ func (r *importReader) readImport(imports *[]string) {
r.readString(imports)
}

// readComments is like io.ReadAll, except that it only reads the leading
// block of comments in the file.
func readComments(f io.Reader) ([]byte, errors.Error) {
r := &importReader{b: bufio.NewReader(f)}
r.peekByte(true)
if r.err == nil && !r.eof {
// Didn't reach EOF, so must have found a non-space byte. Remove it.
r.buf = r.buf[:len(r.buf)-1]
}
return r.buf, r.err
}

// readImports is like io.ReadAll, except that it expects a CUE file as
// input and stops reading the input once the imports have completed.
func readImports(f io.Reader, reportSyntaxError bool, imports *[]string) ([]byte, errors.Error) {
Expand Down
30 changes: 2 additions & 28 deletions cue/load/read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ var readImportsTests = []readTest{
},
{
`package p
// comment
import "x"
import _ "x"
import a "x"
Expand All @@ -76,28 +76,6 @@ var readImportsTests = []readTest{
},
}

var readCommentsTests = []readTest{
{
`ℙpackage p`,
"",
},
{
`ℙpackage p; import "x"`,
"",
},
{
`ℙpackage p; import . "x"`,
"",
},
{
`// foo
// asdf
ℙHello, world`,
"",
},
}

func testRead(t *testing.T, tests []readTest, read func(io.Reader) ([]byte, errors.Error)) {
for i, tt := range tests {
var in, testOut string
Expand Down Expand Up @@ -140,10 +118,6 @@ func TestReadImports(t *testing.T) {
})
}

func TestReadComments(t *testing.T) {
testRead(t, readCommentsTests, readComments)
}

var readFailuresTests = []readTest{
{
`package`,
Expand Down

0 comments on commit b727189

Please sign in to comment.