diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kSymbolDefinition.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kSymbolDefinition.java index 42efbe0..4948d2f 100644 --- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kSymbolDefinition.java +++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kSymbolDefinition.java @@ -2,10 +2,12 @@ package de.platon42.intellij.plugins.m68k.psi; import com.intellij.psi.PsiElement; +import com.intellij.psi.StubBasedPsiElement; +import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStub; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -public interface M68kSymbolDefinition extends M68kNamedElement { +public interface M68kSymbolDefinition extends M68kNamedElement, StubBasedPsiElement { @Nullable String getName(); diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kTypes.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kTypes.java index 896ade2..402cd6e 100644 --- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kTypes.java +++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kTypes.java @@ -66,7 +66,7 @@ public interface M68kTypes { IElementType SPECIAL_REGISTER = new M68kElementType("SPECIAL_REGISTER"); IElementType SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE = new M68kElementType("SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE"); IElementType STATEMENT = new M68kElementType("STATEMENT"); - IElementType SYMBOL_DEFINITION = new M68kElementType("SYMBOL_DEFINITION"); + IElementType SYMBOL_DEFINITION = M68kStubElementTypeFactory.stubFactory("SYMBOL_DEFINITION"); IElementType SYMBOL_REFERENCE = new M68kElementType("SYMBOL_REFERENCE"); IElementType UNARY_COMPL_EXPR = new M68kElementType("UNARY_COMPL_EXPR"); IElementType UNARY_MINUS_EXPR = new M68kElementType("UNARY_MINUS_EXPR"); diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kSymbolDefinitionImpl.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kSymbolDefinitionImpl.java index d45da81..39926a3 100644 --- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kSymbolDefinitionImpl.java +++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kSymbolDefinitionImpl.java @@ -4,10 +4,12 @@ package de.platon42.intellij.plugins.m68k.psi.impl; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; +import com.intellij.psi.stubs.IStubElementType; import de.platon42.intellij.plugins.m68k.psi.M68kPsiImplUtil; import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition; import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinitionMixin; import de.platon42.intellij.plugins.m68k.psi.M68kVisitor; +import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStub; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,6 +19,10 @@ public class M68kSymbolDefinitionImpl extends M68kSymbolDefinitionMixin implemen super(node); } + public M68kSymbolDefinitionImpl(@NotNull M68kSymbolDefinitionStub stub, @NotNull IStubElementType nodeType) { + super(stub, nodeType); + } + public void accept(@NotNull M68kVisitor visitor) { visitor.visitSymbolDefinition(this); } diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf b/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf index 28dc71f..7e53a4b 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf +++ b/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf @@ -130,6 +130,8 @@ private statement_recover ::= !(EOL) SymbolDefinition ::= SYMBOLDEF { implements = "de.platon42.intellij.plugins.m68k.psi.M68kNamedElement" mixin = "de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinitionMixin" + elementTypeFactory = "de.platon42.intellij.plugins.m68k.stubs.M68kStubElementTypeFactory.stubFactory" + stubClass = "de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStub" methods = [getName setName getNameIdentifier] } diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kSymbolDefinitionMixin.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kSymbolDefinitionMixin.kt index 5fdcb94..f7f25a0 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kSymbolDefinitionMixin.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kSymbolDefinitionMixin.kt @@ -1,19 +1,29 @@ package de.platon42.intellij.plugins.m68k.psi -import com.intellij.extapi.psi.ASTWrapperPsiElement +import com.intellij.extapi.psi.StubBasedPsiElementBase import com.intellij.ide.projectView.PresentationData import com.intellij.lang.ASTNode import com.intellij.navigation.ItemPresentation +import com.intellij.psi.stubs.IStubElementType import de.platon42.intellij.plugins.m68k.M68kIcons +import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStub import javax.swing.Icon -abstract class M68kSymbolDefinitionMixin(node: ASTNode) : ASTWrapperPsiElement(node), M68kSymbolDefinition { +abstract class M68kSymbolDefinitionMixin : StubBasedPsiElementBase, M68kSymbolDefinition { + + constructor(node: ASTNode) : super(node) + + constructor(stub: M68kSymbolDefinitionStub, nodeType: IStubElementType<*, *>) : super(stub, nodeType) override fun getPresentation(): ItemPresentation? { - return PresentationData(name, containingFile?.name, getIcon(0), null) + return PresentationData(name, containingFile.name, getIcon(0), null) } override fun getIcon(flags: Int): Icon? { return M68kIcons.SYMBOL_DEF } + + override fun toString(): String { + return javaClass.simpleName + "(SYMBOL_DEFINITION)" + } } \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kElementTypes.kt b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kElementTypes.kt index 16062ce..27a315c 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kElementTypes.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kElementTypes.kt @@ -8,9 +8,12 @@ import com.intellij.psi.stubs.* import com.intellij.psi.tree.ILightStubFileElementType import de.platon42.intellij.plugins.m68k.MC68000Language.Companion.INSTANCE import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel +import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition import de.platon42.intellij.plugins.m68k.psi.M68kTypes import de.platon42.intellij.plugins.m68k.psi.impl.M68kGlobalLabelImpl +import de.platon42.intellij.plugins.m68k.psi.impl.M68kSymbolDefinitionImpl import de.platon42.intellij.plugins.m68k.stubs.impl.M68kGlobalLabelStubImpl +import de.platon42.intellij.plugins.m68k.stubs.impl.M68kSymbolDefinitionStubImpl import java.io.IOException interface M68kElementTypes { @@ -40,5 +43,29 @@ interface M68kElementTypes { override fun indexStub(stub: M68kGlobalLabelStub, sink: IndexSink) = sink.occurrence(M68kGlobalLabelStubIndex.KEY, stub.name!!) } + + @JvmField + val SYMBOL_DEFINITION: IStubElementType = + object : M68kStubElementType("SYMBOL_DEFINITION") { + override fun createPsi(stub: M68kSymbolDefinitionStub): M68kSymbolDefinition = M68kSymbolDefinitionImpl(stub, this) + + override fun createStub(psi: M68kSymbolDefinition, parentStub: StubElement): M68kSymbolDefinitionStub = + M68kSymbolDefinitionStubImpl(parentStub, this, psi.name!!) + + override fun createStub(tree: LighterAST, node: LighterASTNode, parentStub: StubElement<*>): M68kSymbolDefinitionStub { + val idNode = LightTreeUtil.requiredChildOfType(tree, node, M68kTypes.SYMBOLDEF) + return M68kSymbolDefinitionStubImpl(parentStub, this, LightTreeUtil.toFilteredString(tree, idNode, null)) + } + + @Throws(IOException::class) + override fun serialize(stub: M68kSymbolDefinitionStub, dataStream: StubOutputStream) = dataStream.writeName(stub.name) + + @Throws(IOException::class) + override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>): M68kSymbolDefinitionStub = + M68kSymbolDefinitionStubImpl(parentStub, this, dataStream.readName()!!) + + override fun indexStub(stub: M68kSymbolDefinitionStub, sink: IndexSink) = sink.occurrence(M68kSymbolDefinitionStubIndex.KEY, stub.name!!) + } + } } \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kStubElementTypeFactory.kt b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kStubElementTypeFactory.kt index 608ea03..ba30d8d 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kStubElementTypeFactory.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kStubElementTypeFactory.kt @@ -9,6 +9,7 @@ object M68kStubElementTypeFactory { fun stubFactory(name: String): IStubElementType, out M68kPsiElement> { when (name) { "GLOBAL_LABEL" -> return M68kElementTypes.GLOBAL_LABEL + "SYMBOL_DEFINITION" -> return M68kElementTypes.SYMBOL_DEFINITION else -> throw RuntimeException("Unknown element type '$name'") } } diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kSymbolDefinitionStub.kt b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kSymbolDefinitionStub.kt new file mode 100644 index 0000000..f9110ff --- /dev/null +++ b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kSymbolDefinitionStub.kt @@ -0,0 +1,6 @@ +package de.platon42.intellij.plugins.m68k.stubs + +import com.intellij.psi.stubs.NamedStub +import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition + +interface M68kSymbolDefinitionStub : NamedStub \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kSymbolDefinitionStubIndex.kt b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kSymbolDefinitionStubIndex.kt new file mode 100644 index 0000000..052b87a --- /dev/null +++ b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kSymbolDefinitionStubIndex.kt @@ -0,0 +1,16 @@ +package de.platon42.intellij.plugins.m68k.stubs + +import com.intellij.psi.stubs.StringStubIndexExtension +import com.intellij.psi.stubs.StubIndexKey +import de.platon42.intellij.plugins.m68k.M68kFileElementType +import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition + +class M68kSymbolDefinitionStubIndex : StringStubIndexExtension() { + override fun getKey(): StubIndexKey = KEY + + override fun getVersion(): Int = M68kFileElementType.STUB_VERSION + + companion object { + val KEY = StubIndexKey.createIndexKey("mc68000.symboldef.index") + } +} \ No newline at end of file diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/impl/M68kSymbolDefinitionStubImpl.kt b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/impl/M68kSymbolDefinitionStubImpl.kt new file mode 100644 index 0000000..0febeab --- /dev/null +++ b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/impl/M68kSymbolDefinitionStubImpl.kt @@ -0,0 +1,13 @@ +package de.platon42.intellij.plugins.m68k.stubs.impl + +import com.intellij.psi.stubs.IStubElementType +import com.intellij.psi.stubs.NamedStubBase +import com.intellij.psi.stubs.StubElement +import com.intellij.util.io.StringRef +import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition +import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStub + +class M68kSymbolDefinitionStubImpl : NamedStubBase, M68kSymbolDefinitionStub { + constructor(parent: StubElement<*>, elementType: IStubElementType<*, *>, name: StringRef) : super(parent, elementType, name) + constructor(parent: StubElement<*>, elementType: IStubElementType<*, *>, name: String) : super(parent, elementType, name) +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 590646f..0de64fe 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -31,6 +31,7 @@ implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kSymbolReferenceElementManipulator"/> +