diff --git a/README.md b/README.md
index f3741c0..7c2859f 100644
--- a/README.md
+++ b/README.md
@@ -72,6 +72,12 @@ make it work with JUnit 5. Feel free to use the code (in package ```de.platon42.
### V0.3 (unreleased)
- Enhancement: Macros contents are no longer parsed, added syntax highlighting options for macros.
+- Enhancement: Macro definitions are now word and stub indexed, macro calls reference to definition.
+- Enhancement: Macro definition refactoring and find usages support.
+- Enhancement: Structural View also shows macro definitions.
+- Bugfix: Missing REPT and ENDR assembler directives added.
+- Cosmetics: Changed or added some icons at various places.
+- Performance: Reference search for global labels and symbols now uses stub index.
### V0.2 (27-Jul-21)
diff --git a/build.gradle b/build.gradle
index 565b743..a56db23 100644
--- a/build.gradle
+++ b/build.gradle
@@ -49,6 +49,12 @@ patchPluginXml {
V0.3 (unreleased)
- Enhancement: Macros contents are no longer parsed, added syntax highlighting options for macros.
+
- Enhancement: Macro definitions are now word and stub indexed, macro calls reference to definition.
+
- Enhancement: Macro definition refactoring and find usages support.
+
- Enhancement: Structural View also shows macro definitions.
+
- Bugfix: Missing REPT and ENDR assembler directives added.
+
- Cosmetics: Changed or added some icons at various places.
+
- Performance: Reference search for global labels and symbols now uses stub index.
V0.2 (27-Jul-21)
diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.java b/src/main/gen/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.java
index c560435..91c9844 100644
--- a/src/main/gen/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.java
+++ b/src/main/gen/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.java
@@ -898,17 +898,13 @@ public class _M68kLexer implements FlexLexer {
yybegin(EXPR);
return OTHER_DIRECTIVE;
}
- yybegin(MACROCALL);
- eatOneWhitespace = true;
- return MACRO_INVOKATION;
+ return handleMacroMode(this);
}
// fall through
case 116:
break;
case 8: {
- yybegin(MACROCALL);
- eatOneWhitespace = true;
- return MACRO_INVOKATION;
+ return handleMacroMode(this);
}
// fall through
case 117:
diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/parser/M68kParser.java b/src/main/gen/de/platon42/intellij/plugins/m68k/parser/M68kParser.java
index c825f3d..06bcecd 100644
--- a/src/main/gen/de/platon42/intellij/plugins/m68k/parser/M68kParser.java
+++ b/src/main/gen/de/platon42/intellij/plugins/m68k/parser/M68kParser.java
@@ -551,7 +551,7 @@ public class M68kParser implements PsiParser, LightPsiParser {
// AsmInstruction | MacroCall
static boolean Instruction(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Instruction")) return false;
- if (!nextTokenIs(b, "", MACRO_INVOKATION, MNEMONIC)) return false;
+ if (!nextTokenIs(b, "", MACRO_INVOCATION, MNEMONIC)) return false;
boolean r;
r = AsmInstruction(b, l + 1);
if (!r) r = MacroCall(b, l + 1);
@@ -638,13 +638,13 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
- // MACRO_INVOKATION PlainOperands?
+ // MACRO_INVOCATION PlainOperands?
public static boolean MacroCall(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroCall")) return false;
- if (!nextTokenIs(b, MACRO_INVOKATION)) return false;
+ if (!nextTokenIs(b, MACRO_INVOCATION)) return false;
boolean r;
Marker m = enter_section_(b);
- r = consumeToken(b, MACRO_INVOKATION);
+ r = consumeToken(b, MACRO_INVOCATION);
r = r && MacroCall_1(b, l + 1);
exit_section_(b, m, MACRO_CALL, r);
return r;
@@ -754,19 +754,27 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
- // STRINGLIT (SEPARATOR STRINGLIT)*
+ // (expr|AddressingMode) (SEPARATOR (expr|AddressingMode))*
static boolean PlainOperands(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "PlainOperands")) return false;
- if (!nextTokenIs(b, STRINGLIT)) return false;
boolean r;
Marker m = enter_section_(b);
- r = consumeToken(b, STRINGLIT);
+ r = PlainOperands_0(b, l + 1);
r = r && PlainOperands_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
- // (SEPARATOR STRINGLIT)*
+ // expr|AddressingMode
+ private static boolean PlainOperands_0(PsiBuilder b, int l) {
+ if (!recursion_guard_(b, l, "PlainOperands_0")) return false;
+ boolean r;
+ r = expr(b, l + 1, -1);
+ if (!r) r = AddressingMode(b, l + 1);
+ return r;
+ }
+
+ // (SEPARATOR (expr|AddressingMode))*
private static boolean PlainOperands_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "PlainOperands_1")) return false;
while (true) {
@@ -777,16 +785,26 @@ public class M68kParser implements PsiParser, LightPsiParser {
return true;
}
- // SEPARATOR STRINGLIT
+ // SEPARATOR (expr|AddressingMode)
private static boolean PlainOperands_1_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "PlainOperands_1_0")) return false;
boolean r;
Marker m = enter_section_(b);
- r = consumeTokens(b, 0, SEPARATOR, STRINGLIT);
+ r = consumeToken(b, SEPARATOR);
+ r = r && PlainOperands_1_0_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
+ // expr|AddressingMode
+ private static boolean PlainOperands_1_0_1(PsiBuilder b, int l) {
+ if (!recursion_guard_(b, l, "PlainOperands_1_0_1")) return false;
+ boolean r;
+ r = expr(b, l + 1, -1);
+ if (!r) r = AddressingMode(b, l + 1);
+ return r;
+ }
+
/* ********************************************************** */
// Label? (DATA_DIRECTIVE | OTHER_DIRECTIVE)
// PreprocessorOperands?
diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kMacroCall.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kMacroCall.java
index 3ac9374..dc13e01 100644
--- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kMacroCall.java
+++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kMacroCall.java
@@ -1,6 +1,19 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
public interface M68kMacroCall extends M68kPsiElement {
+ @NotNull
+ List getAddressingModeList();
+
+ @NotNull
+ List getExprList();
+
+ @NotNull
+ String getMacroName();
+
}
diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kMacroDefinition.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kMacroDefinition.java
index c9647cb..e7dcfe2 100644
--- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kMacroDefinition.java
+++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kMacroDefinition.java
@@ -1,11 +1,15 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.StubBasedPsiElement;
+import de.platon42.intellij.plugins.m68k.stubs.M68kMacroDefinitionStub;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
-public interface M68kMacroDefinition extends M68kPsiElement {
+public interface M68kMacroDefinition extends M68kNamedElement, StubBasedPsiElement {
@NotNull
M68kMacroNameDefinition getMacroNameDefinition();
@@ -13,4 +17,13 @@ public interface M68kMacroDefinition extends M68kPsiElement {
@NotNull
List getMacroPlainLineList();
+ @Nullable
+ String getName();
+
+ @NotNull
+ PsiElement setName(@NotNull String name);
+
+ @NotNull
+ PsiElement getNameIdentifier();
+
}
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 d217d9b..e57a378 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
@@ -51,7 +51,7 @@ public interface M68kTypes {
IElementType LITERAL_EXPR = new M68kElementType("LITERAL_EXPR");
IElementType LOCAL_LABEL = new M68kElementType("LOCAL_LABEL");
IElementType MACRO_CALL = new M68kElementType("MACRO_CALL");
- IElementType MACRO_DEFINITION = new M68kElementType("MACRO_DEFINITION");
+ IElementType MACRO_DEFINITION = M68kStubElementTypeFactory.stubFactory("MACRO_DEFINITION");
IElementType MACRO_NAME_DEFINITION = new M68kElementType("MACRO_NAME_DEFINITION");
IElementType MACRO_PLAIN_LINE = new M68kElementType("MACRO_PLAIN_LINE");
IElementType OPERAND_SIZE = new M68kElementType("OPERAND_SIZE");
@@ -90,7 +90,7 @@ public interface M68kTypes {
IElementType HEXADECIMAL = new M68kTokenType("HEXADECIMAL");
IElementType LOCAL_LABEL_DEF = new M68kTokenType("LOCAL_LABEL_DEF");
IElementType MACRO_END_TAG = new M68kTokenType("MACRO_END_TAG");
- IElementType MACRO_INVOKATION = new M68kTokenType("MACRO_INVOKATION");
+ IElementType MACRO_INVOCATION = new M68kTokenType("MACRO_INVOCATION");
IElementType MACRO_LINE = new M68kTokenType("MACRO_LINE");
IElementType MACRO_NAME = new M68kTokenType("MACRO_NAME");
IElementType MACRO_TAG = new M68kTokenType("MACRO_TAG");
diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kVisitor.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kVisitor.java
index ae33e75..96c24de 100644
--- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kVisitor.java
+++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/M68kVisitor.java
@@ -95,7 +95,7 @@ public class M68kVisitor extends PsiElementVisitor {
}
public void visitMacroDefinition(@NotNull M68kMacroDefinition o) {
- visitPsiElement(o);
+ visitNamedElement(o);
}
public void visitMacroNameDefinition(@NotNull M68kMacroNameDefinition o) {
diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kMacroCallImpl.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kMacroCallImpl.java
index 37c3780..69d6481 100644
--- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kMacroCallImpl.java
+++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kMacroCallImpl.java
@@ -1,14 +1,15 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
-import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
-import de.platon42.intellij.plugins.m68k.psi.M68kMacroCall;
-import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
+import com.intellij.psi.util.PsiTreeUtil;
+import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
-public class M68kMacroCallImpl extends ASTWrapperPsiElement implements M68kMacroCall {
+import java.util.List;
+
+public class M68kMacroCallImpl extends M68kMacroCallMixin implements M68kMacroCall {
public M68kMacroCallImpl(@NotNull ASTNode node) {
super(node);
@@ -24,4 +25,22 @@ public class M68kMacroCallImpl extends ASTWrapperPsiElement implements M68kMacro
else super.accept(visitor);
}
+ @Override
+ @NotNull
+ public List getAddressingModeList() {
+ return PsiTreeUtil.getChildrenOfTypeAsList(this, M68kAddressingMode.class);
+ }
+
+ @Override
+ @NotNull
+ public List getExprList() {
+ return PsiTreeUtil.getChildrenOfTypeAsList(this, M68kExpr.class);
+ }
+
+ @Override
+ @NotNull
+ public String getMacroName() {
+ return M68kPsiImplUtil.getMacroName(this);
+ }
+
}
diff --git a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kMacroDefinitionImpl.java b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kMacroDefinitionImpl.java
index ba989fc..3d0235e 100644
--- a/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kMacroDefinitionImpl.java
+++ b/src/main/gen/de/platon42/intellij/plugins/m68k/psi/impl/M68kMacroDefinitionImpl.java
@@ -1,24 +1,28 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
-import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
+import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
+import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.util.PsiTreeUtil;
-import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition;
-import de.platon42.intellij.plugins.m68k.psi.M68kMacroNameDefinition;
-import de.platon42.intellij.plugins.m68k.psi.M68kMacroPlainLine;
-import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
+import de.platon42.intellij.plugins.m68k.psi.*;
+import de.platon42.intellij.plugins.m68k.stubs.M68kMacroDefinitionStub;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.List;
-public class M68kMacroDefinitionImpl extends ASTWrapperPsiElement implements M68kMacroDefinition {
+public class M68kMacroDefinitionImpl extends M68kMacroDefinitionMixin implements M68kMacroDefinition {
public M68kMacroDefinitionImpl(@NotNull ASTNode node) {
super(node);
}
+ public M68kMacroDefinitionImpl(@NotNull M68kMacroDefinitionStub stub, @NotNull IStubElementType, ?> nodeType) {
+ super(stub, nodeType);
+ }
+
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitMacroDefinition(this);
}
@@ -41,4 +45,22 @@ public class M68kMacroDefinitionImpl extends ASTWrapperPsiElement implements M68
return PsiTreeUtil.getChildrenOfTypeAsList(this, M68kMacroPlainLine.class);
}
+ @Override
+ @Nullable
+ public String getName() {
+ return M68kPsiImplUtil.getName(this);
+ }
+
+ @Override
+ @NotNull
+ public PsiElement setName(@NotNull String name) {
+ return M68kPsiImplUtil.setName(this, name);
+ }
+
+ @Override
+ @NotNull
+ public PsiElement getNameIdentifier() {
+ return M68kPsiImplUtil.getNameIdentifier(this);
+ }
+
}
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileElementType.kt b/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileElementType.kt
index cb586b7..9213532 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileElementType.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/M68kFileElementType.kt
@@ -10,7 +10,7 @@ class M68kFileElementType private constructor() : ILightStubFileElementType = setOf(
- "section", "pushsection", "popsection",
- "bss", "bss_c", "bss_f",
- "data", "data_c", "data_f",
- "text", "cseg", "code", "code_c", "code_f",
- "offset",
+ "section", "pushsection", "popsection",
+ "bss", "bss_c", "bss_f",
+ "data", "data_c", "data_f",
+ "text", "cseg", "code", "code_c", "code_f",
+ "offset",
- "abs",
- "db", "dw", "dl",
- "dr.b", "dr.w", "dr.l",
- "dc", "dc.b", "dc.w", "dc.l", "dcb", "dcb.b", "dcb.w", "dcb.l",
- "blk.b", "blk.w", "blk.l",
- "ds", "ds.b", "ds.w", "ds.l",
+ "abs",
+ "db", "dw", "dl",
+ "dr.b", "dr.w", "dr.l",
+ "dc", "dc.b", "dc.w", "dc.l", "dcb", "dcb.b", "dcb.w", "dcb.l",
+ "blk.b", "blk.w", "blk.l",
+ "ds", "ds.b", "ds.w", "ds.l",
- "align", "even", "odd", "cnop", "long", "dphrase", "phrase", "qphrase",
+ "align", "even", "odd", "cnop", "long", "dphrase", "phrase", "qphrase",
- "cargs", "comm", "comment",
- "rsset", "clrfo", "clrso", "setfo", "setso"
+ "cargs", "comm", "comment",
+ "rsset", "clrfo", "clrso", "setfo", "setso"
)
val otherDirective: Set = setOf(
- "if",
- "ifeq", "ifne", "ifgt", "ifge", "iflt", "ifle", "ifb", "ifnb", "ifc", "ifnc",
- "ifd", "ifnd", "ifmacrod", "ifmacrond",
- //"iif" // not supported
- "else", "endif", "endc",
+ "if",
+ "ifeq", "ifne", "ifgt", "ifge", "iflt", "ifle", "ifb", "ifnb", "ifc", "ifnc",
+ "ifd", "ifnd", "ifmacrod", "ifmacrond",
+ //"iif" // not supported
+ "else", "endif", "endc",
- "macro", "exitm", "mexit", "endm",
+ "rept", "endr",
- "extern", "nref", "xdef", "xref", "globl", "public", "weak",
+ "macro", "exitm", "mexit", "endm",
- "reg", "equr", "equrl",
+ "extern", "nref", "xdef", "xref", "globl", "public", "weak",
- "incdir", "include", "incbin", "output",
+ "reg", "equr", "equrl",
- "list", "nlist", "nolist", "llen", "nopage", "page", "spc",
- "org",
+ "incdir", "include", "incbin", "output",
- "assert", "fail", "print", "printt", "printv", "echo",
+ "list", "nlist", "nolist", "llen", "nopage", "page", "spc",
+ "org",
- "inline", "einline",
- "rem", "erem"
+ "assert", "fail", "print", "printt", "printv", "echo",
+
+ "inline", "einline",
+ "rem", "erem"
)
}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/asm/M68kMnemonicCompletionContributor.kt b/src/main/java/de/platon42/intellij/plugins/m68k/asm/M68kMnemonicCompletionContributor.kt
index 27f7493..e5a7f30 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/asm/M68kMnemonicCompletionContributor.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/asm/M68kMnemonicCompletionContributor.kt
@@ -2,15 +2,22 @@ package de.platon42.intellij.plugins.m68k.asm
import com.intellij.codeInsight.completion.*
import com.intellij.codeInsight.lookup.LookupElementBuilder
+import com.intellij.icons.AllIcons
import com.intellij.patterns.PlatformPatterns
import com.intellij.util.ProcessingContext
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
class M68kMnemonicCompletionContributor : CompletionContributor() {
+
+ companion object {
+ val MNEMONICS = M68kIsa.mnemonics
+ .map { PrioritizedLookupElement.withPriority(LookupElementBuilder.create(it).withIcon(AllIcons.Nodes.Protected), 10.0) }
+ }
+
init {
- extend(CompletionType.BASIC, PlatformPatterns.psiElement(M68kTypes.MACRO_INVOKATION), object : CompletionProvider() {
+ extend(CompletionType.BASIC, PlatformPatterns.psiElement(M68kTypes.MACRO_INVOCATION), object : CompletionProvider() {
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, resultSet: CompletionResultSet) {
- resultSet.addAllElements(M68kIsa.mnemonics.map(LookupElementBuilder::create))
+ resultSet.addAllElements(MNEMONICS)
}
})
}
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/lexer/LexerUtil.kt b/src/main/java/de/platon42/intellij/plugins/m68k/lexer/LexerUtil.kt
index 237f649..31a68bc 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/lexer/LexerUtil.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/lexer/LexerUtil.kt
@@ -4,6 +4,7 @@ import com.intellij.psi.TokenType
import com.intellij.psi.tree.IElementType
import de.platon42.intellij.plugins.m68k.asm.AssemblerDirectives
import de.platon42.intellij.plugins.m68k.asm.M68kIsa.mnemonics
+import de.platon42.intellij.plugins.m68k.psi.M68kTypes
object LexerUtil {
@@ -48,6 +49,17 @@ object LexerUtil {
return TokenType.WHITE_SPACE
}
+ @JvmStatic
+ fun handleMacroMode(lexer: _M68kLexer): IElementType {
+ if (lexer.lexerPrefs.macroParametersUnparsed) {
+ lexer.yybegin(_M68kLexer.MACROCALL)
+ } else {
+ lexer.yybegin(_M68kLexer.ASMOPS)
+ }
+ lexer.eatOneWhitespace = true
+ return M68kTypes.MACRO_INVOCATION
+ }
+
@JvmStatic
fun handleMacroLineEol(lexer: _M68kLexer): IElementType {
if (++lexer.macroLines > lexer.lexerPrefs.maxLinesPerMacro) {
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.flex b/src/main/java/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.flex
index 5fc8a5a..30166eb 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.flex
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/lexer/_M68kLexer.flex
@@ -89,10 +89,10 @@ PLAIN_MACRO_LINE=[^;\r\n]+
if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; }
if(isDataDirective(yytext())) { yybegin(EXPR); return DATA_DIRECTIVE; }
if(isOtherDirective(yytext())) { yybegin(EXPR); return OTHER_DIRECTIVE; }
- yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION;
+ return handleMacroMode(this);
}
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { yybegin(INSTRPART); return SYMBOL; } }
- {MACRONAME} { yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION; }
+ {MACRONAME} { return handleMacroMode(this); }
{HASH_COMMENT} { yybegin(YYINITIAL); return COMMENT; }
}
@@ -107,10 +107,10 @@ PLAIN_MACRO_LINE=[^;\r\n]+
if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; }
if(isDataDirective(yytext())) { yybegin(EXPR); return DATA_DIRECTIVE; }
if(isOtherDirective(yytext())) { yybegin(EXPR); return OTHER_DIRECTIVE; }
- yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION;
+ return handleMacroMode(this);
}
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { return SYMBOL; } }
- {MACRONAME} { yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION; }
+ {MACRONAME} { return handleMacroMode(this); }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
}
@@ -130,10 +130,10 @@ PLAIN_MACRO_LINE=[^;\r\n]+
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
{EOL} { yybegin(YYINITIAL); return EOL; }
- {COMMENT} { yybegin(WAITEOL); return COMMENT; }
-
"," { return SEPARATOR; }
+ {COMMENT} { yybegin(WAITEOL); return COMMENT; }
+
{PLAINPARAM} { return STRINGLIT; }
}
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 073e1ee..c394839 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/m68k.bnf
@@ -173,9 +173,22 @@ PreprocessorDirective ::= Label? (DATA_DIRECTIVE | OTHER_DIRECTIVE)
MacroPlainLine ::= MACRO_LINE
MacroNameDefinition ::= MACRO_NAME
-MacroDefinition ::= ((MacroNameDefinition MACRO_TAG)|(MACRO_TAG MacroNameDefinition)) MacroPlainLine* MACRO_END_TAG {pin=1}
+MacroDefinition ::= ((MacroNameDefinition MACRO_TAG)|(MACRO_TAG MacroNameDefinition)) MacroPlainLine* MACRO_END_TAG {
+pin=1
+ name = "macro definition"
+ implements = "de.platon42.intellij.plugins.m68k.psi.M68kNamedElement"
+ mixin = "de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinitionMixin"
+ elementTypeFactory = "de.platon42.intellij.plugins.m68k.stubs.M68kStubElementTypeFactory.stubFactory"
+ stubClass = "de.platon42.intellij.plugins.m68k.stubs.M68kMacroDefinitionStub"
+ methods = [getName setName getNameIdentifier]
+}
+
+
+MacroCall ::= MACRO_INVOCATION PlainOperands? {
+ mixin = "de.platon42.intellij.plugins.m68k.psi.M68kMacroCallMixin"
+ methods = [getMacroName]
+}
-MacroCall ::= MACRO_INVOKATION PlainOperands?
AsmInstruction ::= AsmOp AsmOperands?
private Instruction ::= AsmInstruction | MacroCall
//external Instruction ::= parseMacroCallOrAsmInstruction
@@ -185,7 +198,7 @@ private AsmOperands ::= AddressingMode (SEPARATOR AddressingMode)?
private PreprocessorOperands ::= PreprocessorOperand (SEPARATOR PreprocessorOperand)*
private PreprocessorOperand ::= expr
-private PlainOperands ::= STRINGLIT (SEPARATOR STRINGLIT)*
+private PlainOperands ::= (expr|AddressingMode) (SEPARATOR (expr|AddressingMode))*
// TODO This should probably be a ILazyParseableElementType, no idea how to implement that yet
SymbolReference ::= SYMBOL {
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 16a5cbc..0d08f76 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
@@ -27,6 +27,16 @@ object M68kElementFactory {
return PsiTreeUtil.findChildOfType(file, M68kSymbolReference::class.java)!!
}
+ fun createMacroDefinition(project: Project, name: String): M68kMacroDefinition {
+ val file = createFile(project, "$name macro\nendm\n")
+ return PsiTreeUtil.findChildOfType(file, M68kMacroDefinition::class.java)!!
+ }
+
+ fun createMacroCall(project: Project, name: String): M68kMacroCall {
+ val file = createFile(project, " $name\n")
+ return PsiTreeUtil.findChildOfType(file, M68kMacroCall::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/psi/M68kLookupUtil.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kLookupUtil.kt
index 51d89f0..a3d8c3e 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kLookupUtil.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kLookupUtil.kt
@@ -5,6 +5,7 @@ import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import com.intellij.psi.util.PsiTreeUtil
import de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStubIndex
+import de.platon42.intellij.plugins.m68k.stubs.M68kMacroDefinitionStubIndex
import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStubIndex
object M68kLookupUtil {
@@ -93,4 +94,47 @@ object M68kLookupUtil {
}
fun findAllSymbolDefinitionNames(project: Project): Collection = StubIndex.getInstance().getAllKeys(M68kSymbolDefinitionStubIndex.KEY, project)
+
+
+ fun findAllMacroDefinitions(project: Project): List {
+ val results: MutableList = ArrayList()
+ StubIndex.getInstance().processAllKeys(M68kMacroDefinitionStubIndex.KEY, project)
+ {
+ results.addAll(
+ StubIndex.getElements(
+ M68kMacroDefinitionStubIndex.KEY,
+ it,
+ project,
+ GlobalSearchScope.allScope(project),
+ M68kMacroDefinition::class.java
+ )
+ )
+ true
+ }
+ return results
+ }
+
+ fun findAllMacroDefinitions(file: M68kFile): List {
+ val results: MutableList = ArrayList()
+ StubIndex.getInstance().processAllKeys(
+ M68kMacroDefinitionStubIndex.KEY,
+ {
+ results.addAll(
+ StubIndex.getElements(
+ M68kMacroDefinitionStubIndex.KEY,
+ it,
+ file.project,
+ GlobalSearchScope.fileScope(file),
+ M68kMacroDefinition::class.java
+ )
+ )
+ true
+ }, GlobalSearchScope.fileScope(file), null
+ )
+ return results
+ }
+
+ fun findAllMacroDefinitionNames(project: Project): Collection = StubIndex.getInstance().getAllKeys(M68kMacroDefinitionStubIndex.KEY, project)
+
+
}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kMacroCallMixin.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kMacroCallMixin.kt
new file mode 100644
index 0000000..660165d
--- /dev/null
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kMacroCallMixin.kt
@@ -0,0 +1,13 @@
+package de.platon42.intellij.plugins.m68k.psi
+
+import com.intellij.extapi.psi.ASTWrapperPsiElement
+import com.intellij.lang.ASTNode
+import com.intellij.psi.PsiReference
+import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry
+
+abstract class M68kMacroCallMixin(node: ASTNode) : ASTWrapperPsiElement(node), M68kMacroCall {
+
+ override fun getReferences(): Array {
+ return ReferenceProvidersRegistry.getReferencesFromProviders(this)
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kMacroDefinitionMixin.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kMacroDefinitionMixin.kt
new file mode 100644
index 0000000..b2f0c53
--- /dev/null
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kMacroDefinitionMixin.kt
@@ -0,0 +1,29 @@
+package de.platon42.intellij.plugins.m68k.psi
+
+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.M68kMacroDefinitionStub
+import javax.swing.Icon
+
+abstract class M68kMacroDefinitionMixin : StubBasedPsiElementBase, M68kMacroDefinition {
+
+ constructor(node: ASTNode) : super(node)
+
+ constructor(stub: M68kMacroDefinitionStub, nodeType: IStubElementType<*, *>) : super(stub, nodeType)
+
+ override fun getPresentation(): ItemPresentation? {
+ return PresentationData(name, containingFile.name, getIcon(0), null)
+ }
+
+ override fun getIcon(flags: Int): Icon? {
+ return M68kIcons.MACRO_DEF
+ }
+
+ override fun toString(): String {
+ return javaClass.simpleName + "(MACRO_DEFINITION)"
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kPsiImplUtil.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kPsiImplUtil.kt
index 49bef8a..b754ad4 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kPsiImplUtil.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kPsiImplUtil.kt
@@ -4,6 +4,7 @@ import com.intellij.psi.PsiElement
import com.intellij.util.IncorrectOperationException
import de.platon42.intellij.plugins.m68k.psi.M68kElementFactory.createGlobalLabel
import de.platon42.intellij.plugins.m68k.psi.M68kElementFactory.createLocalLabel
+import de.platon42.intellij.plugins.m68k.psi.M68kElementFactory.createMacroDefinition
import de.platon42.intellij.plugins.m68k.psi.M68kElementFactory.createSymbolDefinition
object M68kPsiImplUtil {
@@ -71,4 +72,26 @@ object M68kPsiImplUtil {
val text = element.firstChild.text
return text.startsWith('.') || text.endsWith('$')
}
+
+
+ // Macro Definition
+ @JvmStatic
+ fun getName(element: M68kMacroDefinition): String? = element.macroNameDefinition.firstChild.text
+
+ @JvmStatic
+ fun setName(element: M68kMacroDefinition, name: String): PsiElement {
+ val nameNode = element.macroNameDefinition
+ val newMacroDefinition = createMacroDefinition(element.project, name)
+ nameNode.replace(newMacroDefinition.firstChild)
+ return element
+ }
+
+ @JvmStatic
+ fun getNameIdentifier(element: M68kMacroDefinition): PsiElement = element.firstChild
+
+
+ // Macro Call
+ @JvmStatic
+ fun getMacroName(element: M68kMacroCall): String = element.firstChild.text
+
}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kRenameInputValidator.kt b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kRenameInputValidator.kt
index ca7f6b8..e299fae 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kRenameInputValidator.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/psi/M68kRenameInputValidator.kt
@@ -13,12 +13,13 @@ class M68kRenameInputValidator : RenameInputValidator {
override fun getPattern(): ElementPattern = StandardPatterns.or(
PlatformPatterns.psiElement(M68kGlobalLabel::class.java),
PlatformPatterns.psiElement(M68kLocalLabel::class.java),
- PlatformPatterns.psiElement(M68kSymbolDefinition::class.java)
+ PlatformPatterns.psiElement(M68kSymbolDefinition::class.java),
+ PlatformPatterns.psiElement(M68kMacroDefinition::class.java)
)
override fun isInputValid(newName: String, element: PsiElement, context: ProcessingContext): Boolean {
return when (element) {
- is M68kGlobalLabel, is M68kSymbolDefinition -> SYMBOL_PATTERN.matcher(newName).matches()
+ is M68kGlobalLabel, is M68kSymbolDefinition, is M68kMacroDefinition -> SYMBOL_PATTERN.matcher(newName).matches()
is M68kLocalLabel -> LOCAL_LABEL_PATTERN.matcher(newName).matches()
else -> false
}
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kGlobalLabelSymbolReference.kt b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kGlobalLabelSymbolReference.kt
index 1750b0f..40dbf95 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kGlobalLabelSymbolReference.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kGlobalLabelSymbolReference.kt
@@ -7,12 +7,14 @@ import com.intellij.psi.PsiPolyVariantReferenceBase
import com.intellij.psi.ResolveResult
import com.intellij.psi.impl.source.resolve.ResolveCache
import com.intellij.psi.search.GlobalSearchScope
-import com.intellij.psi.search.PsiSearchHelper
-import com.intellij.psi.search.UsageSearchContext
+import com.intellij.psi.stubs.StubIndex
import com.intellij.util.SmartList
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel
+import de.platon42.intellij.plugins.m68k.psi.M68kNamedElement
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolReference
+import de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStubIndex
+import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStubIndex
class M68kGlobalLabelSymbolReference(element: M68kSymbolReference) :
PsiPolyVariantReferenceBase(element, TextRange(0, element.textLength)) {
@@ -24,18 +26,23 @@ class M68kGlobalLabelSymbolReference(element: M68kSymbolReference) :
class Resolver : ResolveCache.PolyVariantResolver {
override fun resolve(ref: M68kGlobalLabelSymbolReference, incompleteCode: Boolean): Array {
val refName = ref.element.symbolName
-
val project = ref.element.project
- val targets: MutableList = SmartList()
- PsiSearchHelper.getInstance(project).processElementsWithWord(
- { elem, _ ->
- when (elem) {
- is M68kGlobalLabel, is M68kSymbolDefinition -> targets.add(elem)
- }
+
+ val targets: MutableList = SmartList()
+ StubIndex.getInstance()
+ .processElements(M68kGlobalLabelStubIndex.KEY, refName, project, GlobalSearchScope.allScope(project), M68kGlobalLabel::class.java)
+ {
+ targets.add(it)
true
- }, GlobalSearchScope.allScope(project),
- refName, UsageSearchContext.IN_CODE, true
- )
+ }
+
+ StubIndex.getInstance()
+ .processElements(M68kSymbolDefinitionStubIndex.KEY, refName, project, GlobalSearchScope.allScope(project), M68kSymbolDefinition::class.java)
+ {
+ targets.add(it)
+ true
+ }
+
return targets
.map(::PsiElementResolveResult)
.toTypedArray()
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallCompletionContributor.kt b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallCompletionContributor.kt
new file mode 100644
index 0000000..c87369f
--- /dev/null
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallCompletionContributor.kt
@@ -0,0 +1,19 @@
+package de.platon42.intellij.plugins.m68k.refs
+
+import com.intellij.codeInsight.completion.*
+import com.intellij.codeInsight.lookup.LookupElementBuilder
+import com.intellij.patterns.PlatformPatterns
+import com.intellij.util.ProcessingContext
+import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil
+import de.platon42.intellij.plugins.m68k.psi.M68kTypes
+
+class M68kMacroCallCompletionContributor : CompletionContributor() {
+
+ init {
+ extend(CompletionType.BASIC, PlatformPatterns.psiElement(M68kTypes.MACRO_INVOCATION), object : CompletionProvider() {
+ override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, resultSet: CompletionResultSet) {
+ resultSet.addAllElements(M68kLookupUtil.findAllMacroDefinitions(parameters.originalFile.project).map(LookupElementBuilder::createWithIcon))
+ }
+ })
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallElementManipulator.kt b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallElementManipulator.kt
new file mode 100644
index 0000000..ba4f5fa
--- /dev/null
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallElementManipulator.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.M68kMacroCall
+
+class M68kMacroCallElementManipulator : AbstractElementManipulator() {
+
+ @Throws(IncorrectOperationException::class)
+ override fun handleContentChange(element: M68kMacroCall, range: TextRange, newContent: String): M68kMacroCall {
+ val newMacroCall = M68kElementFactory.createMacroCall(element.project, newContent)
+ element.firstChild.replace(newMacroCall.firstChild)
+ return element
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroReference.kt b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroReference.kt
new file mode 100644
index 0000000..a5ec377
--- /dev/null
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroReference.kt
@@ -0,0 +1,49 @@
+package de.platon42.intellij.plugins.m68k.refs
+
+import com.intellij.openapi.util.TextRange
+import com.intellij.psi.PsiElement
+import com.intellij.psi.PsiElementResolveResult
+import com.intellij.psi.PsiPolyVariantReferenceBase
+import com.intellij.psi.ResolveResult
+import com.intellij.psi.impl.source.resolve.ResolveCache
+import com.intellij.psi.search.GlobalSearchScope
+import com.intellij.psi.stubs.StubIndex
+import com.intellij.util.SmartList
+import de.platon42.intellij.plugins.m68k.psi.M68kMacroCall
+import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
+import de.platon42.intellij.plugins.m68k.stubs.M68kMacroDefinitionStubIndex
+
+class M68kMacroReference(element: M68kMacroCall) :
+ PsiPolyVariantReferenceBase(element, TextRange(0, element.macroName.length)) {
+
+ companion object {
+ val INSTANCE = Resolver()
+ }
+
+ class Resolver : ResolveCache.PolyVariantResolver {
+ override fun resolve(ref: M68kMacroReference, incompleteCode: Boolean): Array {
+ val macroName = ref.element.macroName
+ val project = ref.element.project
+
+ val targets: MutableList = SmartList()
+ StubIndex.getInstance()
+ .processElements(M68kMacroDefinitionStubIndex.KEY, macroName, project, GlobalSearchScope.allScope(project), M68kMacroDefinition::class.java)
+ {
+ targets.add(it)
+ true
+ }
+
+ return targets
+ .map(::PsiElementResolveResult)
+ .toTypedArray()
+ }
+ }
+
+ override fun multiResolve(incompleteCode: Boolean): Array =
+ ResolveCache.getInstance(element.project)
+ .resolveWithCaching(this, INSTANCE, false, incompleteCode)
+
+ override fun resolve(): PsiElement? = multiResolve(false).singleOrNull()?.element
+
+ override fun getVariants(): Array = emptyArray()
+}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kReferenceContributor.kt b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kReferenceContributor.kt
index 81c92a6..307cb61 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kReferenceContributor.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/refs/M68kReferenceContributor.kt
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.refs
import com.intellij.patterns.PlatformPatterns
import com.intellij.psi.*
import com.intellij.util.ProcessingContext
+import de.platon42.intellij.plugins.m68k.psi.M68kMacroCall
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolReference
class M68kReferenceContributor : PsiReferenceContributor() {
@@ -10,11 +11,13 @@ class M68kReferenceContributor : PsiReferenceContributor() {
companion object {
val localLabelReferenceProvider = LocalLabelReferenceProvider()
val globalLabelReferenceProvider = GlobalLabelSymbolReferenceProvider()
+ val macroReferenceProvider = MacroReferenceProvider()
}
override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) {
registrar.registerReferenceProvider(PlatformPatterns.psiElement(M68kSymbolReference::class.java), localLabelReferenceProvider)
registrar.registerReferenceProvider(PlatformPatterns.psiElement(M68kSymbolReference::class.java), globalLabelReferenceProvider)
+ registrar.registerReferenceProvider(PlatformPatterns.psiElement(M68kMacroCall::class.java), macroReferenceProvider)
}
class LocalLabelReferenceProvider : PsiReferenceProvider() {
@@ -32,4 +35,9 @@ class M68kReferenceContributor : PsiReferenceContributor() {
return arrayOf(M68kGlobalLabelSymbolReference(symbolReference))
}
}
+
+ class MacroReferenceProvider : PsiReferenceProvider() {
+ override fun getReferencesByElement(element: PsiElement, context: ProcessingContext): Array =
+ arrayOf(M68kMacroReference(element as M68kMacroCall))
+ }
}
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/scanner/M68kFindUsagesProvider.kt b/src/main/java/de/platon42/intellij/plugins/m68k/scanner/M68kFindUsagesProvider.kt
index ded5f06..8bf2e6d 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/scanner/M68kFindUsagesProvider.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/scanner/M68kFindUsagesProvider.kt
@@ -16,7 +16,7 @@ class M68kFindUsagesProvider : FindUsagesProvider {
override fun getWordsScanner(): WordsScanner =
DefaultWordsScanner(
M68kLexer(M68kLexerPrefs()), // FIXME Oh no! More Prefs!
- TokenSet.create(M68kTypes.SYMBOLDEF, M68kTypes.GLOBAL_LABEL_DEF, M68kTypes.LOCAL_LABEL_DEF, M68kTypes.SYMBOL),
+ TokenSet.create(M68kTypes.SYMBOLDEF, M68kTypes.GLOBAL_LABEL_DEF, M68kTypes.LOCAL_LABEL_DEF, M68kTypes.MACRO_NAME),
TokenSet.create(M68kTypes.COMMENT),
TokenSet.create(M68kTypes.STRINGLIT, M68kTypes.DECIMAL, M68kTypes.HEXADECIMAL, M68kTypes.OCTAL, M68kTypes.BINARY),
TokenSet.EMPTY
@@ -32,6 +32,8 @@ class M68kFindUsagesProvider : FindUsagesProvider {
is M68kLocalLabel -> "local label"
is M68kSymbolDefinition -> "symbol definition"
is M68kSymbolReference -> "symbol reference"
+ is M68kMacroDefinition -> "macro definition"
+ is M68kMacroCall -> "macro call"
is M68kRegister -> "register"
is M68kRefExpr -> "reference expression"
else -> ""
@@ -44,6 +46,8 @@ class M68kFindUsagesProvider : FindUsagesProvider {
is M68kLocalLabel -> element.name!!
is M68kSymbolDefinition -> element.parent.text
is M68kSymbolReference -> element.symbolName
+ is M68kMacroDefinition -> element.macroNameDefinition.text
+ is M68kMacroCall -> element.macroName
is M68kRefExpr -> element.symbolReference?.symbolName ?: ""
is M68kRegister -> element.text
else -> ""
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewElement.kt b/src/main/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewElement.kt
index d87ef2a..c85507f 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewElement.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewElement.kt
@@ -20,6 +20,7 @@ class M68kStructureViewElement(private val myElement: NavigatablePsiElement) : S
is M68kFile -> {
listOf(
M68kLookupUtil.findAllSymbolDefinitions(myElement).sortedBy { it.startOffset },
+ M68kLookupUtil.findAllMacroDefinitions(myElement).sortedBy { it.startOffset },
M68kLookupUtil.findAllGlobalLabels(myElement).sortedBy { it.startOffset },
// M68kLookupUtil.findAllSymbolDefinitions(myElement).sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name!! }),
// M68kLookupUtil.findAllGlobalLabels(myElement).sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name!! })
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewModel.kt b/src/main/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewModel.kt
index eb8b183..2890aa0 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewModel.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewModel.kt
@@ -7,6 +7,7 @@ import com.intellij.ide.util.treeView.smartTree.Sorter
import com.intellij.openapi.editor.Editor
import com.intellij.psi.PsiFile
import de.platon42.intellij.plugins.m68k.psi.M68kLocalLabel
+import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
class M68kStructureViewModel(psiFile: PsiFile, editor: Editor?) :
StructureViewModelBase(psiFile, editor, M68kStructureViewElement(psiFile)), ElementInfoProvider {
@@ -16,7 +17,7 @@ class M68kStructureViewModel(psiFile: PsiFile, editor: Editor?) :
}
override fun isAlwaysLeaf(element: StructureViewTreeElement): Boolean {
- return element.value is M68kLocalLabel
+ return element.value is M68kLocalLabel || element.value is M68kMacroDefinition
}
override fun getSorters(): Array {
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 27a315c..1da37e6 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,11 +8,14 @@ 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.M68kMacroDefinition
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.M68kMacroDefinitionImpl
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.M68kMacroDefinitionStubImpl
import de.platon42.intellij.plugins.m68k.stubs.impl.M68kSymbolDefinitionStubImpl
import java.io.IOException
@@ -67,5 +70,28 @@ interface M68kElementTypes {
override fun indexStub(stub: M68kSymbolDefinitionStub, sink: IndexSink) = sink.occurrence(M68kSymbolDefinitionStubIndex.KEY, stub.name!!)
}
+ @JvmField
+ val MACRO_DEFINITION: IStubElementType =
+ object : M68kStubElementType("MACRO_DEFINITION") {
+ override fun createPsi(stub: M68kMacroDefinitionStub): M68kMacroDefinition = M68kMacroDefinitionImpl(stub, this)
+
+ override fun createStub(psi: M68kMacroDefinition, parentStub: StubElement): M68kMacroDefinitionStub =
+ M68kMacroDefinitionStubImpl(parentStub, this, psi.name!!)
+
+ override fun createStub(tree: LighterAST, node: LighterASTNode, parentStub: StubElement<*>): M68kMacroDefinitionStub {
+ val idNode = LightTreeUtil.requiredChildOfType(tree, node, M68kTypes.MACRO_NAME_DEFINITION)
+ return M68kMacroDefinitionStubImpl(parentStub, this, LightTreeUtil.toFilteredString(tree, idNode, null))
+ }
+
+ @Throws(IOException::class)
+ override fun serialize(stub: M68kMacroDefinitionStub, dataStream: StubOutputStream) = dataStream.writeName(stub.name)
+
+ @Throws(IOException::class)
+ override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>): M68kMacroDefinitionStub =
+ M68kMacroDefinitionStubImpl(parentStub, this, dataStream.readName()!!)
+
+ override fun indexStub(stub: M68kMacroDefinitionStub, sink: IndexSink) = sink.occurrence(M68kMacroDefinitionStubIndex.KEY, stub.name!!)
+ }
+
}
}
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kMacroDefinitionStub.kt b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kMacroDefinitionStub.kt
new file mode 100644
index 0000000..ef9605b
--- /dev/null
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kMacroDefinitionStub.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.M68kMacroDefinition
+
+interface M68kMacroDefinitionStub : NamedStub
\ No newline at end of file
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kMacroDefinitionStubIndex.kt b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kMacroDefinitionStubIndex.kt
new file mode 100644
index 0000000..dddec78
--- /dev/null
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/M68kMacroDefinitionStubIndex.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.M68kMacroDefinition
+
+class M68kMacroDefinitionStubIndex : StringStubIndexExtension() {
+ override fun getKey(): StubIndexKey = KEY
+
+ override fun getVersion(): Int = M68kFileElementType.STUB_VERSION
+
+ companion object {
+ val KEY = StubIndexKey.createIndexKey("mc68000.macrodef.index")
+ }
+}
\ 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 0438443..4f8428d 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
@@ -10,6 +10,7 @@ object M68kStubElementTypeFactory {
return when (name) {
"GLOBAL_LABEL" -> M68kElementTypes.GLOBAL_LABEL
"SYMBOL_DEFINITION" -> M68kElementTypes.SYMBOL_DEFINITION
+ "MACRO_DEFINITION" -> M68kElementTypes.MACRO_DEFINITION
else -> throw RuntimeException("Unknown element type '$name'")
}
}
diff --git a/src/main/java/de/platon42/intellij/plugins/m68k/stubs/impl/M68kMacroDefinitionStubImpl.kt b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/impl/M68kMacroDefinitionStubImpl.kt
new file mode 100644
index 0000000..2bf5001
--- /dev/null
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/stubs/impl/M68kMacroDefinitionStubImpl.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.M68kMacroDefinition
+import de.platon42.intellij.plugins.m68k.stubs.M68kMacroDefinitionStub
+
+class M68kMacroDefinitionStubImpl : NamedStubBase, M68kMacroDefinitionStub {
+ 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/java/de/platon42/intellij/plugins/m68k/syntax/M68kSyntaxHighlighter.kt b/src/main/java/de/platon42/intellij/plugins/m68k/syntax/M68kSyntaxHighlighter.kt
index eb5cdc8..4a29d6b 100644
--- a/src/main/java/de/platon42/intellij/plugins/m68k/syntax/M68kSyntaxHighlighter.kt
+++ b/src/main/java/de/platon42/intellij/plugins/m68k/syntax/M68kSyntaxHighlighter.kt
@@ -34,7 +34,7 @@ class M68kSyntaxHighlighter(val project: Project?) : SyntaxHighlighterBase() {
M68kTypes.MNEMONIC -> arrayOf(MNEMONIC)
M68kTypes.MACRO_TAG, M68kTypes.MACRO_END_TAG -> arrayOf(MACRO_PREPROCESSOR)
M68kTypes.MACRO_LINE -> arrayOf(MACRO_LINE)
- M68kTypes.MACRO_INVOKATION -> arrayOf(MACRO_CALL)
+ M68kTypes.MACRO_INVOCATION -> arrayOf(MACRO_CALL)
M68kTypes.MACRO_NAME -> arrayOf(MACRO_NAME_DEF)
M68kTypes.DATA_DIRECTIVE -> arrayOf(DATA_PREPROCESSOR)
M68kTypes.OTHER_DIRECTIVE, M68kTypes.EQU -> arrayOf(OTHER_PREPROCESSOR)
diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml
index 6ea52ed..bbe094f 100644
--- a/src/main/resources/META-INF/plugin.xml
+++ b/src/main/resources/META-INF/plugin.xml
@@ -24,15 +24,19 @@
+
+
+
diff --git a/src/test/java/de/platon42/intellij/plugins/m68k/parser/MacroCallTest.kt b/src/test/java/de/platon42/intellij/plugins/m68k/parser/MacroCallTest.kt
index 987e185..0e8ab07 100644
--- a/src/test/java/de/platon42/intellij/plugins/m68k/parser/MacroCallTest.kt
+++ b/src/test/java/de/platon42/intellij/plugins/m68k/parser/MacroCallTest.kt
@@ -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...
diff --git a/src/test/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallCompletionContributorTest.kt b/src/test/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallCompletionContributorTest.kt
new file mode 100644
index 0000000..d69f6c6
--- /dev/null
+++ b/src/test/java/de/platon42/intellij/plugins/m68k/refs/M68kMacroCallCompletionContributorTest.kt
@@ -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
+ """
+ )
+ myFixture.completeBasic()
+ assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("nop", "not", "noppy")
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/de/platon42/intellij/plugins/m68k/refs/M68kReferenceContributorTest.kt b/src/test/java/de/platon42/intellij/plugins/m68k/refs/M68kReferenceContributorTest.kt
index e6acad8..cbf0f9e 100644
--- a/src/test/java/de/platon42/intellij/plugins/m68k/refs/M68kReferenceContributorTest.kt
+++ b/src/test/java/de/platon42/intellij/plugins/m68k/refs/M68kReferenceContributorTest.kt
@@ -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")
+ }
}
\ No newline at end of file
diff --git a/src/test/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewTest.kt b/src/test/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewTest.kt
index 98f65af..48e9750 100644
--- a/src/test/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewTest.kt
+++ b/src/test/java/de/platon42/intellij/plugins/m68k/structureview/M68kStructureViewTest.kt
@@ -24,6 +24,8 @@ internal class M68kStructureViewTest : AbstractM68kTest() {
PIC_WIDTH
PIC_HEIGHT
DEBUG_LEVEL
+ BLTHOGON
+ BLTHOGOFF
entry
-init
.looph
diff --git a/src/test/resources/parser/comments/comment_after_macro_call_with_space_introduces_comment_option.txt b/src/test/resources/parser/comments/comment_after_macro_call_with_space_introduces_comment_option.txt
index 9087d72..d0ab9f5 100644
--- a/src/test/resources/parser/comments/comment_after_macro_call_with_space_introduces_comment_option.txt
+++ b/src/test/resources/parser/comments/comment_after_macro_call_with_space_introduces_comment_option.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/parser/comments/space_does_not_start_comment_within_macro_call_without_space_introduces_comment_option.txt b/src/test/resources/parser/comments/space_does_not_start_comment_within_macro_call_without_space_introduces_comment_option.txt
index 3e14f79..41d81f6 100644
--- a/src/test/resources/parser/comments/space_does_not_start_comment_within_macro_call_without_space_introduces_comment_option.txt
+++ b/src/test/resources/parser/comments/space_does_not_start_comment_within_macro_call_without_space_introduces_comment_option.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/parser/labels/bad_indented_dot_local_label_without_label.txt b/src/test/resources/parser/labels/bad_indented_dot_local_label_without_label.txt
index dc72ddb..afa2b3e 100644
--- a/src/test/resources/parser/labels/bad_indented_dot_local_label_without_label.txt
+++ b/src/test/resources/parser/labels/bad_indented_dot_local_label_without_label.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/parser/labels/bad_indented_local_label_dollar_without_label.txt b/src/test/resources/parser/labels/bad_indented_local_label_dollar_without_label.txt
index cc4aa5e..192af52 100644
--- a/src/test/resources/parser/labels/bad_indented_local_label_dollar_without_label.txt
+++ b/src/test/resources/parser/labels/bad_indented_local_label_dollar_without_label.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/parser/macros/call_with_complex_parameters.txt b/src/test/resources/parser/macros/call_with_complex_parameters.txt
index 094dfbb..4ca56c8 100644
--- a/src/test/resources/parser/macros/call_with_complex_parameters.txt
+++ b/src/test/resources/parser/macros/call_with_complex_parameters.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/parser/macros/call_with_label.txt b/src/test/resources/parser/macros/call_with_label.txt
new file mode 100644
index 0000000..523fa25
--- /dev/null
+++ b/src/test/resources/parser/macros/call_with_label.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/parser/macros/pushm_call_with_register_list.txt b/src/test/resources/parser/macros/pushm_call_with_register_list.txt
index b64062f..6c74031 100644
--- a/src/test/resources/parser/macros/pushm_call_with_register_list.txt
+++ b/src/test/resources/parser/macros/pushm_call_with_register_list.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/parser/macros/putmsg_call_with_specially_bracketed_parameters.txt b/src/test/resources/parser/macros/putmsg_call_with_specially_bracketed_parameters.txt
index 8b3b3dd..951fbaf 100644
--- a/src/test/resources/parser/macros/putmsg_call_with_specially_bracketed_parameters.txt
+++ b/src/test/resources/parser/macros/putmsg_call_with_specially_bracketed_parameters.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/parser/macros/standard_macrocall_without_parameters.txt b/src/test/resources/parser/macros/standard_macrocall_without_parameters.txt
index 8c30975..dbf4c10 100644
--- a/src/test/resources/parser/macros/standard_macrocall_without_parameters.txt
+++ b/src/test/resources/parser/macros/standard_macrocall_without_parameters.txt
@@ -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')
\ No newline at end of file
diff --git a/src/test/resources/references/macros/macros.asm b/src/test/resources/references/macros/macros.asm
new file mode 100644
index 0000000..c31efea
--- /dev/null
+++ b/src/test/resources/references/macros/macros.asm
@@ -0,0 +1,13 @@
+PUTMSG MACRO
+ printf
+ ENDM
+
+UAEExitWarp MACRO
+ ENDM
+
+main PUTMSG 10,<"Enter MAIN!">,d0
+ rts
+
+exit PUTMSG 10,<"Exit!">,d0
+ illegal
+ rts
\ No newline at end of file
diff --git a/src/test/resources/references/macros/macros_after_rename.asm b/src/test/resources/references/macros/macros_after_rename.asm
new file mode 100644
index 0000000..c144fe9
--- /dev/null
+++ b/src/test/resources/references/macros/macros_after_rename.asm
@@ -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
\ No newline at end of file
diff --git a/src/test/resources/structureview/basic_example.asm b/src/test/resources/structureview/basic_example.asm
index a7e9edd..a5d2a29 100644
--- a/src/test/resources/structureview/basic_example.asm
+++ b/src/test/resources/structureview/basic_example.asm
@@ -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