Skip to content

Commit 70e95f6

Browse files
committed
chore: get namespace from annos
1 parent e9d9bb9 commit 70e95f6

File tree

3 files changed

+5
-31
lines changed

3 files changed

+5
-31
lines changed

thrift/descriptor.go

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,29 +117,17 @@ func (p Type) IsComplex() bool {
117117

118118
// TypeDescriptor is the runtime descriptor of a thrift type
119119
type TypeDescriptor struct {
120-
typ Type
121-
name string
122-
key *TypeDescriptor // for map key
123-
elem *TypeDescriptor // for slice or map element
124-
struc *StructDescriptor // for struct
125-
namespace string // for idl namespace
126-
file string // for idl absolute filepath
120+
typ Type
121+
name string
122+
key *TypeDescriptor // for map key
123+
elem *TypeDescriptor // for slice or map element
124+
struc *StructDescriptor // for struct
127125
}
128126

129127
const (
130128
nameBinary = "binary"
131129
)
132130

133-
// Namespace returns the namespace of the type
134-
func (d TypeDescriptor) Namespace() string {
135-
return d.namespace
136-
}
137-
138-
// File returns the file of the type
139-
func (d TypeDescriptor) File() string {
140-
return d.file
141-
}
142-
143131
// IsBinary tells if the type is binary type ([]byte)
144132
func (d TypeDescriptor) IsBinary() bool {
145133
if d.name == nameBinary {

thrift/idl.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -597,22 +597,16 @@ func parseType(ctx context.Context, t *parser.Type, tree *parser.Thrift, cache c
597597
switch t.Name {
598598
case "list":
599599
ty := &TypeDescriptor{name: t.Name}
600-
ty.namespace = thriftNamespace(tree)
601-
ty.file = tree.GetFilename()
602600
ty.typ = LIST
603601
ty.elem, err = parseType(ctx, t.ValueType, tree, cache, nextRecursionDepth, opts, nextAnns, parseTarget)
604602
return ty, err
605603
case "set":
606604
ty := &TypeDescriptor{name: t.Name}
607-
ty.namespace = thriftNamespace(tree)
608-
ty.file = tree.GetFilename()
609605
ty.typ = SET
610606
ty.elem, err = parseType(ctx, t.ValueType, tree, cache, nextRecursionDepth, opts, nextAnns, parseTarget)
611607
return ty, err
612608
case "map":
613609
ty := &TypeDescriptor{name: t.Name}
614-
ty.namespace = thriftNamespace(tree)
615-
ty.file = tree.GetFilename()
616610
ty.typ = MAP
617611
if ty.key, err = parseType(ctx, t.KeyType, tree, cache, nextRecursionDepth, opts, nextAnns, parseTarget); err != nil {
618612
return nil, err
@@ -686,8 +680,6 @@ func parseType(ctx context.Context, t *parser.Type, tree *parser.Thrift, cache c
686680
annotations: oannos,
687681
},
688682
}
689-
ty.namespace = thriftNamespace(tree)
690-
ty.file = tree.GetFilename()
691683

692684
if recursionDepth == 0 {
693685
ctx = context.WithValue(ctx, CtxKeyIsBodyRoot, true)

thrift/idl_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,6 @@ func TestNewDescriptorByName(t *testing.T) {
580580

581581
// Test parsing User struct with cross-file reference notation
582582
desc, err := opts.NewDescriptorByName(context.Background(), mainPath, "base.User", includes)
583-
// verify file and namespace correctness
584-
require.Equal(t, "base.thrift", desc.File())
585-
require.Equal(t, "kitex.test.base", desc.Namespace())
586583

587584
require.NoError(t, err)
588585
require.NotNil(t, desc)
@@ -638,9 +635,6 @@ func TestNewDescriptorByName(t *testing.T) {
638635

639636
// Test parsing UserRequest with relative path that goes up directories
640637
desc, err := opts.NewDescriptorByName(context.Background(), mainPath, "UserRequest", includes)
641-
// verify file and namespace correctness
642-
require.Equal(t, "a/b/main.thrift", desc.File())
643-
require.Equal(t, "kitex.test.server", desc.Namespace())
644638

645639
require.NoError(t, err)
646640
require.NotNil(t, desc)

0 commit comments

Comments
 (0)