this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

all: replace two uses of astutil.ParseImportPath

If all that is needed is the unquoted import path,
which happens in two call sites, we don't need this API.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: Idaa35aa7e36a36a0055da9284d45f339ae9a5ed8
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1225053
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+10 -10
+3 -3
cue/marshal.go
··· 19 19 "compress/gzip" 20 20 "encoding/gob" 21 21 "path/filepath" 22 + "strconv" 22 23 "strings" 23 24 24 25 "cuelang.org/go/cue/ast" 25 - "cuelang.org/go/cue/ast/astutil" 26 26 "cuelang.org/go/cue/build" 27 27 "cuelang.org/go/cue/errors" 28 28 "cuelang.org/go/cue/format" ··· 144 144 file, _ := export.Def(r.runtime(), inst.ID(), i.instance().root) 145 145 imports := []string{} 146 146 for spec := range file.ImportSpecs() { 147 - info, _ := astutil.ParseImportSpec(spec) 148 - imports = append(imports, info.ID) 147 + path, _ := strconv.Unquote(spec.Path.Value) 148 + imports = append(imports, path) 149 149 } 150 150 151 151 if inst.PkgName != "" {
+7 -7
internal/core/runtime/build.go
··· 15 15 package runtime 16 16 17 17 import ( 18 + "strconv" 18 19 "strings" 19 20 20 21 "cuelang.org/go/cue/ast" 21 - "cuelang.org/go/cue/ast/astutil" 22 22 "cuelang.org/go/cue/build" 23 23 "cuelang.org/go/cue/errors" 24 24 "cuelang.org/go/cue/stats" ··· 119 119 } 120 120 121 121 func (x *Runtime) buildSpec(cfg *Config, b *build.Instance, spec *ast.ImportSpec) (errs errors.Error) { 122 - info, err := astutil.ParseImportSpec(spec) 122 + path, err := strconv.Unquote(spec.Path.Value) 123 123 if err != nil { 124 124 return errors.Promote(err, "invalid import path") 125 125 } 126 126 127 - pkg := b.LookupImport(info.ID) 127 + pkg := b.LookupImport(path) 128 128 if pkg == nil { 129 - if strings.Contains(info.ID, ".") { 129 + if strings.Contains(path, ".") { 130 130 return errors.Newf(spec.Pos(), 131 131 "package %q imported but not defined in %s", 132 - info.ID, b.ImportPath) 133 - } else if x.index.builtinPaths[info.ID] == nil { 132 + path, b.ImportPath) 133 + } else if x.index.builtinPaths[path] == nil { 134 134 return errors.Newf(spec.Pos(), 135 - "builtin package %q undefined", info.ID) 135 + "builtin package %q undefined", path) 136 136 } 137 137 return nil 138 138 }