// Copyright 2023 CloudWeGo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package reflection_tpl

// File .
var FileRef = `// Code generated by thriftgo ({{Version}}). DO NOT EDIT.
{{InsertionPoint "bof"}}

package {{.FilePackage}}

import (
	{{InsertionPoint "imports"}}
	{{define "Imports"}}
	{{end}}
	"reflect"

	"github.com/cloudwego/thriftgo/thrift_reflection"
)

{{$IDLName := .IDLName}}
{{$IDLPath := .AST.Filename}}
{{$FilePackage := .FilePackage}}

// IDL Name: {{$IDLName}}
// IDL Path: {{$IDLPath}}
// Remote Path: {{ .RefPath }}

var file_{{$IDLName}}_thrift *thrift_reflection.FileDescriptor

func init() {
	if file_{{$IDLName}}_thrift != nil {
		return
	}
	type x struct{}
	replacer := &thrift_reflection.FileDescriptorReplacer{
		RemoteGoPkgPath:  {{ backquoted .RefPath }},
		CurrentGoPkgPath: reflect.TypeOf(x{}).PkgPath(),
		CurrentFilepath:  {{ backquoted  $IDLPath }},
		Matcher:          "{{ .GetFirstDescriptor }}",
	}
	file_{{$IDLName}}_thrift = thrift_reflection.ReplaceFileDescriptor(replacer)
}

func GetFileDescriptorFor{{ToCamel $IDLName}}() *thrift_reflection.FileDescriptor{
	return file_{{$IDLName}}_thrift
}

{{- InsertionPoint "eof"}}
`
