@@ -23,7 +23,6 @@ import (
23
23
pathpkg "path"
24
24
"path/filepath"
25
25
"strings"
26
- "unicode"
27
26
28
27
"cuelang.org/go/cue/ast"
29
28
"cuelang.org/go/cue/build"
@@ -257,63 +256,3 @@ func (s *importStack) Pop() {
257
256
func (s * importStack ) Copy () []string {
258
257
return append ([]string {}, * s ... )
259
258
}
260
-
261
- // shorterThan reports whether sp is shorter than t.
262
- // We use this to record the shortest import sequences
263
- // that leads to a particular package.
264
- func (sp * importStack ) shorterThan (t []string ) bool {
265
- s := * sp
266
- if len (s ) != len (t ) {
267
- return len (s ) < len (t )
268
- }
269
- // If they are the same length, settle ties using string ordering.
270
- for i := range s {
271
- if s [i ] != t [i ] {
272
- return s [i ] < t [i ]
273
- }
274
- }
275
- return false // they are equal
276
- }
277
-
278
- // reusePackage reuses package p to satisfy the import at the top
279
- // of the import stack stk. If this use causes an import loop,
280
- // reusePackage updates p's error information to record the loop.
281
- func (l * loader ) reusePackage (p * build.Instance ) * build.Instance {
282
- // We use p.Internal.Imports==nil to detect a package that
283
- // is in the midst of its own loadPackage call
284
- // (all the recursion below happens before p.Internal.Imports gets set).
285
- if p .ImportPaths == nil {
286
- if err := lastError (p ); err == nil {
287
- err = l .errPkgf (nil , "import cycle not allowed" )
288
- err .IsImportCycle = true
289
- report (p , err )
290
- }
291
- p .Incomplete = true
292
- }
293
- // Don't rewrite the import stack in the error if we have an import cycle.
294
- // If we do, we'll lose the path that describes the cycle.
295
- if err := lastError (p ); err != nil && ! err .IsImportCycle && l .stk .shorterThan (err .ImportStack ) {
296
- err .ImportStack = l .stk .Copy ()
297
- }
298
- return p
299
- }
300
-
301
- // dirToImportPath returns the pseudo-import path we use for a package
302
- // outside the CUE path. It begins with _/ and then contains the full path
303
- // to the directory. If the package lives in c:\home\gopher\my\pkg then
304
- // the pseudo-import path is _/c_/home/gopher/my/pkg.
305
- // Using a pseudo-import path like this makes the ./ imports no longer
306
- // a special case, so that all the code to deal with ordinary imports works
307
- // automatically.
308
- func dirToImportPath (dir string ) string {
309
- return pathpkg .Join ("_" , strings .Map (makeImportValid , filepath .ToSlash (dir )))
310
- }
311
-
312
- func makeImportValid (r rune ) rune {
313
- // Should match Go spec, compilers, and ../../go/parser/parser.go:/isValidImport.
314
- const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD "
315
- if ! unicode .IsGraphic (r ) || unicode .IsSpace (r ) || strings .ContainsRune (illegalChars , r ) {
316
- return '_'
317
- }
318
- return r
319
- }
0 commit comments