@@ -98,13 +98,14 @@ public static Semanticdb.TextDocument manifestOccurrencesForSyntheticSymbols(
9898 if (definition != null ) {
9999 continue ;
100100 }
101- for (String alternativeSymbol : alternativeSymbols (info )) {
101+ for (Semanticdb . SymbolOccurrence alternativeSymbol : alternativeSymbols (info )) {
102102 Semanticdb .SymbolOccurrence alternativeDefinition =
103- definitionOccurrences .get (alternativeSymbol );
103+ definitionOccurrences .get (alternativeSymbol . getSymbol () );
104104 if (alternativeDefinition != null ) {
105105 builder .addOccurrences (
106- Semanticdb .SymbolOccurrence .newBuilder (alternativeDefinition )
107- .setRole (Semanticdb .SymbolOccurrence .Role .SYNTHETIC_DEFINITION )
106+ Semanticdb .SymbolOccurrence .newBuilder ()
107+ .setRange (alternativeDefinition .getRange ())
108+ .setRole (alternativeSymbol .getRole ())
108109 .setSymbol (info .getSymbol ()));
109110 break ;
110111 }
@@ -118,29 +119,31 @@ public static Semanticdb.TextDocument manifestOccurrencesForSyntheticSymbols(
118119 public static final Set <String > syntheticCompanionObjectNames =
119120 new HashSet <>(Arrays .asList ("apply" , "copy" ));
120121
121- public static List <String > alternativeSymbols (Semanticdb .SymbolInformation info ) {
122- ArrayList <String > alternatives = new ArrayList <>();
122+ public static List <Semanticdb .SymbolOccurrence > alternativeSymbols (
123+ Semanticdb .SymbolInformation info ) {
124+ SymbolOccurrences alternatives = new SymbolOccurrences ();
123125 SymbolDescriptor sym = SymbolDescriptor .parseFromSymbol (info .getSymbol ());
124126 switch (sym .descriptor .kind ) {
125127 case Method :
126128 if (sym .descriptor .name .endsWith ("_=" )) {
127129 String newName = sym .descriptor .name .substring (0 , sym .descriptor .name .length () - 2 );
128- alternatives .add (SemanticdbSymbols .global (sym .owner , sym .descriptor .withName (newName )));
130+ alternatives .addDefinition (
131+ SemanticdbSymbols .global (sym .owner , sym .descriptor .withName (newName )));
129132 } else if (syntheticCaseClassMethodNames .contains (sym .descriptor .name )) {
130- alternatives .add (sym .owner );
133+ alternatives .addSyntheticDefinition (sym .owner );
131134 } else if (syntheticCompanionObjectNames .contains (sym .descriptor .name )) {
132- alternatives .add (sym .owner );
135+ alternatives .addSyntheticDefinition (sym .owner );
133136 SymbolDescriptor owner = SymbolDescriptor .parseFromSymbol (sym .owner );
134- alternatives .add (
137+ alternatives .addSyntheticDefinition (
135138 SemanticdbSymbols .global (
136139 owner .owner , owner .descriptor .withKind (SemanticdbSymbols .Descriptor .Kind .Type )));
137140 }
138141 break ;
139142 case Parameter :
140143 SymbolDescriptor owner = SymbolDescriptor .parseFromSymbol (sym .owner );
141- if (owner .descriptor .name .equals ("copy" )) {
144+ if (owner .descriptor .name .equals ("copy" ) || owner . descriptor . name . equals ( "<init>" ) ) {
142145 // case classes copy method parameter.
143- alternatives .add (
146+ alternatives .addDefinition (
144147 SemanticdbSymbols .global (
145148 owner .owner , sym .descriptor .withKind (SemanticdbSymbols .Descriptor .Kind .Term )));
146149 } else if (owner .descriptor .name .equals ("apply" )) {
@@ -150,17 +153,18 @@ public static List<String> alternativeSymbols(Semanticdb.SymbolInformation info)
150153 SemanticdbSymbols .global (
151154 grandparent .owner ,
152155 grandparent .descriptor .withKind (SemanticdbSymbols .Descriptor .Kind .Type ));
153- alternatives .add (
156+ alternatives .addDefinition (
154157 SemanticdbSymbols .global (
155158 companion , sym .descriptor .withKind (SemanticdbSymbols .Descriptor .Kind .Term )));
156159 }
157160 case Term :
158- alternatives .add (
161+ alternatives .addDefinition (
159162 SemanticdbSymbols .global (
160163 sym .owner , sym .descriptor .withKind (SemanticdbSymbols .Descriptor .Kind .Type )));
161164 break ;
162165 default :
163166 }
164- return alternatives ;
167+
168+ return alternatives .occurrences ;
165169 }
166170}
0 commit comments