Macro definitions are now word and indexed, macro calls reference to definition.

Macro definition refactoring and find usages support.
Structural View also shows macro definitions.
Missing REPT and ENDR assembler directives added.
Changed or added some icons at various places.
Reference search for global labels and symbols now uses stub index.
This commit is contained in:
2021-07-27 16:34:49 +02:00
parent 6e683eb6a0
commit 25450a9bf8
54 changed files with 649 additions and 114 deletions
@@ -23,6 +23,11 @@ internal class MacroCallTest : AbstractParsingTest() {
testGoodSyntax(testCase, " PUSHM d0/d3/d5-d7/a0-a2/a4-a6 ; save a couple of registers\n")
}
@Test
internal fun call_with_label(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
testGoodSyntax(testCase, "label FOOBAR narf ; wut?\n")
}
@Test
internal fun putmsg_call_with_specially_bracketed_parameters(@MyTestCase testCase: ParsingTestExtension.IParsingTestCase) {
// FIXME this doesn't work as intended...
@@ -0,0 +1,32 @@
package de.platon42.intellij.plugins.m68k.refs
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
import de.platon42.intellij.jupiter.LightCodeInsightExtension
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 org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@TestDataPath("src/test/resources/references")
@TestDataSubPath("completion")
@ExtendWith(LightCodeInsightExtension::class)
internal class M68kMacroCallCompletionContributorTest : AbstractM68kTest() {
@Test
internal fun completion_shows_mnemonics_and_macros(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"completeme.asm", """
noppy MACRO
ENDM
no<caret>
"""
)
myFixture.completeBasic()
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("nop", "not", "noppy")
}
}
@@ -8,10 +8,7 @@ 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 de.platon42.intellij.plugins.m68k.psi.*
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.extension.ExtendWith
@@ -71,4 +68,22 @@ internal class M68kReferenceContributorTest : AbstractM68kTest() {
myFixture.checkResultByFile("symbol_assignment_after_rename.asm")
}
@Test
@TestDataSubPath("macros")
internal fun reference_to_macro_can_be_renamed(@MyFixture myFixture: CodeInsightTestFixture) {
val file = myFixture.configureByFile("macros.asm")
val elementAtCaret = myFixture.elementAtCaret
assertThat(elementAtCaret).isInstanceOf(M68kMacroDefinition::class.java)
val macroDef = elementAtCaret as M68kMacroDefinition
assertThat(macroDef.macroNameDefinition.text).isEqualTo("PUTMSG")
myFixture.renameElementAtCaret("PRINTF")
val reference = file.findReferenceAt(myFixture.editor.caretModel.offset)!!
assertThat(reference).isInstanceOf(M68kMacroReference::class.java)
assertThat(reference.variants).isEmpty()
myFixture.checkResultByFile("macros_after_rename.asm")
}
}
@@ -24,6 +24,8 @@ internal class M68kStructureViewTest : AbstractM68kTest() {
PIC_WIDTH
PIC_HEIGHT
DEBUG_LEVEL
BLTHOGON
BLTHOGOFF
entry
-init
.looph
@@ -2,11 +2,13 @@ Assembly File: a.asm
PsiWhiteSpace(' ')
M68kStatementImpl(STATEMENT)
M68kMacroCallImpl(MACRO_CALL)
PsiElement(M68kTokenType.MACRO_INVOKATION)('PUSHM')
PsiElement(M68kTokenType.MACRO_INVOCATION)('PUSHM')
PsiWhiteSpace(' ')
PsiElement(M68kTokenType.STRINGLIT)('d0')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('d0')
PsiElement(M68kTokenType.SEPARATOR)(',')
PsiElement(M68kTokenType.STRINGLIT)('d0')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('d0')
PsiWhiteSpace(' ')
PsiComment(M68kTokenType.COMMENT)('hey comment')
PsiElement(M68kTokenType.EOL)('\n')
@@ -2,12 +2,14 @@ Assembly File: a.asm
PsiWhiteSpace(' ')
M68kStatementImpl(STATEMENT)
M68kMacroCallImpl(MACRO_CALL)
PsiElement(M68kTokenType.MACRO_INVOKATION)('PUSHM')
PsiElement(M68kTokenType.MACRO_INVOCATION)('PUSHM')
PsiWhiteSpace(' ')
PsiElement(M68kTokenType.STRINGLIT)('d0')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('d0')
PsiElement(M68kTokenType.SEPARATOR)(',')
PsiWhiteSpace(' ')
PsiElement(M68kTokenType.STRINGLIT)('d0')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('d0')
PsiWhiteSpace(' ')
PsiComment(M68kTokenType.COMMENT)('; hey comment')
PsiElement(M68kTokenType.EOL)('\n')
@@ -2,5 +2,5 @@ Assembly File: a.asm
PsiWhiteSpace(' ')
PsiErrorElement:'.' unexpected
PsiElement(BAD_CHARACTER)('.')
PsiElement(M68kTokenType.MACRO_INVOKATION)('local_label')
PsiElement(M68kTokenType.MACRO_INVOCATION)('local_label')
PsiElement(M68kTokenType.EOL)('\n')
@@ -2,6 +2,7 @@ Assembly File: a.asm
PsiWhiteSpace(' ')
M68kStatementImpl(STATEMENT)
M68kMacroCallImpl(MACRO_CALL)
PsiElement(M68kTokenType.MACRO_INVOKATION)('local_label')
PsiElement(M68kTokenType.STRINGLIT)('$')
PsiElement(M68kTokenType.MACRO_INVOCATION)('local_label')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('$')
PsiElement(M68kTokenType.EOL)('\n')
@@ -2,9 +2,11 @@ Assembly File: a.asm
PsiWhiteSpace(' ')
M68kStatementImpl(STATEMENT)
M68kMacroCallImpl(MACRO_CALL)
PsiElement(M68kTokenType.MACRO_INVOKATION)('COPIMOVE')
PsiElement(M68kTokenType.MACRO_INVOCATION)('COPIMOVE')
PsiWhiteSpace(' ')
PsiElement(M68kTokenType.STRINGLIT)('(3<<0)|(3<<3)|(1<<6)')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('(3<<0)|(3<<3)|(1<<6)')
PsiElement(M68kTokenType.SEPARATOR)(',')
PsiElement(M68kTokenType.STRINGLIT)('bplcon2')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('bplcon2')
PsiElement(M68kTokenType.EOL)('\n')
@@ -0,0 +1,13 @@
Assembly File: a.asm
M68kStatementImpl(STATEMENT)
M68kGlobalLabelImpl(GLOBAL_LABEL)
PsiElement(M68kTokenType.GLOBAL_LABEL_DEF)('label')
PsiWhiteSpace(' ')
M68kMacroCallImpl(MACRO_CALL)
PsiElement(M68kTokenType.MACRO_INVOCATION)('FOOBAR')
PsiWhiteSpace(' ')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('narf')
PsiWhiteSpace(' ')
PsiComment(M68kTokenType.COMMENT)('; wut?')
PsiElement(M68kTokenType.EOL)('\n')
@@ -2,9 +2,10 @@ Assembly File: a.asm
PsiWhiteSpace(' ')
M68kStatementImpl(STATEMENT)
M68kMacroCallImpl(MACRO_CALL)
PsiElement(M68kTokenType.MACRO_INVOKATION)('PUSHM')
PsiElement(M68kTokenType.MACRO_INVOCATION)('PUSHM')
PsiWhiteSpace(' ')
PsiElement(M68kTokenType.STRINGLIT)('d0/d3/d5-d7/a0-a2/a4-a6')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('d0/d3/d5-d7/a0-a2/a4-a6')
PsiWhiteSpace(' ')
PsiComment(M68kTokenType.COMMENT)('; save a couple of registers')
PsiElement(M68kTokenType.EOL)('\n')
@@ -2,17 +2,23 @@ Assembly File: a.asm
PsiWhiteSpace('\t')
M68kStatementImpl(STATEMENT)
M68kMacroCallImpl(MACRO_CALL)
PsiElement(M68kTokenType.MACRO_INVOKATION)('PUTMSG')
PsiElement(M68kTokenType.MACRO_INVOCATION)('PUTMSG')
PsiWhiteSpace(' ')
PsiElement(M68kTokenType.STRINGLIT)('10')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('10')
PsiElement(M68kTokenType.SEPARATOR)(',')
PsiElement(M68kTokenType.STRINGLIT)('<"%s has left the building at %d:%d",10,'Yup!'>')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('<"%s has left the building at %d:%d",10,'Yup!'>')
PsiElement(M68kTokenType.SEPARATOR)(',')
PsiElement(M68kTokenType.STRINGLIT)('a0')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('a0')
PsiElement(M68kTokenType.SEPARATOR)(',')
PsiElement(M68kTokenType.STRINGLIT)('$42(a1')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('$42(a1')
PsiElement(M68kTokenType.SEPARATOR)(',')
PsiElement(M68kTokenType.STRINGLIT)('d0.w)')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('d0.w)')
PsiElement(M68kTokenType.SEPARATOR)(',')
PsiElement(M68kTokenType.STRINGLIT)('#42')
M68kLiteralExprImpl(LITERAL_EXPR)
PsiElement(M68kTokenType.STRINGLIT)('#42')
PsiElement(M68kTokenType.EOL)('\n')
@@ -2,5 +2,5 @@ Assembly File: a.asm
PsiWhiteSpace(' ')
M68kStatementImpl(STATEMENT)
M68kMacroCallImpl(MACRO_CALL)
PsiElement(M68kTokenType.MACRO_INVOKATION)('BLT_HOG_ON')
PsiElement(M68kTokenType.MACRO_INVOCATION)('BLT_HOG_ON')
PsiElement(M68kTokenType.EOL)('\n')
@@ -0,0 +1,13 @@
PUTMSG MACRO
printf
ENDM
UAEExitWarp MACRO
ENDM
main PUTM<caret>SG 10,<"Enter MAIN!">,d0
rts
exit PUTMSG 10,<"Exit!">,d0
illegal
rts
@@ -0,0 +1,13 @@
PRINTF MACRO
printf
ENDM
UAEExitWarp MACRO
ENDM
main PRINTF 10,<"Enter MAIN!">,d0
rts
exit PRINTF 10,<"Exit!">,d0
illegal
rts
@@ -2,6 +2,14 @@ PIC_WIDTH = 320
PIC_HEIGHT equ 256
DEBUG_LEVEL set 10
BLTHOGON MACRO
foo
ENDM
BLTHOGOFF MACRO
bar
ENDM
entry:
bsr init
bsr main