Skip to content

Commit fb7d82c

Browse files
committed
Address review comments
1 parent 4d3a104 commit fb7d82c

File tree

3 files changed

+17
-18
lines changed

3 files changed

+17
-18
lines changed

compiler/src/dotty/tools/dotc/interactive/Interactive.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ object Interactive {
512512
in(targetDriver) { implicit ctx =>
513513
val base: Symbol = ctx.definitions.RootClass
514514
owners.tail.foldLeft(base) { (prefix, symbolName) =>
515-
prefix.info.member(symbolName).symbol
515+
if (prefix.exists) prefix.info.member(symbolName).symbol
516+
else NoSymbol
516517
}
517518
}
518519
}

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
7777
}
7878

7979
// Like in `ZipArchiveFileLookup` we assume that zips are immutable
80-
private val zipClassPathClasses: Seq[String] = {
81-
val names = new mutable.ListBuffer[String]
80+
private val zipClassPathClasses: Seq[TypeName] = {
81+
val names = new mutable.ListBuffer[TypeName]
8282
zipClassPaths.foreach { zipCp =>
8383
val zipFile = new ZipFile(zipCp.zipFile)
8484
classesFromZip(zipFile, names)
@@ -105,7 +105,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
105105
def sourceTreesContaining(id: String)(implicit ctx: Context): List[SourceTree] = {
106106
val fromBuffers = openedTrees.values.flatten.toList
107107
val fromCompilationOutput = {
108-
val classNames = new mutable.ListBuffer[String]
108+
val classNames = new mutable.ListBuffer[TypeName]
109109
val output = ctx.settings.outputDir.value
110110
if (output.isDirectory) {
111111
classesFromDir(output.jpath, classNames)
@@ -114,8 +114,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
114114
classesFromZip(zipFile, classNames)
115115
}
116116
classNames.flatMap { cls =>
117-
val className = cls.toTypeName
118-
treesFromClassName(className, id = "")
117+
treesFromClassName(cls, id)
119118
}
120119
}
121120
(fromBuffers ++ fromCompilationOutput).distinct
@@ -138,8 +137,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
138137
def allTreesContaining(id: String)(implicit ctx: Context): List[SourceTree] = {
139138
val fromSource = openedTrees.values.flatten.toList
140139
val fromClassPath = (dirClassPathClasses ++ zipClassPathClasses).flatMap { cls =>
141-
val className = cls.toTypeName
142-
treesFromClassName(className, id)
140+
treesFromClassName(cls, id)
143141
}
144142
(fromSource ++ fromClassPath).distinct
145143
}
@@ -205,8 +203,8 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
205203
// FIXME: classfiles in directories may change at any point, so we retraverse
206204
// the directories each time, if we knew when classfiles changed (sbt
207205
// server-mode might help here), we could do cache invalidation instead.
208-
private def dirClassPathClasses: Seq[String] = {
209-
val names = new mutable.ListBuffer[String]
206+
private def dirClassPathClasses: Seq[TypeName] = {
207+
val names = new mutable.ListBuffer[TypeName]
210208
dirClassPaths.foreach { dirCp =>
211209
val root = dirCp.dir.toPath
212210
classesFromDir(root, names)
@@ -215,19 +213,19 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
215213
}
216214

217215
/** Adds the names of the classes that are defined in `zipFile` to `buffer`. */
218-
private def classesFromZip(zipFile: ZipFile, buffer: mutable.ListBuffer[String]): Unit = {
216+
private def classesFromZip(zipFile: ZipFile, buffer: mutable.ListBuffer[TypeName]): Unit = {
219217
try {
220218
for {
221219
entry <- zipFile.stream.toArray((size: Int) => new Array[ZipEntry](size))
222220
name = entry.getName
223221
tastySuffix <- tastySuffixes.find(name.endsWith)
224-
} buffer += name.replace("/", ".").stripSuffix(tastySuffix)
222+
} buffer += name.replace("/", ".").stripSuffix(tastySuffix).toTypeName
225223
}
226224
finally zipFile.close()
227225
}
228226

229227
/** Adds the names of the classes that are defined in `dir` to `buffer`. */
230-
private def classesFromDir(dir: Path, buffer: mutable.ListBuffer[String]): Unit = {
228+
private def classesFromDir(dir: Path, buffer: mutable.ListBuffer[TypeName]): Unit = {
231229
try
232230
Files.walkFileTree(dir, new SimpleFileVisitor[Path] {
233231
override def visitFile(path: Path, attrs: BasicFileAttributes) = {
@@ -237,7 +235,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
237235
tastySuffix <- tastySuffixes
238236
if name.endsWith(tastySuffix)
239237
} {
240-
buffer += dir.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix)
238+
buffer += dir.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix).toTypeName
241239
}
242240
}
243241
FileVisitResult.CONTINUE

sbt-dotty/src/dotty/tools/sbtplugin/DottyIDEPlugin.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,16 @@ object DottyIDEPlugin extends AutoPlugin {
374374
/**
375375
* Detect the eligible configuration dependencies from a given configuration.
376376
*
377-
* A configuration is elibile if the project defines it and `bloopGenerate`
377+
* A configuration is eligible if the project defines it and `compile`
378378
* exists for it. Otherwise, the configuration dependency is ignored.
379379
*
380380
* This is required to prevent transitive configurations like `Runtime` from
381-
* generating useless bloop configuration files and possibly incorrect project
381+
* generating useless IDE configuration files and possibly incorrect project
382382
* dependencies. For example, if we didn't do this then the dependencies of
383-
* `IntegrationTest` would be `projectName-runtime` and `projectName-compile`,
383+
* `IntegrationTest` would be `projectName/runtime` and `projectName/compile`,
384384
* whereas the following logic will return only the configuration `Compile`
385385
* so that the use site of this function can create the project dep
386-
* `projectName-compile`.
386+
* `projectName/compile`.
387387
*/
388388
private def eligibleDepsFromConfig(config: Configuration): Def.Initialize[Task[List[Configuration]]] = {
389389
Def.task {

0 commit comments

Comments
 (0)