diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kElementFactory.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kElementFactory.kt index f3bc6ea..16a5cbc 100644 --- a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kElementFactory.kt +++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kElementFactory.kt @@ -22,6 +22,11 @@ object M68kElementFactory { return PsiTreeUtil.findChildOfType(file, M68kSymbolDefinition::class.java)!! } + fun createSymbolReference(project: Project, symbol: String): M68kSymbolReference { + val file = createFile(project, " bra $symbol\n") + return PsiTreeUtil.findChildOfType(file, M68kSymbolReference::class.java)!! + } + fun createFile(project: Project, content: String): M68kFile { return PsiFileFactory.getInstance(project).createFileFromText("dummy.m68k", INSTANCE, content) as M68kFile } diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kSymbolReferenceElementManipulator.kt b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kSymbolReferenceElementManipulator.kt new file mode 100644 index 0000000..25fa71a --- /dev/null +++ b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kSymbolReferenceElementManipulator.kt @@ -0,0 +1,17 @@ +package de.platon42.intellij.plugins.m68k.refs + +import com.intellij.openapi.util.TextRange +import com.intellij.psi.AbstractElementManipulator +import com.intellij.util.IncorrectOperationException +import de.platon42.intellij.plugins.m68k.psi.M68kElementFactory +import de.platon42.intellij.plugins.m68k.psi.M68kSymbolReference + +class M68kSymbolReferenceElementManipulator : AbstractElementManipulator() { + + @Throws(IncorrectOperationException::class) + override fun handleContentChange(element: M68kSymbolReference, range: TextRange, newContent: String): M68kSymbolReference { + val newSymbolReference = M68kElementFactory.createSymbolReference(element.project, newContent) + element.firstChild.replace(newSymbolReference.firstChild) + return element + } +} \ 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 f74bc92..26c8df2 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -24,8 +24,11 @@ - + + +