Skip to content

Commit 71b9e3a

Browse files
committed
Add examples & add missing case for typetrees
1 parent eb580a3 commit 71b9e3a

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package example
2+
3+
class IgnoredTest {
4+
val _ = 2
5+
def foo(x: Int): Unit = {
6+
val _ = x
7+
}
8+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package example
2+
3+
class Multiple {
4+
def m19(x: Int)(z: Int = 3) = ???
5+
}

semanticdb/src/dotty/semanticdb/SemanticdbConsumer.scala

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -449,26 +449,32 @@ class SemanticdbConsumer extends TastyConsumer {
449449
})
450450
}
451451

452+
def extractTypeTree(tree: TypeOrBoundsTree) = tree match {
453+
case IsTypeTree(t) => t
454+
}
452455
override def traverseTypeTree(tree: TypeOrBoundsTree)(
453456
implicit ctx: Context): Unit = {
457+
println("type: ", tree)
454458
tree match {
455-
case TypeTree.Ident(_) => {
456-
tree match {
457-
case IsTypeTree(typetree) => {
459+
case TypeTree.Ident(_) => {
460+
val typetree = extractTypeTree(tree)
458461
addOccurenceTypeTree(typetree,
459462
s.SymbolOccurrence.Role.REFERENCE,
460463
s.Range(typetree.pos.startLine,
461464
typetree.pos.startColumn,
462465
typetree.pos.startLine,
463466
typetree.pos.endColumn))
464467
}
468+
case TypeTree.Select(qualifier, _) => {
469+
val typetree = extractTypeTree(tree)
470+
val range = rangeExclude(typetree.pos, qualifier.pos)
471+
addOccurenceTypeTree(typetree, s.SymbolOccurrence.Role.REFERENCE, range)
472+
super.traverseTypeTree(typetree)
473+
}
465474
case _ =>
466475
super.traverseTypeTree(tree)
467-
}
468-
}
469-
case _ =>
470-
super.traverseTypeTree(tree)
471476
}
477+
472478
}
473479

474480
/*override def traversePattern(tree: Pattern)(implicit ctx: Context): Unit = {

semanticdb/test/dotty/semanticdb/Tests.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class Tests {
182182
//@Test def testEmpty(): Unit = checkFile("example/Empty.scala")
183183
//@Test def testEmptyObject(): Unit = checkFile("example/EmptyObject.scala")
184184
//@Test def testExample(): Unit = checkFile("example/Example.scala")
185-
@Test def testExample2(): Unit = checkFile("example/Example2.scala")
185+
//@Test def testExample2(): Unit = checkFile("example/Example2.scala")
186186
//@Test def testExclude(): Unit = checkFile("example/Exclude.scala")
187187
//WIP @Test def testFlags(): Unit = checkFile("example/Flags.scala")
188188
//@Test def testImports(): Unit = checkFile("example/Imports.scala")
@@ -191,7 +191,8 @@ class Tests {
191191
//@Test def testLocals(): Unit = checkFile("example/Locals.scala")
192192
//@Test def testMacroAnnotations(): Unit = checkFile("example/MacroAnnotations.scala")
193193
//WIP @Test def testMethods(): Unit = checkFile("example/Methods.scala")
194-
//WIP @Test def testMethodUsages(): Unit = checkFile("example/MethodUsages.scala")
194+
//WIP @Test def testMultiArguments(): Unit = checkFile("example/MultiArguments.scala")
195+
@Test def testMethodUsages(): Unit = checkFile("example/MethodUsages.scala")
195196
//@Test def testObjects(): Unit = checkFile("example/Objects.scala")
196197
//@Test def testOverrides(): Unit = checkFile("example/Overrides.scala")
197198
//WIP @Test def testPrefixes(): Unit = checkFile("example/Prefixes.scala")

0 commit comments

Comments
 (0)