Using externalIdPrefix for a stubElementTypeHolder generated by Grammar-Kit
Answered
We want to specify externalIdPrefix for our stubElementTypeHolder as recommended by the docs:
To speed up IDE loading, it's recommended that this extension is used for interfaces containing only IStubElementType (or ObjectStubSerializer) constants, and all other language's element types are kept in a separate interface that can be loaded later
However, in the Grammar-Kit preamble you can only specify one elementTypeHolderClass, so inevitably both the stub and the non-stub types will end up in the same class.
I've checked some other plugins but haven't found yet how this is fixable without manually editing generated files. Is this possible at all?
Please sign in to leave a comment.
Hi,
I don't see it as possible at the moment. Please follow https://github.com/JetBrains/Grammar-Kit/issues/314.
Clear, thanks!
Hi,
Please check the answer in the linked GitHub issue.
Just want to add that the stubElementTypeHolder has to be a Java interface, a Kotlin interface will not work and IStubElementType will fail with
All stub element types should be created before index initialization is complete.
See `org.angular2.lang.html.stub.Angular2HtmlStubElementTypes` as sample for using Kotlin:
interface Angular2HtmlStubElementTypes {
@Suppress("MayBeConstant")
companion object {
@JvmField
val STUB_VERSION = 1
@JvmField
val EXTERNAL_ID_PREFIX = "NG-HTML:"
@JvmField
val REFERENCE_VARIABLE: JSStubElementType<JSVariableStub<JSVariable>, JSVariable> =
Angular2HtmlVariableElementType(Angular2HtmlAttrVariable.Kind.REFERENCE)
@JvmField
val LET_VARIABLE: JSStubElementType<JSVariableStub<JSVariable>, JSVariable> =
Angular2HtmlVariableElementType(Angular2HtmlAttrVariable.Kind.LET)
@JvmField
val NG_CONTENT_SELECTOR = Angular2HtmlNgContentSelectorElementType()
}
}