Teach index working with source roots with package prefix

#KT-9167 Fixed
This commit is contained in:
Nikolay Krasko
2015-11-08 20:58:55 +03:00
committed by Nikolay Krasko
parent c0739ef53c
commit 23e35ab112
17 changed files with 179 additions and 3 deletions
@@ -59,7 +59,8 @@ public class JvmDependenciesIndex(_roots: List<JavaRoot>) {
val rootIndices = IntArrayList()
}
// root "Cache" object corresponds to DefaultPackage which exists in every root
// root "Cache" object corresponds to DefaultPackage which exists in every root. Roots with non-default fqname are also listed here but
// they will be ignored on requests with invalid fqname prefix.
private val rootCache: Cache by lazy {
with(Cache()) {
roots.indices.forEach {
@@ -208,10 +209,23 @@ public class JvmDependenciesIndex(_roots: List<JavaRoot>) {
return null
}
var currentFile = roots[rootIndex].file
val pathRoot = roots[rootIndex]
val prefixPathSegments = pathRoot.prefixFqName?.pathSegments()
var currentFile = pathRoot.file
for (pathIndex in packagesPath.indices) {
val subPackageName = packagesPath[pathIndex]
currentFile = currentFile.findChild(subPackageName) ?: return null
if (prefixPathSegments != null && pathIndex < prefixPathSegments.size) {
// Traverse prefix first instead of traversing real directories
if (prefixPathSegments[pathIndex].identifier != subPackageName) {
return null
}
}
else {
currentFile = currentFile.findChild(subPackageName) ?: return null
}
val correspondingCacheIndex = pathIndex + 1
if (correspondingCacheIndex > fillCachesAfter) {
// subPackageName exists in this root