Skip to content

Commit d2c1e13

Browse files
committed
Able to consume tasty from semanticdb's tests
1 parent 2d23cba commit d2c1e13

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

semanticdb/test/dotty/semanticdb/Tests.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,24 @@ class Tests {
2525

2626
/** TODO: Produce semanticdb from TASTy for this Scala source file. */
2727
def getTastySemanticdb(scalaFile: Path): s.TextDocument = {
28-
???
28+
val scalac = getScalacSemanticdb(scalaFile)
29+
val pat = """(.*)\.scala""".r
30+
val classpath = scalaFile.getParent().toString()
31+
val modulename = sourceDirectory.relativize(scalaFile).getParent().getFileName().toString()
32+
val sourcename =
33+
scalaFile.toFile().getName().toString() match {
34+
case pat(name) => name
35+
case _ => ""
36+
}
37+
val _ = ConsumeTasty(classpath, (modulename + "." + sourcename) :: Nil, new SemanticdbConsumer)
38+
return s.TextDocument(text = scalac.text)
2939
}
3040

3141
/** Fails the test if the s.TextDocument from tasty and semanticdb-scalac are not the same. */
3242
def checkFile(filename: String): Unit = {
3343
val path = sourceDirectory.resolve(filename)
3444
val scalac = getScalacSemanticdb(path)
35-
val tasty = s.TextDocument(text = scalac.text) // TODO: replace with `getTastySemanticdb(path)`
45+
val tasty = getTastySemanticdb(path)
3646
val obtained = Semanticdbs.printTextDocument(tasty)
3747
val expected = Semanticdbs.printTextDocument(scalac)
3848
assertNoDiff(obtained, expected)

0 commit comments

Comments
 (0)