@@ -4,6 +4,7 @@ package sbt
4
4
import scala .language .unsafeNulls
5
5
6
6
import java .io .File
7
+ import java .nio .file .Path
7
8
import java .util .{Arrays , EnumSet }
8
9
9
10
import dotty .tools .dotc .ast .tpd
@@ -55,8 +56,7 @@ class ExtractDependencies extends Phase {
55
56
override def description : String = ExtractDependencies .description
56
57
57
58
override def isRunnable (using Context ): Boolean = {
58
- def forceRun = ctx.settings.YdumpSbtInc .value || ctx.settings.YforceSbtPhases .value
59
- super .isRunnable && (ctx.sbtCallback != null || forceRun)
59
+ super .isRunnable && ctx.runZincPhases
60
60
}
61
61
62
62
// Check no needed. Does not transform trees
@@ -91,18 +91,16 @@ class ExtractDependencies extends Phase {
91
91
} finally pw.close()
92
92
}
93
93
94
- if ( ctx.sbtCallback != null ) {
94
+ ctx.withIncCallback : cb =>
95
95
collector.usedNames.foreach {
96
96
case (clazz, usedNames) =>
97
97
val className = classNameAsString(clazz)
98
98
usedNames.names.foreach {
99
99
case (usedName, scopes) =>
100
- ctx.sbtCallback .usedName(className, usedName.toString, scopes)
100
+ cb .usedName(className, usedName.toString, scopes)
101
101
}
102
102
}
103
-
104
103
collector.dependencies.foreach(recordDependency)
105
- }
106
104
}
107
105
108
106
/*
@@ -112,27 +110,20 @@ class ExtractDependencies extends Phase {
112
110
*/
113
111
def recordDependency (dep : ClassDependency )(using Context ): Unit = {
114
112
val fromClassName = classNameAsString(dep.from)
115
- val sourceFile = ctx.compilationUnit.source.file.file
113
+ val sourceFile = ctx.compilationUnit.source
116
114
117
- def binaryDependency (file : File , binaryClassName : String ) =
118
- ctx.sbtCallback .binaryDependency(file, binaryClassName, fromClassName, sourceFile, dep.context)
115
+ def binaryDependency (file : Path , binaryClassName : String ) =
116
+ ctx.withIncCallback(_ .binaryDependency(file, binaryClassName, fromClassName, sourceFile, dep.context) )
119
117
120
118
def processExternalDependency (depFile : AbstractFile , binaryClassName : String ) = {
121
119
depFile match {
122
120
case ze : ZipArchive # Entry => // The dependency comes from a JAR
123
121
ze.underlyingSource match
124
- case Some (zip) if zip.file != null =>
125
- binaryDependency(zip.file , binaryClassName)
122
+ case Some (zip) if zip.jpath != null =>
123
+ binaryDependency(zip.jpath , binaryClassName)
126
124
case _ =>
127
- case pf : PlainFile => // The dependency comes from a class file
128
- // FIXME: pf.file is null for classfiles coming from the modulepath
129
- // (handled by JrtClassPath) because they cannot be represented as
130
- // java.io.File, since the `binaryDependency` callback must take a
131
- // java.io.File, this means that we cannot record dependencies coming
132
- // from the modulepath. For now this isn't a big deal since we only
133
- // support having the standard Java library on the modulepath.
134
- if pf.file != null then
135
- binaryDependency(pf.file, binaryClassName)
125
+ case pf : PlainFile => // The dependency comes from a class file, Zinc handles JRT filesystem
126
+ binaryDependency(pf.jpath, binaryClassName)
136
127
case _ =>
137
128
internalError(s " Ignoring dependency $depFile of unknown class ${depFile.getClass}} " , dep.from.srcPos)
138
129
}
@@ -148,11 +139,11 @@ class ExtractDependencies extends Phase {
148
139
if (depClassFile != null ) {
149
140
// Dependency is external -- source is undefined
150
141
processExternalDependency(depClassFile, dep.to.binaryClassName)
151
- } else if (allowLocal || depFile.file != sourceFile) {
142
+ } else if (allowLocal || depFile != sourceFile.file ) {
152
143
// We cannot ignore dependencies coming from the same source file because
153
144
// the dependency info needs to propagate. See source-dependencies/trait-trait-211.
154
145
val toClassName = classNameAsString(dep.to)
155
- ctx.sbtCallback .classDependency(toClassName, fromClassName, dep.context)
146
+ ctx.withIncCallback(_ .classDependency(toClassName, fromClassName, dep.context) )
156
147
}
157
148
}
158
149
}
0 commit comments