|
|
|
@ -11,17 +11,18 @@ import com.intellij.openapi.roots.*
|
|
|
|
|
import com.intellij.psi.* |
|
|
|
|
import com.intellij.psi.search.* |
|
|
|
|
import com.intellij.psi.util.* |
|
|
|
|
import org.jetbrains.kotlin.idea.stubindex.KotlinFullClassNameIndex |
|
|
|
|
import org.jetbrains.kotlin.idea.util.* |
|
|
|
|
|
|
|
|
|
fun PsiElement.inComposeModule() = module?.isComposeModule() ?: false |
|
|
|
|
fun Module.isComposeModule(): Boolean { |
|
|
|
|
return CachedValuesManager.getManager(project).getCachedValue(this) { |
|
|
|
|
val javaPsiFacade = JavaPsiFacade.getInstance(this.project) |
|
|
|
|
val value = COMPOSABLE_FQ_NAMES.any { |
|
|
|
|
javaPsiFacade.findClass(it, GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(this)) != null |
|
|
|
|
val scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(this) |
|
|
|
|
val hasComposable = COMPOSABLE_FQ_NAMES.any { |
|
|
|
|
KotlinFullClassNameIndex.getInstance().get(it, project, scope).any() |
|
|
|
|
} |
|
|
|
|
val rootModificationTracker = ProjectRootModificationTracker.getInstance(project) |
|
|
|
|
CachedValueProvider.Result.create(value, rootModificationTracker) |
|
|
|
|
CachedValueProvider.Result.create(hasComposable, rootModificationTracker) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|