Skip to content

Commit 385c2bd

Browse files
committed
from-tasty: Remove sources from dottydoc interface
When running with `-from-tasty`, the dottydoc interface in the sbt bridge will remove the scala sources that are passed to dottydoc.
1 parent 0688420 commit 385c2bd

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed
Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
11
package dotty.tools.dotc.fromtasty
22

33
import dotty.tools.dotc.CompilationUnit
4-
import dotty.tools.dotc.core.Contexts.Context
54
import dotty.tools.dotc.util.NoSource
6-
import dotty.tools.io.File
75

86
class TASTYCompilationUnit(val className: String) extends CompilationUnit(NoSource) {
97
override def toString: String = s"class file $className"
108
}
11-
object TASTYCompilationUnit {
12-
def apply(className: String)(implicit ctx: Context): Option[TASTYCompilationUnit] = {
13-
if (File(className).exists) {
14-
ctx.inform(s"Ignoring $className: cannot create a `TASTYCompilationUnit` for a source file.")
15-
None
16-
} else {
17-
Some(new TASTYCompilationUnit(className))
18-
}
19-
}
20-
}

compiler/src/dotty/tools/dotc/fromtasty/TASTYRun.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package fromtasty
55
import core.Contexts._
66

77
class TASTYRun(comp: Compiler, ictx: Context) extends Run(comp, ictx) {
8-
override def compile(classNames: List[String]) = {
9-
val units = classNames.flatMap(TASTYCompilationUnit(_)(ictx))
8+
override def compile(classNames: List[String]): Unit = {
9+
val units = classNames.map(new TASTYCompilationUnit(_))
1010
compileUnits(units)
1111
}
1212
}

sbt-bridge/src/xsbt/ScaladocInterface.scala

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package xsbt
66
import xsbti.{ Logger, Severity }
77
import java.net.URL
88
import java.util.Optional
9+
import java.nio.file.{Files, Paths}
910

1011
import dotty.tools.dotc.core.Contexts.{ Context, ContextBase }
1112
import dotty.tools.dotc.reporting.Reporter
@@ -16,9 +17,21 @@ class ScaladocInterface {
1617
}
1718
}
1819

19-
class DottydocRunner(args: Array[String], log: Logger, delegate: xsbti.Reporter) {
20+
class DottydocRunner(args0: Array[String], log: Logger, delegate: xsbti.Reporter) {
2021
def run(): Unit = {
21-
log.debug(() => args.mkString("Calling Dottydoc with arguments (ScaladocInterface):\n\t", "\n\t", ""))
22+
log.debug(() => args0.mkString("Calling Dottydoc with arguments (ScaladocInterface):\n\t", "\n\t", ""))
23+
24+
val args = {
25+
// When running with `-from-tasty`, remove the source files from arg list.
26+
if (args0.contains("-from-tasty")) {
27+
val (excluded, retained) =
28+
args0.partition { arg =>
29+
(arg.endsWith(".scala") || arg.endsWith(".java")) && Files.exists(Paths.get(arg))
30+
}
31+
log.debug(() => excluded.mkString("Running `-from-tasty`, excluding source files:\n\t", "\n\t", ""))
32+
retained
33+
} else args0
34+
}
2235

2336
val ctx = (new ContextBase).initialCtx.fresh
2437
.setReporter(new DelegatingReporter(delegate))

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ object DottyPlugin extends AutoPlugin {
223223
sources := {
224224
val _ = compile.value // Ensure that everything is compiled, so TASTy is available.
225225
val prev = sources.value
226-
val tastyFiles = (classDirectory.value ** "*tasty").get.map(_.getAbsoluteFile)
226+
val tastyFiles = (classDirectory.value ** "*.tasty").get.map(_.getAbsoluteFile)
227227
prev ++ tastyFiles
228228
},
229229
scalacOptions += "-from-tasty"

0 commit comments

Comments
 (0)