|
| 1 | +package org.rust.lang.core.stubs.elements |
| 2 | + |
| 3 | + |
| 4 | +import com.intellij.psi.stubs.* |
| 5 | +import org.rust.lang.core.psi.RustUnionItemElement |
| 6 | +import org.rust.lang.core.psi.impl.RustUnionItemElementImpl |
| 7 | +import org.rust.lang.core.stubs.RustNamedElementStub |
| 8 | +import org.rust.lang.core.stubs.RustNamedStubElementType |
| 9 | +import org.rust.lang.core.stubs.index.RustGotoClassIndex |
| 10 | + |
| 11 | +object RustUnionItemStubElementType : RustNamedStubElementType<RustUnionItemElementStub, RustUnionItemElement>("UNION_ITEM") { |
| 12 | + override fun createStub(psi: RustUnionItemElement, parentStub: StubElement<*>?): RustUnionItemElementStub = |
| 13 | + RustUnionItemElementStub(parentStub, this, psi.name, psi.isPublic) |
| 14 | + |
| 15 | + override fun createPsi(stub: RustUnionItemElementStub): RustUnionItemElement = |
| 16 | + RustUnionItemElementImpl(stub, this) |
| 17 | + |
| 18 | + override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>?): RustUnionItemElementStub = |
| 19 | + RustUnionItemElementStub(parentStub, this, dataStream.readNameAsString(), dataStream.readBoolean()) |
| 20 | + |
| 21 | + override fun serialize(stub: RustUnionItemElementStub, dataStream: StubOutputStream) = with(dataStream) { |
| 22 | + writeName(stub.name) |
| 23 | + writeBoolean(stub.isPublic) |
| 24 | + } |
| 25 | + |
| 26 | + override fun indexStub(stub: RustUnionItemElementStub, sink: IndexSink) { |
| 27 | + super.indexStub(stub, sink) |
| 28 | + stub.name?.let { sink.occurrence(RustGotoClassIndex.KEY, it) } |
| 29 | + } |
| 30 | + |
| 31 | +} |
| 32 | + |
| 33 | + |
| 34 | +class RustUnionItemElementStub( |
| 35 | + parent: StubElement<*>?, |
| 36 | + elementType: IStubElementType<*, *>, |
| 37 | + name: String?, |
| 38 | + isPublic: Boolean |
| 39 | +) : RustNamedElementStub<RustUnionItemElement>(parent, elementType, name ?: "", isPublic) |
0 commit comments