Example #1
0
func fluxPath(obj types.Object) string {
	pkg, err := build.Import(obj.GetPkg().Path, "", build.FindOnly)
	if err != nil {
		fmt.Println("error importing \"%s\": %s\n", obj.GetPkg().Path, err)
		return ""
	}

	name := obj.GetName()
	if !obj.IsExported() { // unexported names are suffixed with "-" to avoid possible conflicts on case-insensitive systems
		name += "-"
	}
	if isMethod(obj) {
		t, _ := indirect(obj.GetType().(*types.Signature).Recv.Type)
		recv := t.(*types.Named).Obj
		typeName := recv.Name
		if !recv.IsExported() {
			typeName += "-"
		}
		name = typeName + "." + name
	}
	return filepath.Join(pkg.Dir, name+".flux.go")
}
Example #2
0
func invisible(obj types.Object, p *types.Package) bool {
	p2 := obj.GetPkg()
	return !(p2 == nil || p == nil || p2 == p || obj.IsExported())
}