func main()

in scripts/resolve_thrift/main.go [38:89]


func main() {
	thriftFile := os.Args[1]
	if !strings.HasSuffix(thriftFile, ".thrift") {
		fmt.Printf("Skipping compilation: %s is not a thrift file", thriftFile)
		return
	}

	module, err := compile.Compile(thriftFile)
	if err != nil {
		panic(fmt.Sprintf("Failed to parse thrift file: %s", thriftFile))
	}
	thisThriftPath := module.ThriftPath
	fmt.Println(thisThriftPath)

	var unwrapAnnot = fmt.Sprintf(codegen.AntHTTPReqDefBoxed, os.Args[2])

	for _, service := range module.Services {
		for _, method := range service.Functions {
			if method.Annotations[unwrapAnnot] == "true" {
				if len(method.ArgsSpec) < 1 {
					panic(fmt.Sprintf("Annotation %q found on method %q, but no argument found: %s",
						unwrapAnnot, method.Name, service.ThriftFile(),
					))
				}

				argThriftPath := method.ArgsSpec[0].Type.ThriftFile()
				if argThriftPath != "" && argThriftPath != thisThriftPath {
					fmt.Println(argThriftPath)
				}

			}

			if method.ResultSpec == nil {
				continue
			}

			if method.ResultSpec.ReturnType != nil {
				returnThriftPath := method.ResultSpec.ReturnType.ThriftFile()
				if returnThriftPath != "" && returnThriftPath != thisThriftPath {
					fmt.Println(returnThriftPath)
				}
			}

			for _, exp := range method.ResultSpec.Exceptions {
				exceptionThriftPath := exp.Type.ThriftFile()
				if exceptionThriftPath != thisThriftPath {
					fmt.Println(exceptionThriftPath)
				}
			}
		}
	}
}