Added support for referencing / refactoring of global variables and symbols. Added getPresentation() for structural view, but does not seem to be working yet. Also Find Usages still reports "Unclassified" :-/
This commit is contained in:
@@ -8,7 +8,9 @@ import de.platon42.intellij.jupiter.MyFixture
|
||||
import de.platon42.intellij.jupiter.TestDataPath
|
||||
import de.platon42.intellij.jupiter.TestDataSubPath
|
||||
import de.platon42.intellij.plugins.m68k.AbstractM68kTest
|
||||
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel
|
||||
import de.platon42.intellij.plugins.m68k.psi.M68kLocalLabel
|
||||
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition
|
||||
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolReference
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -36,4 +38,38 @@ internal class M68kReferenceContributorTest : AbstractM68kTest() {
|
||||
.extracting<String> { (it as LookupElementBuilder).lookupString }
|
||||
.containsExactlyInAnyOrderElementsOf(listOf("loop$", "loop$", ".skip"))
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun reference_to_global_label_can_be_renamed(@MyFixture myFixture: CodeInsightTestFixture) {
|
||||
val file = myFixture.configureByFile("global_labels.asm")
|
||||
assertThat(myFixture.elementAtCaret).isInstanceOf(M68kGlobalLabel::class.java)
|
||||
.extracting(PsiElement::getText).isEqualTo("main")
|
||||
|
||||
val reference = file.findReferenceAt(myFixture.editor.caretModel.offset - 1)!!
|
||||
assertThat(reference).isInstanceOf(M68kGlobalLabelSymbolReference::class.java)
|
||||
assertThat(reference.variants).hasOnlyElementsOfType(LookupElementBuilder::class.java)
|
||||
.extracting<String> { (it as LookupElementBuilder).lookupString }
|
||||
.containsExactlyInAnyOrder("main", "init", "exit")
|
||||
|
||||
myFixture.renameElementAtCaret("intro_main")
|
||||
|
||||
myFixture.checkResultByFile("global_labels_after_rename.asm")
|
||||
}
|
||||
|
||||
@Test
|
||||
internal fun reference_to_symbol_can_be_renamed(@MyFixture myFixture: CodeInsightTestFixture) {
|
||||
val file = myFixture.configureByFile("symbol_assignment.asm")
|
||||
assertThat(myFixture.elementAtCaret).isInstanceOf(M68kSymbolDefinition::class.java)
|
||||
.extracting(PsiElement::getText).isEqualTo("PIC_HEIGTH")
|
||||
|
||||
myFixture.renameElementAtCaret("PIC_HEIGHT")
|
||||
|
||||
val reference = file.findReferenceAt(myFixture.editor.caretModel.offset)!!
|
||||
assertThat(reference).isInstanceOf(M68kGlobalLabelSymbolReference::class.java)
|
||||
assertThat(reference.variants).hasOnlyElementsOfType(LookupElementBuilder::class.java)
|
||||
.extracting<String> { (it as LookupElementBuilder).lookupString }
|
||||
.containsExactlyInAnyOrder("main", "init", "exit", "PIC_WIDTH", "PIC_HEIGHT")
|
||||
|
||||
myFixture.checkResultByFile("symbol_assignment_after_rename.asm")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
bsr init
|
||||
bsr main<caret>
|
||||
bsr exit
|
||||
rts
|
||||
|
||||
init moveq.l #-1,d0
|
||||
rts
|
||||
|
||||
main moveq.l #0,d0
|
||||
rts
|
||||
|
||||
exit illegal
|
||||
rts
|
||||
@@ -0,0 +1,13 @@
|
||||
bsr init
|
||||
bsr intro_main
|
||||
bsr exit
|
||||
rts
|
||||
|
||||
init moveq.l #-1,d0
|
||||
rts
|
||||
|
||||
intro_main moveq.l #0,d0
|
||||
rts
|
||||
|
||||
exit illegal
|
||||
rts
|
||||
@@ -0,0 +1,17 @@
|
||||
PIC_WIDTH = 320
|
||||
PIC_HEIGTH equ 256
|
||||
|
||||
bsr init
|
||||
bsr main
|
||||
bsr exit
|
||||
rts
|
||||
|
||||
init move.w #PIC_WIDTH,d0
|
||||
move.w #PIC_<caret>HEIGTH,d1
|
||||
rts
|
||||
|
||||
main moveq.l #0,d0
|
||||
rts
|
||||
|
||||
exit illegal
|
||||
rts
|
||||
@@ -0,0 +1,17 @@
|
||||
PIC_WIDTH = 320
|
||||
PIC_HEIGHT equ 256
|
||||
|
||||
bsr init
|
||||
bsr main
|
||||
bsr exit
|
||||
rts
|
||||
|
||||
init move.w #PIC_WIDTH,d0
|
||||
move.w #PIC_HEIGHT,d1
|
||||
rts
|
||||
|
||||
main moveq.l #0,d0
|
||||
rts
|
||||
|
||||
exit illegal
|
||||
rts
|
||||
Reference in New Issue
Block a user