mirror of
https://github.com/ilyakooo0/intellij-haskell.git
synced 2024-08-17 10:40:44 +03:00
Improve finding module file
This commit is contained in:
parent
cd122ba5ef
commit
0ad6468379
@ -110,17 +110,12 @@ object HaskellProjectUtil {
|
||||
directory.listFiles.find(_.getName == "package.yaml")
|
||||
}
|
||||
|
||||
def getProjectAndLibrariesModulesSearchScope(project: Project): GlobalSearchScope = {
|
||||
val projectModules = findProjectHaskellModules(project).map(m => GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(m, true))
|
||||
if (projectModules.isEmpty) {
|
||||
GlobalSearchScope.EMPTY_SCOPE
|
||||
} else {
|
||||
projectModules.reduce(_.uniteWith(_))
|
||||
}
|
||||
def getProjectSearchScope(project: Project): GlobalSearchScope = {
|
||||
GlobalSearchScope.allScope(project)
|
||||
}
|
||||
|
||||
def getSearchScope(project: Project, includeNonProjectItems: Boolean): GlobalSearchScope = {
|
||||
if (includeNonProjectItems) getProjectAndLibrariesModulesSearchScope(project) else GlobalSearchScope.projectScope(project)
|
||||
if (includeNonProjectItems) getProjectSearchScope(project) else GlobalSearchScope.projectScope(project)
|
||||
}
|
||||
|
||||
import ScalaUtil._
|
||||
|
@ -76,8 +76,8 @@ object HaskellModuleNameIndex {
|
||||
moduleNames.foreach(mn => {
|
||||
val key = Key(project, mn)
|
||||
find(key, 5.seconds, reschedule = true) match {
|
||||
case Right(vf) => Cache.put(key, Right(vf))
|
||||
case Left(_) => ()
|
||||
case Right(vf) if vf.nonEmpty => Cache.put(key, Right(vf))
|
||||
case _ => ()
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -128,7 +128,7 @@ object HaskellModuleNameIndex {
|
||||
val files = ApplicationUtil.scheduleInReadActionWithWriteActionPriority(
|
||||
project, {
|
||||
try {
|
||||
Some(FileBasedIndex.getInstance.getContainingFiles(HaskellModuleNameIndex, moduleName, HaskellProjectUtil.getProjectAndLibrariesModulesSearchScope(project)).asScala.toSeq)
|
||||
Some(FileBasedIndex.getInstance.getContainingFiles(HaskellModuleNameIndex, moduleName, HaskellProjectUtil.getProjectSearchScope(project)).asScala.toSeq)
|
||||
} catch {
|
||||
case _: IndexNotReadyException => None
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user