Skip to content

Commit

Permalink
Fix unresolved kotlin types (#3924)
Browse files Browse the repository at this point in the history
closes #3438
  • Loading branch information
aperfilyev committed Mar 13, 2023
1 parent aaa6643 commit da7a4a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
Expand Up @@ -27,7 +27,6 @@ import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.lang.annotation.AnnotationHolder
import com.intellij.lang.annotation.Annotator
import com.intellij.lang.annotation.HighlightSeverity
import com.intellij.openapi.module.ModuleUtil
import com.intellij.psi.PsiElement
import com.intellij.psi.search.GlobalSearchScope

Expand All @@ -47,8 +46,7 @@ internal class SqlDelightClassNameElementAnnotator : Annotator {
} else {
val project = element.project
val sqlDelightFile = element.containingFile as SqlDelightFile
val module = ModuleUtil.findModuleForFile(sqlDelightFile) ?: return
val scope = GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module, false)
val scope = GlobalSearchScope.allScope(project)
val outerClassElement = element.firstChild
val outerClassName = outerClassElement.text
val classes = PsiClassSearchHelper.getClassesByShortName(outerClassName, project, scope)
Expand Down
Expand Up @@ -5,7 +5,6 @@ import app.cash.sqldelight.core.lang.psi.ImportStmtMixin
import app.cash.sqldelight.core.lang.psi.JavaTypeMixin
import app.cash.sqldelight.core.lang.util.findChildrenOfType
import app.cash.sqldelight.core.psi.SqlDelightImportStmt
import com.intellij.openapi.module.ModuleUtilCore
import com.intellij.patterns.PlatformPatterns.psiElement
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiElement
Expand All @@ -14,6 +13,7 @@ import com.intellij.psi.PsiReferenceBase
import com.intellij.psi.PsiReferenceContributor
import com.intellij.psi.PsiReferenceProvider
import com.intellij.psi.PsiReferenceRegistrar
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.util.ProcessingContext
import org.jetbrains.kotlin.idea.stubindex.KotlinFullClassNameIndex
import org.jetbrains.kotlin.idea.stubindex.KotlinTopLevelTypeAliasFqNameIndex
Expand Down Expand Up @@ -43,9 +43,6 @@ internal class SqlDelightReferenceContributor : PsiReferenceContributor() {
}

override fun resolve(): PsiElement? {
val module = ModuleUtilCore.findModuleForPsiElement(element)
?: return null

val elementText = element.text
val qName = if (element.parent is SqlDelightImportStmt) {
elementText
Expand All @@ -63,7 +60,7 @@ internal class SqlDelightReferenceContributor : PsiReferenceContributor() {
}
}
val project = element.project
val scope = module.getModuleWithDependenciesAndLibrariesScope(false)
val scope = GlobalSearchScope.allScope(project)
val classNameIndex = KotlinFullClassNameIndex.getInstance()
val ktClass = { classNameIndex[qName, project, scope].firstOrNull() }
val typeAliasFqNameIndex = getKotlinTopLevelTypeAliasFqNameIndex()
Expand Down

0 comments on commit da7a4a9

Please sign in to comment.