@@ -14,6 +14,8 @@ type SymbolFormatter struct {
14
14
IncludePackageName func (name string ) bool
15
15
IncludePackageVersion func (version string ) bool
16
16
IncludeDescriptor func (descriptor string ) bool
17
+ IncludeRawDescriptor func (descriptor * Descriptor ) bool
18
+ IncludeDisambiguator func (disambiguator string ) bool
17
19
}
18
20
19
21
// VerboseSymbolFormatter formats all parts of the symbol.
@@ -24,6 +26,8 @@ var VerboseSymbolFormatter = SymbolFormatter{
24
26
IncludePackageName : func (_ string ) bool { return true },
25
27
IncludePackageVersion : func (_ string ) bool { return true },
26
28
IncludeDescriptor : func (_ string ) bool { return true },
29
+ IncludeRawDescriptor : func (_ * Descriptor ) bool { return true },
30
+ IncludeDisambiguator : func (_ string ) bool { return true },
27
31
}
28
32
29
33
// Same as VerboseSymbolFormatter but silently ignores errors.
@@ -34,6 +38,8 @@ var LenientVerboseSymbolFormatter = SymbolFormatter{
34
38
IncludePackageName : func (_ string ) bool { return true },
35
39
IncludePackageVersion : func (_ string ) bool { return true },
36
40
IncludeDescriptor : func (_ string ) bool { return true },
41
+ IncludeRawDescriptor : func (_ * Descriptor ) bool { return true },
42
+ IncludeDisambiguator : func (_ string ) bool { return true },
37
43
}
38
44
39
45
// DescriptorOnlyFormatter formats only the descriptor part of the symbol.
@@ -44,6 +50,8 @@ var DescriptorOnlyFormatter = SymbolFormatter{
44
50
IncludePackageName : func (_ string ) bool { return false },
45
51
IncludePackageVersion : func (_ string ) bool { return false },
46
52
IncludeDescriptor : func (_ string ) bool { return true },
53
+ IncludeRawDescriptor : func (_ * Descriptor ) bool { return true },
54
+ IncludeDisambiguator : func (_ string ) bool { return true },
47
55
}
48
56
49
57
func (f * SymbolFormatter ) Format (symbol string ) (string , error ) {
@@ -70,6 +78,9 @@ func (f *SymbolFormatter) FormatSymbol(symbol *Symbol) string {
70
78
}
71
79
descriptor := strings.Builder {}
72
80
for _ , desc := range symbol .Descriptors {
81
+ if ! f .IncludeRawDescriptor (desc ) {
82
+ continue
83
+ }
73
84
switch desc .Suffix {
74
85
case Descriptor_Namespace :
75
86
descriptor .WriteString (desc .Name )
@@ -83,7 +94,9 @@ func (f *SymbolFormatter) FormatSymbol(symbol *Symbol) string {
83
94
case Descriptor_Method :
84
95
descriptor .WriteString (desc .Name )
85
96
descriptor .WriteRune ('(' )
86
- descriptor .WriteString (desc .Disambiguator )
97
+ if f .IncludeDisambiguator (desc .Disambiguator ) {
98
+ descriptor .WriteString (desc .Disambiguator )
99
+ }
87
100
descriptor .WriteString (")." )
88
101
case Descriptor_TypeParameter :
89
102
descriptor .WriteRune ('[' )
0 commit comments