@@ -6,7 +6,8 @@ import core.transform._
66import dotc .core .Contexts .Context
77import dotc .core .Phases .Phase
88import dotc .core .Mode
9- import dotc .{Compiler , Run }
9+ import dotc .{Compiler , CompilationUnit , Run }
10+ import dotc .typer .FrontEnd
1011
1112import dotty .tools .dotc .fromtasty .{ReadTastyTreesFromClasses , TASTYRun }
1213import dotty .tools .dotc .transform .CookComments
@@ -29,36 +30,48 @@ class DocCompiler extends Compiler {
2930 if (ctx.settings.fromTasty.value) {
3031 reset()
3132 new TASTYRun (this , ctx.addMode(Mode .ReadPositions ).addMode(Mode .ReadComments ))
32- } else {
33- super .newRun
3433 }
34+ else
35+ super .newRun
3536 }
3637
37- override protected def frontendPhases : List [List [Phase ]] =
38- List (new ReadTastyTreesFromClasses ) ::
39- List (new DocFrontEnd ) :: Nil
40-
41- override protected def picklerPhases : List [List [Phase ]] =
42- Nil
38+ /** `DocFrontEnd` uses the Dotty `FrontEnd` without discarding the AnyVal
39+ * interfaces for Boolean, Int, Char, Long, Byte etc.
40+ *
41+ * If `-from-tasty` is set, then the trees and documentation will be loaded
42+ * from TASTY. The comments will be cooked after being unpickled.
43+ *
44+ * It currently still throws away Java sources by overriding
45+ * `discardAfterTyper`.
46+ */
47+ private class DocFrontEnd extends FrontEnd {
48+ override protected def discardAfterTyper (unit : CompilationUnit )(implicit ctx : Context ) =
49+ unit.isJava
4350
44- override protected def transformPhases : List [List [Phase ]] =
45- List (new CookComments ) ::
46- List (new DocImplicitsPhase ) ::
47- List (new DocASTPhase ) ::
48- List (DocMiniTransformations (new UsecasePhase ,
49- new DocstringPhase )) ::
50- List (DocMiniTransformations (new PackageObjectsPhase ,
51- new LinkReturnTypes ,
52- new LinkParamListTypes ,
53- new LinkImplicitlyAddedTypes ,
54- new LinkSuperTypes ,
55- new LinkCompanions ,
56- new AlternateConstructors ,
57- new SortMembers )) ::
58- List (DocMiniTransformations (new RemoveEmptyPackages )) ::
59- Nil
60-
61- override protected def backendPhases : List [List [Phase ]] =
62- List (new StatisticsPhase ) :: Nil
51+ override def isRunnable (implicit ctx : Context ): Boolean =
52+ super .isRunnable && ! ctx.settings.fromTasty.value
53+ }
6354
55+ override def phases : List [List [Phase ]] = List (
56+ List (new ReadTastyTreesFromClasses ),
57+ List (new DocFrontEnd ),
58+ List (new CookComments ),
59+ List (new DocImplicitsPhase ),
60+ List (new DocASTPhase ),
61+ List (DocMiniTransformations (
62+ new UsecasePhase ,
63+ new DocstringPhase )),
64+ List (DocMiniTransformations (
65+ new PackageObjectsPhase ,
66+ new LinkReturnTypes ,
67+ new LinkParamListTypes ,
68+ new LinkImplicitlyAddedTypes ,
69+ new LinkSuperTypes ,
70+ new LinkCompanions ,
71+ new AlternateConstructors ,
72+ new SortMembers )),
73+ List (DocMiniTransformations (
74+ new RemoveEmptyPackages )),
75+ List (new StatisticsPhase )
76+ )
6477}
0 commit comments