Don't consider a directory to be a package if there's a .java or .class file with the same name in its parent directory

#KT-12664 Fixed
This commit is contained in:
Dmitry Jemerov
2016-11-17 15:44:57 +01:00
parent 7dbcbeb794
commit 5a533a521b
7 changed files with 39 additions and 6 deletions
@@ -220,7 +220,7 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>): JvmDependenciesIndex {
}
}
else {
currentFile = currentFile.findChild(subPackageName) ?: return null
currentFile = currentFile.findChildPackage(subPackageName, pathRoot.type) ?: return null
}
val correspondingCacheIndex = pathIndex + 1
@@ -233,6 +233,21 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>): JvmDependenciesIndex {
return currentFile
}
private fun VirtualFile.findChildPackage(subPackageName: String, rootType: JavaRoot.RootType): VirtualFile? {
val childDirectory = findChild(subPackageName) ?: return null
// Resolve conflicts between files and packages with the same qualified name in favor of files
val fileExtension = when (rootType) {
JavaRoot.RootType.BINARY -> ".class"
JavaRoot.RootType.SOURCE -> ".java"
}
if (findChild(subPackageName + fileExtension)?.isDirectory == false) {
return null
}
return childDirectory
}
private fun cachesPath(path: List<String>): List<Cache> {
val caches = ArrayList<Cache>(path.size + 1)
caches.add(rootCache)