this repo has no description
0
fork

Configure Feed

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

cue/load: include module file in build.Instance

This makes the module file, including dependency and
language version info, available to `cue/load.Instances`
callers.

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

+14
+4
cue/build/instance.go
··· 26 26 "cuelang.org/go/cue/errors" 27 27 "cuelang.org/go/cue/parser" 28 28 "cuelang.org/go/cue/token" 29 + "cuelang.org/go/internal/mod/modfiledata" 29 30 ) 30 31 31 32 // An Instance describes the collection of files, and its imports, necessary ··· 79 80 // the packages within the directory structure of the module are to be 80 81 // imported by other packages, including those within the module. 81 82 Module string 83 + 84 + // ModuleFile holds the actual module file data, if available. 85 + ModuleFile *modfiledata.File 82 86 83 87 // Root is the root of the directory hierarchy, it may be "" if this an 84 88 // instance has no imports.
+1
cue/load/config.go
··· 472 472 i := c.Context.NewInstance("", nil) 473 473 i.Root = c.ModuleRoot 474 474 i.Module = c.Module 475 + i.ModuleFile = c.modFile 475 476 i.Err = errors.Promote(err, "") 476 477 return i 477 478 }
+2
cue/load/import.go
··· 317 317 // p.ImportPath = string(dir) // compute unique ID. 318 318 p.Root = l.cfg.ModuleRoot 319 319 p.Module = l.cfg.Module 320 + p.ModuleFile = l.cfg.modFile 320 321 321 322 var err errors.Error 322 323 if path != cleanImport(path) { ··· 402 403 i.ImportPath = string(p) 403 404 i.Root = l.cfg.ModuleRoot 404 405 i.Module = modPath 406 + i.ModuleFile = l.cfg.modFile 405 407 406 408 return i 407 409 }
+1
cue/load/loader_common.go
··· 248 248 q.ImportPath = p.ImportPath + ":" + pkg 249 249 q.Root = p.Root 250 250 q.Module = p.Module 251 + q.ModuleFile = p.ModuleFile 251 252 fp.pkgs[pkg] = q 252 253 } 253 254 p = q
+6
cue/load/module_test.go
··· 102 102 }) 103 103 return 104 104 } 105 + if inst.Module != "" { 106 + // Sanity check that the module file is present in the instance. 107 + qt.Assert(t, qt.Not(qt.IsNil(inst.ModuleFile))) 108 + qt.Assert(t, qt.Equals(inst.ModuleFile.Module, inst.Module)) 109 + qt.Assert(t, qt.Equals(inst.ModuleFile.Language.Version, "v0.8.0")) 110 + } 105 111 v := ctx.BuildInstance(inst) 106 112 if err := v.Validate(); err != nil { 107 113 t.Fatal(err)