mirror of
https://github.com/ilyakooo0/intellij-haskell.git
synced 2024-09-11 14:56:19 +03:00
Also find conditional packages in Cabal's build-depends.
This commit is contained in:
parent
cb00af053a
commit
8d4febc8d4
@ -25,7 +25,7 @@ import com.intellij.psi.{PsiElement, PsiFileFactory}
|
||||
import intellij.haskell.HaskellNotificationGroup
|
||||
import intellij.haskell.cabal.lang.psi
|
||||
import intellij.haskell.cabal.lang.psi._
|
||||
import intellij.haskell.cabal.lang.psi.impl.{BuildDependsImpl, ExtensionsImpl, MainIsImpl, SourceDirsImpl}
|
||||
import intellij.haskell.cabal.lang.psi.impl.{ExtensionsImpl, MainIsImpl, SourceDirsImpl}
|
||||
import intellij.haskell.psi.HaskellPsiUtil
|
||||
import intellij.haskell.util.HaskellFileUtil
|
||||
|
||||
@ -118,8 +118,8 @@ sealed trait CabalStanza {
|
||||
HaskellPsiUtil.getChildOfType(sectionRootElement, classOf[SourceDirsImpl]).map(_.getValue).getOrElse(Array()).map(p => HaskellFileUtil.makeFilePathAbsolute(p, modulePath))
|
||||
}
|
||||
|
||||
lazy val buildDepends: Array[String] = {
|
||||
HaskellPsiUtil.getChildOfType(sectionRootElement, classOf[BuildDependsImpl]).map(_.getPackageNames).getOrElse(Array())
|
||||
lazy val buildDepends: Seq[String] = {
|
||||
HaskellPsiUtil.getChildrenOfType(sectionRootElement, classOf[BuildDepends]).flatMap(_.getPackageNames).toSeq
|
||||
}
|
||||
|
||||
private def findLanguageExtensions: Set[String] = {
|
||||
|
@ -189,7 +189,7 @@ object HaskellModuleBuilder {
|
||||
|
||||
private def getDependencies(project: Project, module: Module, packageName: String, libraryDependencies: Seq[HaskellLibraryDependency]): Seq[HaskellDependency] = {
|
||||
val cabalInfo = HaskellComponentsManager.findCabalInfos(project).find(_.packageName == packageName)
|
||||
val libPackages = cabalInfo.flatMap(_.library.map(_.buildDepends)).getOrElse(Array())
|
||||
val libPackages = cabalInfo.flatMap(_.library.map(_.buildDepends)).getOrElse(Seq())
|
||||
val exePackages = cabalInfo.map(_.executables.flatMap(_.buildDepends)).getOrElse(Seq())
|
||||
val testPackages = cabalInfo.map(_.testSuites.flatMap(_.buildDepends)).getOrElse(Seq())
|
||||
val benchPackages = cabalInfo.map(_.benchmarks.flatMap(_.buildDepends)).getOrElse(Seq())
|
||||
|
@ -210,6 +210,10 @@ object HaskellPsiUtil {
|
||||
Option(PsiTreeUtil.getChildOfType(psiElement, cls))
|
||||
}
|
||||
|
||||
def getChildrenOfType[T <: PsiElement](psiElement: PsiElement, cls: Class[T]): Iterable[T] = {
|
||||
PsiTreeUtil.findChildrenOfAnyType(psiElement, cls).asScala
|
||||
}
|
||||
|
||||
def getChildNodes(psiElement: PsiElement, elementTypes: IElementType*): Array[ASTNode] = {
|
||||
psiElement.getNode.getChildren(TokenSet.create(elementTypes: _*))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user