@@ -321,16 +321,16 @@ class SemanticdbConsumer extends TastyConsumer {
321
321
}
322
322
323
323
def addSelfDefinition (name : String , range : s.Range ): Unit = {
324
- var localsymbol = Symbols .Local (local_offset.toString)
325
- local_offset += 1
326
- symbolsCache += ((name, range) -> localsymbol)
327
- occurrences =
328
- occurrences :+
329
- s.SymbolOccurrence (
330
- Some (range),
331
- localsymbol,
332
- s.SymbolOccurrence .Role .DEFINITION
333
- )
324
+ var localsymbol = Symbols .Local (local_offset.toString)
325
+ local_offset += 1
326
+ symbolsCache += ((name, range) -> localsymbol)
327
+ occurrences =
328
+ occurrences :+
329
+ s.SymbolOccurrence (
330
+ Some (range),
331
+ localsymbol,
332
+ s.SymbolOccurrence .Role .DEFINITION
333
+ )
334
334
}
335
335
336
336
def symbolToSymbolString (symbol : Symbol ): (String , Boolean ) = {
@@ -377,10 +377,14 @@ class SemanticdbConsumer extends TastyConsumer {
377
377
}
378
378
}
379
379
380
+ val reserverdFunctions : List [String ] = " apply" :: " unapply" :: Nil
380
381
def addOccurenceTree (tree : Tree ,
381
382
type_symbol : s.SymbolOccurrence .Role ,
382
383
range : s.Range ,
383
384
force_add : Boolean = false ): Unit = {
385
+ if (type_symbol != s.SymbolOccurrence .Role .DEFINITION && reserverdFunctions
386
+ .contains(tree.symbol.name))
387
+ return
384
388
if (tree.isUserCreated || (force_add && ! (! tree.isUserCreated && iterateParent(
385
389
tree.symbol) == " java/lang/Object#`<init>`()." ))) {
386
390
addOccurence(tree.symbol, type_symbol, range)
@@ -515,6 +519,30 @@ class SemanticdbConsumer extends TastyConsumer {
515
519
}
516
520
}
517
521
522
+ override def traversePattern (tree : Pattern )(implicit ctx : Context ): Unit = {
523
+ tree match {
524
+ 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
+ addOccurence(
532
+ tree.symbol,
533
+ s.SymbolOccurrence .Role .REFERENCE ,
534
+ s.Range (tree.symbol.pos.startLine,
535
+ tree.symbol.pos.startColumn,
536
+ tree.symbol.pos.endLine,
537
+ tree.symbol.pos.startColumn + name.length)
538
+ )
539
+ super .traversePattern(tree)
540
+ }
541
+ case _ =>
542
+ super .traversePattern(tree)
543
+ }
544
+ }
545
+
518
546
var fittedInitClassRange : Option [s.Range ] = None
519
547
var forceAddBecauseParents : Boolean = false
520
548
@@ -531,7 +559,6 @@ class SemanticdbConsumer extends TastyConsumer {
531
559
}
532
560
case Term .Apply (_, _) => {
533
561
super .traverseTree(tree)
534
-
535
562
}
536
563
case ClassDef (classname, constr, parents, selfopt, statements) => {
537
564
// we first add the class to the symbol list
@@ -561,27 +588,37 @@ class SemanticdbConsumer extends TastyConsumer {
561
588
forceAddBecauseParents = true
562
589
parents.foreach(_ match {
563
590
case IsTypeTree (t) => traverseTypeTree(t)
564
- case IsTerm (t) => {println(t.pos.startColumn, t.pos.endColumn)
565
- traverseTree(t)}
591
+ case IsTerm (t) => {
592
+ println(t.pos.startColumn, t.pos.endColumn)
593
+ traverseTree(t)
594
+ }
566
595
})
567
596
forceAddBecauseParents = false
568
597
569
-
570
-
571
598
selfopt match {
572
599
case Some (vdef @ ValDef (name, _, _)) => {
573
- val posColumn : Int = parents.foldLeft(vdef.pos.startColumn)((old : Int , ct : TermOrTypeTree ) =>
574
- ct match {
575
- case IsTerm (t) => if (t.pos.endColumn + 3 < old) {t.pos.endColumn+ 3 } else {old}
576
- case _ => old
577
- })
600
+ val posColumn : Int = parents.foldLeft(vdef.pos.startColumn)(
601
+ (old : Int , ct : TermOrTypeTree ) =>
602
+ ct match {
603
+ case IsTerm (t) =>
604
+ if (t.pos.endColumn + 3 < old) { t.pos.endColumn + 3 } else {
605
+ old
606
+ }
607
+ case _ => old
608
+ })
578
609
println(posColumn)
579
610
println(vdef)
580
- println(vdef.pos.startColumn, tree.pos.startColumn, tree.pos.endColumn)
581
- addSelfDefinition(name, s.Range (vdef.pos.startLine, posColumn, vdef.pos.endLine, posColumn + name.length))
611
+ println(vdef.pos.startColumn,
612
+ tree.pos.startColumn,
613
+ tree.pos.endColumn)
614
+ addSelfDefinition(name,
615
+ s.Range (vdef.pos.startLine,
616
+ posColumn,
617
+ vdef.pos.endLine,
618
+ posColumn + name.length))
582
619
println(name)
583
620
}
584
- case _ =>
621
+ case _ =>
585
622
}
586
623
selfopt.foreach(traverseTree)
587
624
@@ -640,7 +677,9 @@ class SemanticdbConsumer extends TastyConsumer {
640
677
}
641
678
642
679
case Term .This (what) =>
643
- addOccurenceTree(tree, s.SymbolOccurrence .Role .REFERENCE , posToRange(tree.pos).get)
680
+ addOccurenceTree(tree,
681
+ s.SymbolOccurrence .Role .REFERENCE ,
682
+ posToRange(tree.pos).get)
644
683
645
684
case Term .Select (qualifier, _, _) => {
646
685
val range = {
0 commit comments