@@ -91,6 +91,8 @@ class SemanticdbConsumer extends TastyConsumer {
91
91
case _ => false
92
92
}
93
93
94
+ def isDefaultGetter : Boolean = symbol.name.contains(tpnme.DEFAULT_GETTER .toString)
95
+
94
96
def isParameter : Boolean = symbol.flags.is(Flags .Param )
95
97
96
98
def isObject : Boolean = symbol.flags.is(Flags .Object )
@@ -222,6 +224,7 @@ class SemanticdbConsumer extends TastyConsumer {
222
224
def isUseless (implicit ctx : Context ): Boolean = {
223
225
symbol == NoSymbol ||
224
226
// symbol.isInitChild ||
227
+ symbol.isDefaultGetter ||
225
228
symbol.isWildCard ||
226
229
symbol.isAnonymousClass ||
227
230
symbol.isAnonymousFunction ||
@@ -303,7 +306,7 @@ class SemanticdbConsumer extends TastyConsumer {
303
306
case _ =>
304
307
d.Term (symbol.name)
305
308
}
306
- } else if (symbol.isMethod) {
309
+ } else if (symbol.isMethod || symbol.isUsefulField ) {
307
310
d.Method (symbol.name,
308
311
disimbiguate(previous_symbol + symbol.name, symbol))
309
312
} else if (symbol.isTypeParameter) {
@@ -358,23 +361,28 @@ class SemanticdbConsumer extends TastyConsumer {
358
361
case _ =>
359
362
symbolToSymbolString(symbol)
360
363
}
361
-
362
364
if (symbol_path == " " || symbol.isUselessOccurrence) return
363
- println(symbol_path, range, symbol.owner.flags)
364
365
365
366
val key = (symbol_path, range)
366
- if (! is_global || ! (symbolPathsMap.contains(key))) {
367
- if (is_global) {
368
- symbolPathsMap += key
369
- }
370
- occurrences =
371
- occurrences :+
372
- s.SymbolOccurrence (
373
- Some (range),
374
- symbol_path,
375
- type_symbol
376
- )
377
- }
367
+ // TODO: refactor the following
368
+
369
+ // this is to avoid duplicates symbols
370
+ // For example, when we define a class as: `class foo(x: Int)`,
371
+ // dotty will generate a ValDef for the x, but the x will also
372
+ // be present in the constructor, thus making a double definition
373
+ if (symbolPathsMap.contains(key)) return
374
+ if (is_global) {
375
+ symbolPathsMap += key
376
+ println(" duplicates" , key)
377
+ }
378
+ println(symbol_path, range, symbol.owner.flags, is_global)
379
+ occurrences =
380
+ occurrences :+
381
+ s.SymbolOccurrence (
382
+ Some (range),
383
+ symbol_path,
384
+ type_symbol
385
+ )
378
386
}
379
387
380
388
val reserverdFunctions : List [String ] = " apply" :: " unapply" :: Nil
@@ -522,12 +530,6 @@ class SemanticdbConsumer extends TastyConsumer {
522
530
override def traversePattern (tree : Pattern )(implicit ctx : Context ): Unit = {
523
531
tree match {
524
532
case Pattern .Bind (name, _) => {
525
- println(" [bind]" ,
526
- tree.pos.startColumn,
527
- tree.pos.endColumn,
528
- tree.symbol,
529
- tree.symbol.pos.startColumn,
530
- tree.symbol.pos.endColumn)
531
533
addOccurence(
532
534
tree.symbol,
533
535
s.SymbolOccurrence .Role .REFERENCE ,
@@ -681,7 +683,7 @@ class SemanticdbConsumer extends TastyConsumer {
681
683
s.SymbolOccurrence .Role .REFERENCE ,
682
684
posToRange(tree.pos).get)
683
685
684
- case Term .Select (qualifier, _, _ ) => {
686
+ case Term .Select (qualifier, _) => {
685
687
val range = {
686
688
val r = rangeSelect(tree.symbol.name, tree.pos)
687
689
if (tree.symbol.name == " <init>" )
0 commit comments