Preparations for supporting Cabal's internal library.

This commit is contained in:
Rik van der Kleij 2019-02-05 20:16:13 +01:00
parent 05d710b4cd
commit 2b8f370505
3 changed files with 5 additions and 3 deletions

View File

@ -150,7 +150,7 @@ sealed trait CabalStanza {
}
case class LibraryCabalStanza(sectionRootElement: PsiElement, packageName: String, modulePath: String) extends CabalStanza {
val nameElementType: Option[IElementType] = None
val nameElementType: Option[IElementType] = Some(CabalTypes.LIBRARY_NAME)
val targetName: String = s"$packageName:lib"

View File

@ -52,7 +52,8 @@ final class CabalPsiBuilder(builder: PsiBuilder)
)
def library(): Boolean = stanza(
"library", LIBRARY, LIBRARY_KEY, noStanzaArgs, () => libraryField()
"library", LIBRARY, LIBRARY_KEY,
() => stanzaNameArg(LIBRARY_NAME)(), () => libraryField()
)
def libraryField(): Boolean = (
@ -122,7 +123,7 @@ final class CabalPsiBuilder(builder: PsiBuilder)
def stanzaNameArg(el: CabalStanzaArgTokenType)(): Unit = getTokenType match {
case _: CabalWordLikeTokenType => remapAdvance(el)
case _ => error(s"Expected name argument")
case _ => () // non internal library has no name
}
def invalidStanza(): Boolean = {

View File

@ -323,6 +323,7 @@ public interface CabalTypes {
CabalElementType LIBRARY = new CabalElementType("LIBRARY");
CabalStanzaKeyTokenType LIBRARY_KEY = new CabalStanzaKeyTokenType("LIBRARY_KEY");
CabalStanzaArgTokenType LIBRARY_NAME = new CabalStanzaArgTokenType("LIBRARY_NAME");
CabalElementType EXPOSED_MODULES = new CabalElementType("EXPOSED_MODULES");
CabalFieldKeyTokenType EXPOSED_MODULES_KEY = new CabalFieldKeyTokenType("EXPOSED_MODULES_KEY");