File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed
compiler/src/dotty/tools/dotc/fromtasty
sbt-dotty/src/dotty/tools/sbtplugin Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 1
1
package dotty .tools .dotc .fromtasty
2
2
3
3
import dotty .tools .dotc .CompilationUnit
4
+ import dotty .tools .dotc .core .Contexts .Context
4
5
import dotty .tools .dotc .util .NoSource
6
+ import dotty .tools .io .Path
5
7
6
8
class TASTYCompilationUnit (val className : String ) extends CompilationUnit (NoSource ) {
7
9
override def toString = s " class file $className"
8
10
}
11
+ object TASTYCompilationUnit {
12
+ def apply (className : String )(implicit ctx : Context ): Option [TASTYCompilationUnit ] = {
13
+ if (Path (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
+ }
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import core.Contexts._
6
6
7
7
class TASTYRun (comp : Compiler , ictx : Context ) extends Run (comp, ictx) {
8
8
override def compile (classNames : List [String ]) = {
9
- val units = classNames.map( new TASTYCompilationUnit (_))
9
+ val units = classNames.flatMap( TASTYCompilationUnit (_)(ictx ))
10
10
compileUnits(units)
11
11
}
12
12
}
Original file line number Diff line number Diff line change @@ -194,10 +194,21 @@ object DottyPlugin extends AutoPlugin {
194
194
} else {
195
195
Def .task { si }
196
196
}
197
- }.value
198
- )
197
+ }.value,
198
+ ) ++ inConfig( Compile )(docSettings) ++ inConfig( Test )(docSettings)
199
199
}
200
200
201
+ private val docSettings = inTask(doc)(Seq (
202
+ scalacOptions := {
203
+ val prev = scalacOptions.value
204
+ val classNames = compile.value match { case analysis : sbt.internal.inc.Analysis => analysis.relations.classes._2s.toSeq }
205
+ " -from-tasty" +: (classNames ++ prev)
206
+ },
207
+ // `doc` normally uses `dependencyClasspath`. However, we need the products for this project
208
+ // to be on the classpath so that we can unpickle the doc from TASTY.
209
+ dependencyClasspath := fullClasspath.value
210
+ ))
211
+
201
212
/** Fetch artefacts for scalaOrganization.value %% moduleName % scalaVersion.value */
202
213
private def fetchArtifactsOf (moduleName : String ) = Def .task {
203
214
val dependencyResolution = Keys .dependencyResolution.value
You can’t perform that action at this time.
0 commit comments