Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/mod/modimports: use cue/parser.ImportsOnly
Invalid syntax after import declarations should be handled consistently no matter whether a file started with a package clause or not. If for any reason cueimports.Read thinks there is invalid syntax and reads the entire source, such as when a package clause is missing, stop cue/parser from parsing the entire file as well. Not only is parsing the entire file in that case wasteful, but it also leads to errors which aren't particularly useful when all we care about here is listing imported packages. While here, remove the use of ParseComments; none of the modimports users need to parse comments at the top of the file. This is a remnant from Go, where comments at the top of the file are important as they may contain build tag directives. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: I35eeade6481b74da7f04240f9ef85da338491f7e Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1194961 TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
- Loading branch information