@@ -6,6 +6,7 @@ import scala.collection.{mutable, SortedSet}
66trait BasePluginPhase [CompilationUnit , Tree , Symbol ] { self : GraphAnalysis [Tree ] =>
77 protected val cycleReporter : Seq [(Value , SortedSet [Int ])] => Unit
88 protected def force : Boolean
9+ protected def forcePkg : Boolean
910 protected def fatal : Boolean
1011
1112 def treeLine (tree : Tree ): Int
@@ -22,6 +23,8 @@ trait BasePluginPhase[CompilationUnit, Tree, Symbol] { self: GraphAnalysis[Tree]
2223 def unitPkgName (unit : CompilationUnit ): List [String ]
2324 def findPkgObjects (tree : Tree ): List [Tree ]
2425 def pkgObjectName (pkgObject : Tree ): String
26+ def findPkgs (tree : Tree ): List [Tree ]
27+ def pkgName (tree : Tree ): String
2528 def hasAcyclicImport (tree : Tree , selector : String ): Boolean
2629
2730 def extractDependencies (unit : CompilationUnit ): Seq [(Symbol , Tree )]
@@ -39,15 +42,22 @@ trait BasePluginPhase[CompilationUnit, Tree, Symbol] { self: GraphAnalysis[Tree]
3942 } yield {
4043 Value .File (unitPath(unit), unitPkgName(unit))
4144 }
42-
43- val acyclicPkgNames = for {
44- unit <- units
45- pkgObject <- findPkgObjects(unitTree(unit))
46- if hasAcyclicImport(pkgObject, " pkg" )
47- } yield Value .Pkg (pkgObjectName(pkgObject).split('.' ).toList)
45+ val stdPackages = if (forcePkg) packages else Seq .empty[Value .Pkg ]
46+ val acyclicPkgNames = packageObjects ++ stdPackages
4847 (skipNodePaths, acyclicNodePaths, acyclicPkgNames)
4948 }
5049
50+ private def packageObjects = for {
51+ unit <- units
52+ pkgObject <- findPkgObjects(unitTree(unit))
53+ if hasAcyclicImport(pkgObject, " pkg" )
54+ } yield Value .Pkg (pkgObjectName(pkgObject).split('.' ).toList)
55+
56+ private def packages : Seq [Value .Pkg ] = for {
57+ unit <- units
58+ pkgs <- findPkgs(unitTree(unit))
59+ } yield Value .Pkg (pkgName(pkgs).split('.' ).toList)
60+
5161 final def runAllUnits (): Unit = {
5262 val unitMap = units.map(u => unitPath(u) -> u).toMap
5363 val nodes = for (unit <- units) yield {
0 commit comments