-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastkit.go
30 lines (25 loc) · 1.19 KB
/
astkit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package astkit
import (
"context"
"github.com/influx6/astkit/compiler"
)
// Transform takes provided package path returning a package
// definition with all dependencies and a map containing all
// indexed packages, else an error if any occurred.
// definition with all dependencies.
func Transform(ctx context.Context, pkg string) (*compiler.Package, map[string]*compiler.Package, error) {
return TransformWith(ctx, pkg, compiler.Cg{})
}
// TransformWith takes provided package path returning a package
// definition with all dependencies using the compiler.Cg provided.
// It also returns a map containing all indexed packages, else an error
// if any occurred.
func TransformWith(ctx context.Context, pkg string, c compiler.Cg) (*compiler.Package, map[string]*compiler.Package, error) {
index := compiler.NewIndexer(c)
return index.Index(ctx, pkg)
}
// WithPreloaded takes provided package path and preloaded packages to generate package structures.
func TransformWithPreloaded(ctx context.Context, pkg string, c compiler.Cg, preloaded map[string]*compiler.Package) (*compiler.Package, map[string]*compiler.Package, error) {
index := compiler.PreloadedIndexer(c, preloaded)
return index.Index(ctx, pkg)
}