@@ -342,19 +342,6 @@ class SemanticdbConsumer extends TastyConsumer {
342
342
} else {
343
343
(iterateParent(symbol), true )
344
344
}
345
- /* println(symbol, symbol.isUselessOccurrence)
346
-
347
- println(symbol, "isWildCard", symbol.isWildCard)
348
- println(symbol, "isAnonymousCl", symbol.isAnonymousClass)
349
- println(symbol, "isAnonymousFun", symbol.isAnonymousFunction)
350
- println(symbol, "isSyntheticCon", symbol.isSyntheticConstructor)
351
- println(symbol, "isStaticConstr", symbol.isStaticConstructor)
352
- println(symbol, "isLocalChil", symbol.isLocalChild)
353
- println(symbol, "isSyntheticVal", symbol.isSyntheticValueClassCompanion)
354
- println(symbol, "isUselessFie", symbol.isUselessField)
355
- println(symbol, "isSyntheticCas", symbol.isSyntheticCaseAccessor)
356
- println(symbol, "isRefinementCl", symbol.isRefinementClass)
357
- println(symbol, "isSyntheticJav", symbol.isSyntheticJavaModule)*/
358
345
359
346
println(symbol_path, range)
360
347
if (symbol_path == " " || symbol.isUselessOccurrence) return
@@ -378,8 +365,7 @@ class SemanticdbConsumer extends TastyConsumer {
378
365
type_symbol : s.SymbolOccurrence .Role ,
379
366
range : s.Range ,
380
367
force_add : Boolean = false ): Unit = {
381
-
382
- if (tree.isUserCreated || force_add) {
368
+ if (tree.isUserCreated || (force_add && ! (! tree.isUserCreated && iterateParent(tree.symbol) == " java/lang/Object#`<init>`()." ))) {
383
369
addOccurence(tree.symbol, type_symbol, range)
384
370
}
385
371
}
@@ -475,96 +461,8 @@ class SemanticdbConsumer extends TastyConsumer {
475
461
case IsTypeTree (t) => t
476
462
}
477
463
478
- /*
479
- def traverseType(tree: TypeOrBounds)(implicit ctx: Context): Unit = {
480
- //println(tree)
481
- tree match {
482
- case IsType(t) => {
483
- if(t.typeSymbol.pos.exists)
484
- println(t.typeSymbol, t.typeSymbol.pos.startColumn, t.typeSymbol.pos.endColumn)
485
- }
486
- case _ => ()
487
- }
488
- tree match {
489
- case Type.ConstantType(Constant.Symbol(symbol)) =>
490
- println("TYPE", symbol)
491
- case Type.ConstantType(_) => {println("CNST")}
492
- case Type.SymRef(_, a) => {
493
- traverseType(a)
494
- }
495
- case Type.TermRef(_, a) => {
496
- traverseType(a)
497
- }
498
- case Type.TypeRef(_, a) => {
499
- traverseType(a)
500
- }
501
- case Type.SuperType(a, b) => {
502
- traverseType(a)
503
- traverseType(b)
504
- }
505
- case Type.Refinement(a, _, b) => {
506
- traverseType(a)
507
- traverseType(b)
508
- }
509
- case Type.AppliedType(a, l) => {
510
- traverseType(a)
511
- l.foreach(traverseType)
512
- }
513
- case Type.AnnotatedType(a, b) => {
514
- traverseType(a)
515
- super.traverseTree(b)
516
- }
517
- case Type.AndType(a, b) => {
518
- traverseType(a)
519
- traverseType(b)
520
- }
521
- case Type.OrType(a, b) => {
522
- traverseType(a)
523
- traverseType(b)
524
- }
525
- case Type.MatchType(a, b, l) => {
526
- traverseType(a)
527
- traverseType(b)
528
- l.foreach(traverseType)
529
- }
530
- case Type.ByNameType(a) => {
531
- traverseType(a)
532
- }
533
- case Type.ParamRef(a, _) => {
534
- traverseType(a)
535
- }
536
- case Type.ThisType(a) => {
537
- traverseType(a)
538
- }
539
- case Type.RecursiveThis(a) => {
540
- traverseType(a)
541
- }
542
- case Type.RecursiveType(a) => {
543
- traverseType(a)
544
- }
545
- case Type.MethodType(_, l, a) => {
546
- traverseType(a)
547
- l.foreach(traverseType)
548
- }
549
- case Type.PolyType(_, l, a) => {
550
- traverseType(a)
551
- l.foreach(traverseType)
552
- }
553
- case Type.TypeLambda(_, l, a) => {
554
- traverseType(a)
555
- l.foreach(traverseType)
556
- }
557
- case NoPrefix() => ()
558
- case TypeBounds(a, b) => {
559
- traverseType(a)
560
- traverseType(b)
561
- }
562
- }
563
- }*/
564
-
565
464
override def traverseTypeTree (tree : TypeOrBoundsTree )(
566
465
implicit ctx : Context ): Unit = {
567
- // println("--->", tree)
568
466
tree match {
569
467
case TypeTree .Ident (_) => {
570
468
val typetree = extractTypeTree(tree)
@@ -585,92 +483,63 @@ class SemanticdbConsumer extends TastyConsumer {
585
483
}
586
484
case _ =>
587
485
super .traverseTypeTree(tree)
588
- /* case TypeTree.Applied(_, _) => {
589
- val typetree = extractTypeTree(tree)
590
- println("APPLIED", typetree.pos.startColumn, typetree.pos.endColumn)
591
- super.traverseTypeTree(tree)
592
- }
593
- case TypeTree.Synthetic() => {
594
- val typetree = extractTypeTree(tree)
595
- println("Synthetic", typetree.pos.startColumn, typetree.pos.endColumn)
596
- super.traverseTypeTree(tree)
597
- }
598
- case TypeTree.Project(_, _) => {
599
- println("Project")
600
- super.traverseTypeTree(tree)
601
- }
602
- case TypeTree.Singleton(_) => {
603
- println("Singleton")
604
- super.traverseTypeTree(tree)
605
- }
606
- case TypeTree.Refined(_, _) => {
607
- println("Refined")
608
- super.traverseTypeTree(tree)
609
- }
610
- case TypeTree.Annotated(_, _) => {
611
- println("Annotated")
612
- super.traverseTypeTree(tree)
613
- }
614
- case TypeTree.And(_, _) => {
615
- println("And")
616
- super.traverseTypeTree(tree)
617
- }
618
- case TypeTree.Or(_, _) => {
619
- println("Or")
620
- super.traverseTypeTree(tree)
621
- }
622
- case TypeTree.MatchType(_, _, _) => {
623
- println("MatchType")
624
- super.traverseTypeTree(tree)
625
- }
626
- case TypeTree.ByName(_, _, _) => {
627
- println("ByName")
628
- super.traverseTypeTree(tree)
629
- }
630
- case TypeTree.TypeLambdaTree(_, _) => {
631
- println("TypeLambdaTree")
632
- super.traverseTypeTree(tree)
633
- }
634
- case TypeTree.Bind(_, _) => {
635
- println("Bind")
636
- super.traverseTypeTree(tree)
637
- }
638
- case TypeTree.Block(_, _) => {
639
- println("Block")
640
- super.traverseTypeTree(tree)
641
- }
642
- case SyntheticBounds() => {
643
- println("synthetic bounds")
644
- super.traverseTypeTree(tree)
645
- }
646
- case TypeBoundsTree(_, _) => {
647
- //println("typetree")
648
- super.traverseTypeTree(tree)
649
- }*/
650
486
}
651
-
652
487
}
653
488
489
+ var fittedInitClassRange : Option [s.Range ] = None
490
+ var forceAddBecauseParents : Boolean = false
491
+
654
492
override def traverseTree (tree : Tree )(implicit ctx : Context ): Unit = {
655
- /* println("\n")
656
- println(tree)
657
- println(tree.pos.startColumn, tree.symbol.name, tree.pos.endColumn)*/
658
493
tree match {
659
494
case Import (path, selectors) =>
660
495
val key = (tree.symbol.name, tree.pos.start)
661
496
if (! package_definitions(key)) {
662
497
package_definitions += key
663
498
getImportSelectors(getImportPath(path), selectors)
664
499
}
665
- case Term .New (_ ) => {
500
+ case Term .New (ty ) => {
666
501
super .traverseTree(tree)
667
502
}
668
503
case Term .Apply (_, _) => {
669
- println(" ---------------" )
670
- println(tree.symbol)
671
504
super .traverseTree(tree)
672
505
673
506
}
507
+ case ClassDef (classname, constr, parents, selfopt, statements) => {
508
+ // we first add the class to the symbol list
509
+ addOccurenceTree(tree,
510
+ s.SymbolOccurrence .Role .DEFINITION ,
511
+ range(tree, tree.symbol.pos, tree.symbol.name))
512
+ println(" constr symbol pos: " , constr.symbol.pos.startColumn, constr.symbol.pos.endColumn)
513
+ println(" constr pos: " , constr.pos.startColumn, constr.pos.endColumn)
514
+ // then the constructor
515
+ if (! constr.isUserCreated) {
516
+ fittedInitClassRange = Some (
517
+ s.Range (tree.symbol.pos.startLine,
518
+ tree.symbol.pos.startColumn + classname.length + 1 ,
519
+ tree.symbol.pos.startLine,
520
+ tree.symbol.pos.startColumn + classname.length + 1 ))
521
+ } else {
522
+ fittedInitClassRange = Some (s.Range (constr.symbol.pos.startLine,
523
+ constr.symbol.pos.startColumn,
524
+ constr.symbol.pos.endLine,
525
+ constr.symbol.pos.endColumn))
526
+ }
527
+ traverseTree(constr)
528
+ fittedInitClassRange = None
529
+
530
+ // we add the parents to the symbol list
531
+ forceAddBecauseParents = true
532
+ parents.foreach(_ match {
533
+ case IsTypeTree (t) => traverseTypeTree(t)
534
+ case IsTerm (t) => traverseTree(t)
535
+ })
536
+ forceAddBecauseParents = false
537
+
538
+ selfopt.foreach(traverseTree)
539
+
540
+
541
+ statements.foreach(traverseTree)
542
+ }
674
543
case IsDefinition (cdef) => {
675
544
676
545
if (cdef.symbol.flags.is(Flags .Protected )) {
@@ -706,22 +575,13 @@ class SemanticdbConsumer extends TastyConsumer {
706
575
}
707
576
if (tree.symbol.name != " <none>" ) {
708
577
val range_symbol = range(tree, tree.symbol.pos, tree.symbol.name)
709
- println(tree.symbol.flags)
710
- println(tree.symbol.pos.startColumn,
711
- tree.symbol.pos.endColumn,
712
- tree.pos.startColumn,
713
- tree.pos.endColumn)
714
- if (tree.symbol.name == " <init>" && (! tree.isUserCreated || tree.symbol.pos.startColumn == tree.symbol.pos.endColumn) && ! tree.symbol.owner.flags.is(Flags .Object )) {
715
- println(" yes" )
716
- val range_symbol2 = s.Range (tree.pos.startLine,
717
- tree.pos.endColumn,
718
- tree.pos.endLine,
719
- tree.pos.endColumn)
578
+ if (tree.symbol.name == " <init>" && tree.symbol.flags.is(Flags .Object )) {
579
+
580
+ } else if (tree.symbol.name == " <init>" && fittedInitClassRange != None ) {
720
581
addOccurenceTree(tree,
721
582
s.SymbolOccurrence .Role .DEFINITION ,
722
- range_symbol2 ,
583
+ fittedInitClassRange.get ,
723
584
true )
724
-
725
585
} else {
726
586
addOccurenceTree(tree,
727
587
s.SymbolOccurrence .Role .DEFINITION ,
@@ -732,7 +592,6 @@ class SemanticdbConsumer extends TastyConsumer {
732
592
}
733
593
734
594
case Term .Select (qualifier, _) => {
735
- println(" [Select] " + tree.symbol + " <-> " + qualifier)
736
595
val range = {
737
596
val r = rangeSelect(tree.symbol.name, tree.pos)
738
597
if (tree.symbol.name == " <init>" )
@@ -750,17 +609,13 @@ class SemanticdbConsumer extends TastyConsumer {
750
609
}
751
610
752
611
case Term .Ident (name) => {
753
- println(" [Ident] " + name)
754
612
addOccurenceTree(tree,
755
613
s.SymbolOccurrence .Role .REFERENCE ,
756
614
range(tree, tree.pos, tree.symbol.name))
757
615
758
616
super .traverseTree(tree)
759
617
}
760
618
761
- case Term .Literal (name) => {
762
- println(" Litteral: " + name)
763
- }
764
619
case PackageClause (_) =>
765
620
val key = (tree.symbol.name, tree.pos.start)
766
621
if (! package_definitions(key)) {
0 commit comments