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