Skip to content

Commit

Permalink
[kotlin] ensure that file from production isn't found in test sources
Browse files Browse the repository at this point in the history
otherwise 2 FirFiles might be created for single ktFile if containing module has both production and test roots
^ KTIJ-24530

GitOrigin-RevId: ec5608bfcc1eca71c6c4aadc5a5c8f29df2133ac
  • Loading branch information
akozlova authored and intellij-monorepo-bot committed Feb 3, 2023
1 parent 65274fb commit bb9f2d2
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.intellij.openapi.roots.ProjectRootModificationTracker
import com.intellij.openapi.util.Key
import com.intellij.psi.PsiFile
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.GlobalSearchScopes
import com.intellij.psi.util.CachedValue
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
Expand Down Expand Up @@ -73,7 +74,12 @@ internal class KtSourceModuleByModuleInfo(
override val directRegularDependencies: List<KtModule>
get() = moduleInfo.dependencies(provider)

override val contentScope: GlobalSearchScope get() = moduleInfo.contentScope
override val contentScope: GlobalSearchScope
get() = if (moduleInfo is ModuleTestSourceInfo) {
val testOnlyScope = GlobalSearchScopes.projectTestScope(project).intersectWith(ideaModule.moduleTestSourceScope)
KotlinResolveScopeEnlarger.enlargeScope(testOnlyScope, ideaModule, isTestScope = true)
} else
moduleInfo.contentScope

override val languageVersionSettings: LanguageVersionSettings get() = moduleInfo.module.languageVersionSettings

Expand Down

0 comments on commit bb9f2d2

Please sign in to comment.