Added M68kSymbolReferenceElementManipulator to allow refactoring of local labels.
This commit is contained in:
parent
56697ac1df
commit
c13e488ab8
@ -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
|
||||
}
|
||||
|
@ -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<M68kSymbolReference>() {
|
||||
|
||||
@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
|
||||
}
|
||||
}
|
@ -24,8 +24,11 @@
|
||||
<completion.contributor language="M68k" implementationClass="de.platon42.intellij.plugins.m68k.asm.M68kMnemonicCompletionContributor"/>
|
||||
<lang.braceMatcher language="M68k" implementationClass="de.platon42.intellij.plugins.m68k.syntax.M68kPairedBraceMatcher"/>
|
||||
<lang.quoteHandler language="M68k" implementationClass="de.platon42.intellij.plugins.m68k.M68kStringQuoteHandler"/>
|
||||
<psi.referenceContributor implementation="de.platon42.intellij.plugins.m68k.refs.M68kReferenceContributor"/>
|
||||
<lang.findUsagesProvider language="M68k" implementationClass="de.platon42.intellij.plugins.m68k.scanner.M68kFindUsagesProvider"/>
|
||||
<lang.elementManipulator forClass="de.platon42.intellij.plugins.m68k.psi.M68kSymbolReference"
|
||||
implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kSymbolReferenceElementManipulator"/>
|
||||
|
||||
<psi.referenceContributor implementation="de.platon42.intellij.plugins.m68k.refs.M68kReferenceContributor"/>
|
||||
<renameInputValidator implementation="de.platon42.intellij.plugins.m68k.psi.M68kRenameInputValidator"/>
|
||||
</extensions>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user