19 Commits
Author SHA1 Message Date
chrisly42 8ea70f0dfa Docs update. Prepared next release. 2021-07-28 08:00:09 +02:00
chrisly42 fa1ef0b3d5 Reduced lexer code by combining state rules. Removed one rule, that seemed to be wrong. 2021-07-27 20:27:58 +02:00
chrisly42 3de9e9eba2 Restored compatibility with IDEs versions < 2021.1. Added PluginVerifier to build.gradle. 2021-07-27 17:46:11 +02:00
chrisly42 25450a9bf8 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.
2021-07-27 16:34:49 +02:00
chrisly42 6e683eb6a0 Started working on macro support. Macro-Definition are now plain, unparsed lines. Added Syntax-Highlighter options. 2021-07-27 12:42:26 +02:00
chrisly42 f006199201 Prepared next release. 2021-07-27 08:01:03 +02:00
chrisly42 9553da6a1c Minor fix for ExpressionsTest. 2021-07-26 20:02:20 +02:00
chrisly42 5ffffb5680 Added M68kGlobalLabelSymbolCompletionContributor to replace variants returned by M68kGlobalLabelSymbolReference, to have more control over resolution. Contributor also adds registers to code completion. Code tidying. 2021-07-26 19:52:48 +02:00
chrisly42 fc5e1f6bf7 Enhanced ISA description (no functional changes). 2021-07-26 15:44:13 +02:00
chrisly42 ad3b207362 Added missing test for comparing expressions. Deleted unused generated file for Label-Implementation, noticed problem in inheritance hierarchy and removed base interface M68kLabel, too. 2021-07-26 14:13:12 +02:00
chrisly42 72db8ad8b2 Changes to File stubbing, maybe this fixes some strange errors in log. 2021-07-26 13:10:56 +02:00
chrisly42 82feb8c43c Fixed syntax error for files ending on non-empty line 2021-07-26 10:59:40 +02:00
chrisly42 3165d99fc2 Changed LookupUtil to use stub indexes instead of iterating over global labels and symbol definitions. Added basic test for Structure View. 2021-07-26 10:50:22 +02:00
chrisly42 89ecaeb613 Added stubbing and stub index for symbol definitions. 2021-07-25 20:13:13 +02:00
chrisly42 83d2ca3304 Added first stubbing and stub index for global labels. 2021-07-25 19:53:06 +02:00
chrisly42 a800b13a3e Call Word-Index for Global Labels and Symbols instead of iterating over the files. Removed unused file. 2021-07-24 19:46:28 +02:00
chrisly42 d872feeec4 Added plugin icon. 2021-07-24 18:27:41 +02:00
chrisly42 884624e833 Oops. Not good at dates :-/ 2021-07-20 17:19:38 +02:00
chrisly42 27d9d3c543 Decreased minimum build version to allow the compatible CLion 2019.3.6. 2021-07-20 17:08:53 +02:00
136 changed files with 2876 additions and 1377 deletions
+33 -10
View File
@@ -27,8 +27,8 @@ it's "good enough" to get started, and I can return to demo coding with its curr
- Parser / Lexer for MC68000 (yes, only 68000 right now!) assembly language files in VAsm / DevPac style
- Syntax highlighting and Color Settings Page (you should really modify the color settings to your likings!)
- Mnemonics code completion
- Symbols / Labels code completion
- References / Refactoring support for local and global labels, and symbol assignments.
- Symbols / Labels / Macros code completion
- References / Refactoring support for local and global labels, symbol assignments, and macros.
- Brace matching
- Quote handler
- Goto Symbol support
@@ -36,28 +36,31 @@ it's "good enough" to get started, and I can return to demo coding with its curr
## Known issues
- Performance is not optimal yet (no stub index).
- No referencing of macro invocations and macro definitions.
- `Find Usages` always shows _"Unclassified"_ though it shouldn't.
- Macro definitions may cause syntax errors when using backslash arguments.
- `Find Usages` always shows _"Unclassified"_ though it shouldn't (?)
- Macro invocations are not yet evaluated, thus no referencing to symbols defined via macros (e.g. `STRUCT`).
- No support for includes. Scoping is for global symbols and labels is currently the whole project.
- No support for register replacement (e.g. registers replaced by `EQUR` or `EQURL` will cause syntax errors)
- While the Lexer supports the -spaces option (where a space introduces a comment), this cannot be configured yet.
- While the Lexer supports the -spaces option (where a space introduces a comment), this cannot be configured yet (default is off).
- No support for other processor instructions, FPU or 68020+ address modes.
- No semantic checking for allowed address modes or data widths yet.
- Unit Test coverage is not as good as it could be (ahem).
- Missing but planned features:
- Macro definition and evaluation on invocation
- Macro evaluation on invocation
- Folding
- Semantic inspections
- Quick fixes
- Formatter + Code Style Settings
- Register use analysis (but this only makes sense after macro evaluation)
- Cycle counting
## Recommendations
Currently, I would suggest using the fabulous [Browse Word at Caret Plugin](https://plugins.jetbrains.com/plugin/201-browsewordatcaret)
to highlight the same address and data registers while editing (see new `View -> Highlight Word at Caret` menu item).
## Development notice
This plugin has been written in Kotlin 1.5.
This plugin has been written in Kotlin 1.5 using Grammar-Kit.
It is probably the only plugin (besides [Cajon](https://github.com/chrisly42/cajon-plugin) from the same author) that uses JUnit 5 Jupiter for unit testing so
far (or at least the only one I'm aware of ;) ). The IntelliJ framework actually uses the JUnit 3 TestCase for plugin testing, and it took me quite a while to
@@ -65,6 +68,26 @@ make it work with JUnit 5. Feel free to use the code (in package ```de.platon42.
## Changelog
### V0.1 (20-Jun-21)
### V0.3 (28-Jul-21)
- Enhancement: Macro 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.
- Compatibility: Restored compatibility with IDE versions < 2021.1.
- Performance: Optimized lexer.
### V0.2 (27-Jul-21)
- Cosmetics: Added (same) icon for plugin as for file type.
- Performance: Use Word-Index for global labels and symbols instead of iterating over the file.
- Performance: Use Stub-Index for global labels and symbols.
- Bugfix: No longer reports a syntax error when file lacks terminating End-Of-Line.
- Enhancement: Registers are now offered for code completion, making editing less annoying.
### V0.1 (20-Jul-21)
- Initial public release.
+29 -3
View File
@@ -7,7 +7,7 @@ plugins {
}
group = 'de.platon42'
version = '0.1'
version = '0.3'
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
@@ -44,11 +44,37 @@ intellij {
// setPlugins(["com.intellij.java"])
}
runPluginVerifier {
ideVersions = ["IC-193.5662.53", "IC-211.7628.21", // 2019.3.1 - 2021.1.3
"CL-193.5233.103", "CL-193.7288.25", // 2019.3
"CL-201.6668.126", "CL-201.8743.17", // 2020.1
"CL-202.6397.106", "CL-202.8194.17", // 2020.2
"CL-203.5981.166", "CL-203.8084.11", // 2020.3
"CL-211.6693.114", "CL-211.7628.27"] // 2021.1
downloadDir = System.getProperty("user.home") + "/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea"
}
patchPluginXml {
setChangeNotes("""
<h4>V0.1 (20-Jun-21)</h4>
<h4>V0.3 (28-Jul-21)</h4>
<ul>
<li>Initial public release.
<li>Enhancement: Macro contents are no longer parsed, added syntax highlighting options for macros.
<li>Enhancement: Macro definitions are now word and stub indexed, macro calls reference to definition.
<li>Enhancement: Macro definition refactoring and find usages support.
<li>Enhancement: Structural View also shows macro definitions.
<li>Bugfix: Missing REPT and ENDR assembler directives added.
<li>Cosmetics: Changed or added some icons at various places.
<li>Performance: Reference search for global labels and symbols now uses stub index.
<li>Compatibility: Restored compatibility with IDE versions < 2021.1.
<li>Performance: Optimized lexer.
</ul>
<h4>V0.2 (27-Jul-21)</h4>
<ul>
<li>Cosmetics: Added (same) icon for plugin as for file type.
<li>Performance: Use Word-Index for global labels and symbols instead of iterating over the file.
<li>Performance: Use Stub-Index for global labels and symbols.
<li>Bugfix: No longer reports a syntax error when file lacks terminating End-Of-Line.
<li>Enhancement: Registers are now offered for code completion, making editing less annoying.
</ul>
<p>Full changelog available at <a href="https://github.com/chrisly42/mc68000-asm-plugin#changelog">Github project site</a>.</p>
""")
File diff suppressed because it is too large Load Diff
@@ -37,7 +37,6 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
public static final TokenSet[] EXTENDS_SETS_ = new TokenSet[]{
create_token_set_(GLOBAL_LABEL, LABEL, LOCAL_LABEL),
create_token_set_(ADDRESS_REGISTER, DATA_REGISTER, REGISTER, SPECIAL_REGISTER),
create_token_set_(ABSOLUTE_ADDRESS_ADDRESSING_MODE, ADDRESSING_MODE, ADDRESS_REGISTER_DIRECT_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_ADDRESSING_MODE,
ADDRESS_REGISTER_INDIRECT_POST_INC_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_PRE_DEC_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_NEW_ADDRESSING_MODE, ADDRESS_REGISTER_INDIRECT_WITH_DISPLACEMENT_OLD_ADDRESSING_MODE,
@@ -552,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);
@@ -567,14 +566,12 @@ public class M68kParser implements PsiParser, LightPsiParser {
/* ********************************************************** */
// LocalLabel | GlobalLabel
public static boolean Label(PsiBuilder b, int l) {
static boolean Label(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "Label")) return false;
if (!nextTokenIs(b, "<label>", GLOBAL_LABEL_DEF, LOCAL_LABEL_DEF)) return false;
if (!nextTokenIs(b, "", GLOBAL_LABEL_DEF, LOCAL_LABEL_DEF)) return false;
boolean r;
Marker m = enter_section_(b, l, _COLLAPSE_, LABEL, "<label>");
r = LocalLabel(b, l + 1);
if (!r) r = GlobalLabel(b, l + 1);
exit_section_(b, l, m, r, false, null);
return r;
}
@@ -641,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;
@@ -660,6 +657,89 @@ public class M68kParser implements PsiParser, LightPsiParser {
return true;
}
/* ********************************************************** */
// ((MacroNameDefinition MACRO_TAG)|(MACRO_TAG MacroNameDefinition)) MacroPlainLine* MACRO_END_TAG
public static boolean MacroDefinition(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition")) return false;
if (!nextTokenIs(b, "<macro definition>", MACRO_NAME, MACRO_TAG)) return false;
boolean r, p;
Marker m = enter_section_(b, l, _NONE_, MACRO_DEFINITION, "<macro definition>");
r = MacroDefinition_0(b, l + 1);
p = r; // pin = 1
r = r && report_error_(b, MacroDefinition_1(b, l + 1));
r = p && consumeToken(b, MACRO_END_TAG) && r;
exit_section_(b, l, m, r, p, null);
return r || p;
}
// (MacroNameDefinition MACRO_TAG)|(MACRO_TAG MacroNameDefinition)
private static boolean MacroDefinition_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = MacroDefinition_0_0(b, l + 1);
if (!r) r = MacroDefinition_0_1(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// MacroNameDefinition MACRO_TAG
private static boolean MacroDefinition_0_0(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition_0_0")) return false;
boolean r;
Marker m = enter_section_(b);
r = MacroNameDefinition(b, l + 1);
r = r && consumeToken(b, MACRO_TAG);
exit_section_(b, m, null, r);
return r;
}
// MACRO_TAG MacroNameDefinition
private static boolean MacroDefinition_0_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition_0_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, MACRO_TAG);
r = r && MacroNameDefinition(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// MacroPlainLine*
private static boolean MacroDefinition_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroDefinition_1")) return false;
while (true) {
int c = current_position_(b);
if (!MacroPlainLine(b, l + 1)) break;
if (!empty_element_parsed_guard_(b, "MacroDefinition_1", c)) break;
}
return true;
}
/* ********************************************************** */
// MACRO_NAME
public static boolean MacroNameDefinition(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroNameDefinition")) return false;
if (!nextTokenIs(b, MACRO_NAME)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, MACRO_NAME);
exit_section_(b, m, MACRO_NAME_DEFINITION, r);
return r;
}
/* ********************************************************** */
// MACRO_LINE
public static boolean MacroPlainLine(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "MacroPlainLine")) return false;
if (!nextTokenIs(b, MACRO_LINE)) return false;
boolean r;
Marker m = enter_section_(b);
r = consumeToken(b, MACRO_LINE);
exit_section_(b, m, MACRO_PLAIN_LINE, r);
return r;
}
/* ********************************************************** */
// OPSIZE_BS|OPSIZE_W|OPSIZE_L
public static boolean OperandSize(PsiBuilder b, int l) {
@@ -674,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) {
@@ -697,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?
@@ -1051,14 +1149,14 @@ public class M68kParser implements PsiParser, LightPsiParser {
}
/* ********************************************************** */
// !<<eof>> statement EOL
// !<<eof>> (MacroDefinition | statement) (<<eof>>|EOL)
static boolean line(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "line")) return false;
boolean r;
Marker m = enter_section_(b);
r = line_0(b, l + 1);
r = r && statement(b, l + 1);
r = r && consumeToken(b, EOL);
r = r && line_1(b, l + 1);
r = r && line_2(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
@@ -1073,6 +1171,28 @@ public class M68kParser implements PsiParser, LightPsiParser {
return r;
}
// MacroDefinition | statement
private static boolean line_1(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "line_1")) return false;
boolean r;
Marker m = enter_section_(b);
r = MacroDefinition(b, l + 1);
if (!r) r = statement(b, l + 1);
exit_section_(b, m, null, r);
return r;
}
// <<eof>>|EOL
private static boolean line_2(PsiBuilder b, int l) {
if (!recursion_guard_(b, l, "line_2")) return false;
boolean r;
Marker m = enter_section_(b);
r = eof(b, l + 1);
if (!r) r = consumeToken(b, EOL);
exit_section_(b, m, null, r);
return r;
}
/* ********************************************************** */
// Assignment
// | PreprocessorDirective
@@ -1,8 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
public interface M68kAddressSize extends PsiElement {
public interface M68kAddressSize extends M68kPsiElement {
}
@@ -1,8 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
public interface M68kAddressingMode extends PsiElement {
public interface M68kAddressingMode extends M68kPsiElement {
}
@@ -1,12 +1,11 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface M68kAsmInstruction extends PsiElement {
public interface M68kAsmInstruction extends M68kPsiElement {
@NotNull
List<M68kAddressingMode> getAddressingModeList();
@@ -1,10 +1,9 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
public interface M68kAsmOp extends PsiElement {
public interface M68kAsmOp extends M68kPsiElement {
@Nullable
M68kOperandSize getOperandSize();
@@ -1,10 +1,9 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
public interface M68kAssignment extends PsiElement {
public interface M68kAssignment extends M68kPsiElement {
@NotNull
M68kSymbolDefinition getSymbolDefinition();
@@ -1,8 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
public interface M68kDataWidth extends PsiElement {
public interface M68kDataWidth extends M68kPsiElement {
}
@@ -1,8 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
public interface M68kExpr extends PsiElement {
public interface M68kExpr extends M68kPsiElement {
}
@@ -2,10 +2,12 @@
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import com.intellij.psi.StubBasedPsiElement;
import de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStub;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kGlobalLabel extends M68kLabel, M68kNamedElement {
public interface M68kGlobalLabel extends M68kNamedElement, StubBasedPsiElement<M68kGlobalLabelStub> {
@Nullable
String getName();
@@ -5,7 +5,7 @@ import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kLocalLabel extends M68kLabel, M68kNamedElement {
public interface M68kLocalLabel extends M68kNamedElement {
@Nullable
String getName();
@@ -1,8 +1,19 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
public interface M68kMacroCall extends PsiElement {
import java.util.List;
public interface M68kMacroCall extends M68kPsiElement {
@NotNull
List<M68kAddressingMode> getAddressingModeList();
@NotNull
List<M68kExpr> getExprList();
@NotNull
String getMacroName();
}
@@ -0,0 +1,29 @@
// 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 M68kNamedElement, StubBasedPsiElement<M68kMacroDefinitionStub> {
@NotNull
M68kMacroNameDefinition getMacroNameDefinition();
@NotNull
List<M68kMacroPlainLine> getMacroPlainLineList();
@Nullable
String getName();
@NotNull
PsiElement setName(@NotNull String name);
@NotNull
PsiElement getNameIdentifier();
}
@@ -1,8 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
public interface M68kLabel extends PsiElement {
public interface M68kMacroNameDefinition extends M68kPsiElement {
}
@@ -0,0 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
public interface M68kMacroPlainLine extends M68kPsiElement {
}
@@ -1,8 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
public interface M68kOperandSize extends PsiElement {
public interface M68kOperandSize extends M68kPsiElement {
}
@@ -1,16 +1,18 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public interface M68kPreprocessorDirective extends PsiElement {
public interface M68kPreprocessorDirective extends M68kPsiElement {
@Nullable
M68kLabel getLabel();
M68kGlobalLabel getGlobalLabel();
@Nullable
M68kLocalLabel getLocalLabel();
@NotNull
List<M68kExpr> getExprList();
@@ -1,8 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
public interface M68kProgramCounterReference extends PsiElement {
public interface M68kProgramCounterReference extends M68kPsiElement {
}
@@ -1,8 +1,6 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
public interface M68kRegister extends PsiElement {
public interface M68kRegister extends M68kPsiElement {
}
@@ -1,10 +1,9 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.Nullable;
public interface M68kStatement extends PsiElement {
public interface M68kStatement extends M68kPsiElement {
@Nullable
M68kAsmInstruction getAsmInstruction();
@@ -13,7 +12,10 @@ public interface M68kStatement extends PsiElement {
M68kAssignment getAssignment();
@Nullable
M68kLabel getLabel();
M68kGlobalLabel getGlobalLabel();
@Nullable
M68kLocalLabel getLocalLabel();
@Nullable
M68kMacroCall getMacroCall();
@@ -2,10 +2,12 @@
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import com.intellij.psi.StubBasedPsiElement;
import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStub;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface M68kSymbolDefinition extends M68kNamedElement {
public interface M68kSymbolDefinition extends M68kNamedElement, StubBasedPsiElement<M68kSymbolDefinitionStub> {
@Nullable
String getName();
@@ -1,10 +1,9 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
public interface M68kSymbolReference extends PsiElement {
public interface M68kSymbolReference extends M68kPsiElement {
@NotNull
String getSymbolName();
@@ -5,6 +5,7 @@ import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import de.platon42.intellij.plugins.m68k.psi.impl.*;
import de.platon42.intellij.plugins.m68k.stubs.M68kStubElementTypeFactory;
public interface M68kTypes {
@@ -45,12 +46,14 @@ public interface M68kTypes {
IElementType DATA_REGISTER_DIRECT_ADDRESSING_MODE = new M68kElementType("DATA_REGISTER_DIRECT_ADDRESSING_MODE");
IElementType DATA_WIDTH = new M68kElementType("DATA_WIDTH");
IElementType EXPR = new M68kElementType("EXPR");
IElementType GLOBAL_LABEL = new M68kElementType("GLOBAL_LABEL");
IElementType GLOBAL_LABEL = M68kStubElementTypeFactory.stubFactory("GLOBAL_LABEL");
IElementType IMMEDIATE_DATA = new M68kElementType("IMMEDIATE_DATA");
IElementType LABEL = new M68kElementType("LABEL");
IElementType LITERAL_EXPR = new M68kElementType("LITERAL_EXPR");
IElementType LOCAL_LABEL = new M68kElementType("LOCAL_LABEL");
IElementType MACRO_CALL = new M68kElementType("MACRO_CALL");
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");
IElementType PAREN_EXPR = new M68kElementType("PAREN_EXPR");
IElementType PREPROCESSOR_DIRECTIVE = new M68kElementType("PREPROCESSOR_DIRECTIVE");
@@ -65,7 +68,7 @@ public interface M68kTypes {
IElementType SPECIAL_REGISTER = new M68kElementType("SPECIAL_REGISTER");
IElementType SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE = new M68kElementType("SPECIAL_REGISTER_DIRECT_ADDRESSING_MODE");
IElementType STATEMENT = new M68kElementType("STATEMENT");
IElementType SYMBOL_DEFINITION = new M68kElementType("SYMBOL_DEFINITION");
IElementType SYMBOL_DEFINITION = M68kStubElementTypeFactory.stubFactory("SYMBOL_DEFINITION");
IElementType SYMBOL_REFERENCE = new M68kElementType("SYMBOL_REFERENCE");
IElementType UNARY_COMPL_EXPR = new M68kElementType("UNARY_COMPL_EXPR");
IElementType UNARY_MINUS_EXPR = new M68kElementType("UNARY_MINUS_EXPR");
@@ -86,7 +89,11 @@ public interface M68kTypes {
IElementType HASH = new M68kTokenType("HASH");
IElementType HEXADECIMAL = new M68kTokenType("HEXADECIMAL");
IElementType LOCAL_LABEL_DEF = new M68kTokenType("LOCAL_LABEL_DEF");
IElementType MACRO_INVOKATION = new M68kTokenType("MACRO_INVOKATION");
IElementType MACRO_END_TAG = new M68kTokenType("MACRO_END_TAG");
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");
IElementType MNEMONIC = new M68kTokenType("MNEMONIC");
IElementType OCTAL = new M68kTokenType("OCTAL");
IElementType OPSIZE_BS = new M68kTokenType("OPSIZE_BS");
@@ -210,6 +217,12 @@ public interface M68kTypes {
return new M68kLocalLabelImpl(node);
} else if (type == MACRO_CALL) {
return new M68kMacroCallImpl(node);
} else if (type == MACRO_DEFINITION) {
return new M68kMacroDefinitionImpl(node);
} else if (type == MACRO_NAME_DEFINITION) {
return new M68kMacroNameDefinitionImpl(node);
} else if (type == MACRO_PLAIN_LINE) {
return new M68kMacroPlainLineImpl(node);
} else if (type == OPERAND_SIZE) {
return new M68kOperandSizeImpl(node);
} else if (type == PAREN_EXPR) {
@@ -1,7 +1,6 @@
// 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.PsiElementVisitor;
import org.jetbrains.annotations.NotNull;
@@ -80,27 +79,33 @@ public class M68kVisitor extends PsiElementVisitor {
}
public void visitGlobalLabel(@NotNull M68kGlobalLabel o) {
visitLabel(o);
// visitNamedElement(o);
visitNamedElement(o);
}
public void visitImmediateData(@NotNull M68kImmediateData o) {
visitAddressingMode(o);
}
public void visitLabel(@NotNull M68kLabel o) {
visitPsiElement(o);
}
public void visitLocalLabel(@NotNull M68kLocalLabel o) {
visitLabel(o);
// visitNamedElement(o);
visitNamedElement(o);
}
public void visitMacroCall(@NotNull M68kMacroCall o) {
visitPsiElement(o);
}
public void visitMacroDefinition(@NotNull M68kMacroDefinition o) {
visitNamedElement(o);
}
public void visitMacroNameDefinition(@NotNull M68kMacroNameDefinition o) {
visitPsiElement(o);
}
public void visitMacroPlainLine(@NotNull M68kMacroPlainLine o) {
visitPsiElement(o);
}
public void visitOperandSize(@NotNull M68kOperandSize o) {
visitPsiElement(o);
}
@@ -266,7 +271,7 @@ public class M68kVisitor extends PsiElementVisitor {
visitPsiElement(o);
}
public void visitPsiElement(@NotNull PsiElement o) {
public void visitPsiElement(@NotNull M68kPsiElement o) {
visitElement(o);
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAbsoluteAddressAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressSize;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
@@ -30,13 +31,13 @@ public class M68kAbsoluteAddressAddressingModeImpl extends M68kAddressingModeImp
@Override
@Nullable
public M68kAddressSize getAddressSize() {
return findChildByClass(M68kAddressSize.class);
return PsiTreeUtil.getChildOfType(this, M68kAddressSize.class);
}
@Override
@NotNull
public M68kExpr getExpr() {
return findNotNullChildByClass(M68kExpr.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegisterDirectAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -28,7 +29,7 @@ public class M68kAddressRegisterDirectAddressingModeImpl extends M68kAddressingM
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return findNotNullChildByClass(M68kAddressRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegisterIndirectAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -28,7 +29,7 @@ public class M68kAddressRegisterIndirectAddressingModeImpl extends M68kAddressin
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return findNotNullChildByClass(M68kAddressRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegisterIndirectPostIncAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -28,7 +29,7 @@ public class M68kAddressRegisterIndirectPostIncAddressingModeImpl extends M68kAd
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return findNotNullChildByClass(M68kAddressRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegisterIndirectPreDecAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -28,7 +29,7 @@ public class M68kAddressRegisterIndirectPreDecAddressingModeImpl extends M68kAdd
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return findNotNullChildByClass(M68kAddressRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegisterIndirectWithDisplacementNewAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
@@ -29,13 +30,13 @@ public class M68kAddressRegisterIndirectWithDisplacementNewAddressingModeImpl ex
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return findNotNullChildByClass(M68kAddressRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
@Override
@NotNull
public M68kExpr getExpr() {
return findNotNullChildByClass(M68kExpr.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegisterIndirectWithDisplacementOldAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
@@ -29,13 +30,13 @@ public class M68kAddressRegisterIndirectWithDisplacementOldAddressingModeImpl ex
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return findNotNullChildByClass(M68kAddressRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
@Override
@NotNull
public M68kExpr getExpr() {
return findNotNullChildByClass(M68kExpr.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,25 +28,25 @@ public class M68kAddressRegisterIndirectWithIndexNewAddressingModeImpl extends M
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return findNotNullChildByClass(M68kAddressRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
@Override
@Nullable
public M68kDataWidth getDataWidth() {
return findChildByClass(M68kDataWidth.class);
return PsiTreeUtil.getChildOfType(this, M68kDataWidth.class);
}
@Override
@NotNull
public M68kRegister getRegister() {
return findNotNullChildByClass(M68kRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kRegister.class));
}
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,25 +28,25 @@ public class M68kAddressRegisterIndirectWithIndexOldAddressingModeImpl extends M
@Override
@NotNull
public M68kAddressRegister getAddressRegister() {
return findNotNullChildByClass(M68kAddressRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAddressRegister.class));
}
@Override
@Nullable
public M68kDataWidth getDataWidth() {
return findChildByClass(M68kDataWidth.class);
return PsiTreeUtil.getChildOfType(this, M68kDataWidth.class);
}
@Override
@NotNull
public M68kRegister getRegister() {
return findNotNullChildByClass(M68kRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kRegister.class));
}
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -38,7 +38,7 @@ public class M68kAsmInstructionImpl extends ASTWrapperPsiElement implements M68k
@Override
@NotNull
public M68kAsmOp getAsmOp() {
return findNotNullChildByClass(M68kAsmOp.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kAsmOp.class));
}
}
@@ -4,6 +4,7 @@ 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 com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAsmOp;
import de.platon42.intellij.plugins.m68k.psi.M68kOperandSize;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -29,7 +30,7 @@ public class M68kAsmOpImpl extends ASTWrapperPsiElement implements M68kAsmOp {
@Override
@Nullable
public M68kOperandSize getOperandSize() {
return findChildByClass(M68kOperandSize.class);
return PsiTreeUtil.getChildOfType(this, M68kOperandSize.class);
}
}
@@ -4,6 +4,7 @@ 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 com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kAssignment;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition;
@@ -29,13 +30,13 @@ public class M68kAssignmentImpl extends ASTWrapperPsiElement implements M68kAssi
@Override
@NotNull
public M68kSymbolDefinition getSymbolDefinition() {
return findNotNullChildByClass(M68kSymbolDefinition.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kSymbolDefinition.class));
}
@Override
@NotNull
public M68kExpr getExpr() {
return findNotNullChildByClass(M68kExpr.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kDataRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kDataRegisterDirectAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -28,7 +29,7 @@ public class M68kDataRegisterDirectAddressingModeImpl extends M68kAddressingMode
@Override
@NotNull
public M68kDataRegister getDataRegister() {
return findNotNullChildByClass(M68kDataRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kDataRegister.class));
}
}
@@ -4,10 +4,12 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.stubs.IStubElementType;
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel;
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabelMixin;
import de.platon42.intellij.plugins.m68k.psi.M68kPsiImplUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStub;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -17,6 +19,10 @@ public class M68kGlobalLabelImpl extends M68kGlobalLabelMixin implements M68kGlo
super(node);
}
public M68kGlobalLabelImpl(@NotNull M68kGlobalLabelStub stub, @NotNull IStubElementType<?, ?> nodeType) {
super(stub, nodeType);
}
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitGlobalLabel(this);
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kImmediateData;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -28,7 +29,7 @@ public class M68kImmediateDataImpl extends M68kAddressingModeImpl implements M68
@Override
@NotNull
public M68kExpr getExpr() {
return findNotNullChildByClass(M68kExpr.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}
@@ -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<M68kAddressingMode> getAddressingModeList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, M68kAddressingMode.class);
}
@Override
@NotNull
public List<M68kExpr> getExprList() {
return PsiTreeUtil.getChildrenOfTypeAsList(this, M68kExpr.class);
}
@Override
@NotNull
public String getMacroName() {
return M68kPsiImplUtil.getMacroName(this);
}
}
@@ -0,0 +1,66 @@
// This is a generated file. Not intended for manual editing.
package de.platon42.intellij.plugins.m68k.psi.impl;
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.*;
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 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);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
@Override
@NotNull
public M68kMacroNameDefinition getMacroNameDefinition() {
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kMacroNameDefinition.class));
}
@Override
@NotNull
public List<M68kMacroPlainLine> getMacroPlainLineList() {
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);
}
}
@@ -0,0 +1,27 @@
// 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.M68kMacroNameDefinition;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
public class M68kMacroNameDefinitionImpl extends ASTWrapperPsiElement implements M68kMacroNameDefinition {
public M68kMacroNameDefinitionImpl(@NotNull ASTNode node) {
super(node);
}
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitMacroNameDefinition(this);
}
@Override
public void accept(@NotNull PsiElementVisitor visitor) {
if (visitor instanceof M68kVisitor) accept((M68kVisitor) visitor);
else super.accept(visitor);
}
}
@@ -4,18 +4,18 @@ 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.M68kLabel;
import de.platon42.intellij.plugins.m68k.psi.M68kMacroPlainLine;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import org.jetbrains.annotations.NotNull;
public abstract class M68kLabelImpl extends ASTWrapperPsiElement implements M68kLabel {
public class M68kMacroPlainLineImpl extends ASTWrapperPsiElement implements M68kMacroPlainLine {
public M68kLabelImpl(@NotNull ASTNode node) {
public M68kMacroPlainLineImpl(@NotNull ASTNode node) {
super(node);
}
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitLabel(this);
visitor.visitMacroPlainLine(this);
}
@Override
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kParenExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -29,7 +30,7 @@ public class M68kParenExprImpl extends M68kExprImpl implements M68kParenExpr {
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -5,10 +5,7 @@ import com.intellij.extapi.psi.ASTWrapperPsiElement;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kLabel;
import de.platon42.intellij.plugins.m68k.psi.M68kPreprocessorDirective;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -32,8 +29,14 @@ public class M68kPreprocessorDirectiveImpl extends ASTWrapperPsiElement implemen
@Override
@Nullable
public M68kLabel getLabel() {
return findChildByClass(M68kLabel.class);
public M68kGlobalLabel getGlobalLabel() {
return PsiTreeUtil.getChildOfType(this, M68kGlobalLabel.class);
}
@Override
@Nullable
public M68kLocalLabel getLocalLabel() {
return PsiTreeUtil.getChildOfType(this, M68kLocalLabel.class);
}
@Override
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kProgramCounterIndirectWithDisplacementNewAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -28,7 +29,7 @@ public class M68kProgramCounterIndirectWithDisplacementNewAddressingModeImpl ext
@Override
@NotNull
public M68kExpr getExpr() {
return findNotNullChildByClass(M68kExpr.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kExpr.class));
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kProgramCounterIndirectWithDisplacementOldAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -29,7 +30,7 @@ public class M68kProgramCounterIndirectWithDisplacementOldAddressingModeImpl ext
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,19 +28,19 @@ public class M68kProgramCounterIndirectWithIndexNewAddressingModeImpl extends M6
@Override
@Nullable
public M68kDataWidth getDataWidth() {
return findChildByClass(M68kDataWidth.class);
return PsiTreeUtil.getChildOfType(this, M68kDataWidth.class);
}
@Override
@NotNull
public M68kRegister getRegister() {
return findNotNullChildByClass(M68kRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kRegister.class));
}
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,19 +28,19 @@ public class M68kProgramCounterIndirectWithIndexOldAddressingModeImpl extends M6
@Override
@Nullable
public M68kDataWidth getDataWidth() {
return findChildByClass(M68kDataWidth.class);
return PsiTreeUtil.getChildOfType(this, M68kDataWidth.class);
}
@Override
@NotNull
public M68kRegister getRegister() {
return findNotNullChildByClass(M68kRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kRegister.class));
}
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kProgramCounterReference;
import de.platon42.intellij.plugins.m68k.psi.M68kRefExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolReference;
@@ -30,13 +31,13 @@ public class M68kRefExprImpl extends M68kExprImpl implements M68kRefExpr {
@Override
@Nullable
public M68kProgramCounterReference getProgramCounterReference() {
return findChildByClass(M68kProgramCounterReference.class);
return PsiTreeUtil.getChildOfType(this, M68kProgramCounterReference.class);
}
@Override
@Nullable
public M68kSymbolReference getSymbolReference() {
return findChildByClass(M68kSymbolReference.class);
return PsiTreeUtil.getChildOfType(this, M68kSymbolReference.class);
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kSpecialRegister;
import de.platon42.intellij.plugins.m68k.psi.M68kSpecialRegisterDirectAddressingMode;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -28,7 +29,7 @@ public class M68kSpecialRegisterDirectAddressingModeImpl extends M68kAddressingM
@Override
@NotNull
public M68kSpecialRegister getSpecialRegister() {
return findNotNullChildByClass(M68kSpecialRegister.class);
return notNullChild(PsiTreeUtil.getChildOfType(this, M68kSpecialRegister.class));
}
}
@@ -4,6 +4,7 @@ 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 com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.*;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -27,31 +28,37 @@ public class M68kStatementImpl extends ASTWrapperPsiElement implements M68kState
@Override
@Nullable
public M68kAsmInstruction getAsmInstruction() {
return findChildByClass(M68kAsmInstruction.class);
return PsiTreeUtil.getChildOfType(this, M68kAsmInstruction.class);
}
@Override
@Nullable
public M68kAssignment getAssignment() {
return findChildByClass(M68kAssignment.class);
return PsiTreeUtil.getChildOfType(this, M68kAssignment.class);
}
@Override
@Nullable
public M68kLabel getLabel() {
return findChildByClass(M68kLabel.class);
public M68kGlobalLabel getGlobalLabel() {
return PsiTreeUtil.getChildOfType(this, M68kGlobalLabel.class);
}
@Override
@Nullable
public M68kLocalLabel getLocalLabel() {
return PsiTreeUtil.getChildOfType(this, M68kLocalLabel.class);
}
@Override
@Nullable
public M68kMacroCall getMacroCall() {
return findChildByClass(M68kMacroCall.class);
return PsiTreeUtil.getChildOfType(this, M68kMacroCall.class);
}
@Override
@Nullable
public M68kPreprocessorDirective getPreprocessorDirective() {
return findChildByClass(M68kPreprocessorDirective.class);
return PsiTreeUtil.getChildOfType(this, M68kPreprocessorDirective.class);
}
}
@@ -4,10 +4,12 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.stubs.IStubElementType;
import de.platon42.intellij.plugins.m68k.psi.M68kPsiImplUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition;
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinitionMixin;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStub;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -17,6 +19,10 @@ public class M68kSymbolDefinitionImpl extends M68kSymbolDefinitionMixin implemen
super(node);
}
public M68kSymbolDefinitionImpl(@NotNull M68kSymbolDefinitionStub stub, @NotNull IStubElementType<?, ?> nodeType) {
super(stub, nodeType);
}
public void accept(@NotNull M68kVisitor visitor) {
visitor.visitSymbolDefinition(this);
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kUnaryComplExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -29,7 +30,7 @@ public class M68kUnaryComplExprImpl extends M68kExprImpl implements M68kUnaryCom
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kUnaryMinusExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -29,7 +30,7 @@ public class M68kUnaryMinusExprImpl extends M68kExprImpl implements M68kUnaryMin
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kUnaryNotExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -29,7 +30,7 @@ public class M68kUnaryNotExprImpl extends M68kExprImpl implements M68kUnaryNotEx
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -3,6 +3,7 @@ package de.platon42.intellij.plugins.m68k.psi.impl;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.util.PsiTreeUtil;
import de.platon42.intellij.plugins.m68k.psi.M68kExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kUnaryPlusExpr;
import de.platon42.intellij.plugins.m68k.psi.M68kVisitor;
@@ -29,7 +30,7 @@ public class M68kUnaryPlusExprImpl extends M68kExprImpl implements M68kUnaryPlus
@Override
@Nullable
public M68kExpr getExpr() {
return findChildByClass(M68kExpr.class);
return PsiTreeUtil.getChildOfType(this, M68kExpr.class);
}
}
@@ -1,27 +1,21 @@
package de.platon42.intellij.plugins.m68k
import com.intellij.psi.PsiFile
import com.intellij.psi.stubs.DefaultStubBuilder
import com.intellij.psi.stubs.StubElement
import com.intellij.psi.tree.IStubFileElementType
import com.intellij.psi.stubs.PsiFileStub
import com.intellij.psi.tree.ILightStubFileElementType
import de.platon42.intellij.plugins.m68k.psi.M68kFile
import de.platon42.intellij.plugins.m68k.stubs.M68kFileStub
class M68kFileElementType private constructor() : IStubFileElementType<M68kFileStub>("MC68000_FILE", MC68000Language.INSTANCE) {
class M68kFileElementType private constructor() : ILightStubFileElementType<PsiFileStub<M68kFile>>("MC68000_FILE", MC68000Language.INSTANCE) {
companion object {
@JvmField
val INSTANCE = M68kFileElementType()
const val STUB_VERSION = 1
const val STUB_VERSION = 4
const val STUB_EXTERNAL_ID_PREFIX = "MC68000."
const val EXTERNAL_ID = STUB_EXTERNAL_ID_PREFIX + "FILE"
}
override fun getStubVersion() = STUB_VERSION
override fun getBuilder() =
object : DefaultStubBuilder() {
override fun createStubForFile(file: PsiFile): StubElement<*> {
return if (file is M68kFile) M68kFileStub(file) else super.createStubForFile(file)
}
}
override fun getExternalId() = EXTERNAL_ID
}
@@ -7,5 +7,8 @@ object M68kIcons {
val FILE = IconLoader.getIcon("/icons/FileType_m68k.svg", javaClass)
val LOCAL_LABEL = AllIcons.Nodes.AbstractMethod
val GLOBAL_LABEL = AllIcons.Nodes.Method
val SYMBOL_DEF = AllIcons.Nodes.Constant
val SYMBOL_DEF = AllIcons.Nodes.ClassInitializer
val MACRO_DEF = AllIcons.Nodes.MultipleTypeDefinitions
val REGISTER = AllIcons.Nodes.DataTables // AllIcons.Nodes.Record only available starting from 2020.1
val MNEMONIC = AllIcons.Nodes.C_protected
}
@@ -29,6 +29,8 @@ object AssemblerDirectives {
//"iif" // not supported
"else", "endif", "endc",
"rept", "endr",
"macro", "exitm", "mexit", "endm",
"extern", "nref", "xdef", "xref", "globl", "public", "weak",
@@ -1,15 +1,24 @@
package de.platon42.intellij.plugins.m68k.asm
enum class Machine {
MC68000
MC68000,
MC68010,
MC68020,
MC68030,
MC68040,
MC68060
}
data class IsaData(
val mnemonic: String,
val description: String,
val machine: Machine = Machine.MC68000,
val machine: Set<Machine> = setOf(Machine.MC68000),
val altMnemonics: List<String> = emptyList(),
val conditionCodes: List<String> = emptyList()
val conditionCodes: List<String> = emptyList(),
val id: String = mnemonic,
val opSize: String = "bWl",
val isPrivileged: Boolean = false,
val hasOps: Boolean = true
)
object M68kIsa {
@@ -18,95 +27,129 @@ object M68kIsa {
val conditionCodesBcc = conditionCodes.filterNot { it == "f" || it == "t" }
val isaData = listOf(
IsaData("abcd", "Add Decimal with Extend"),
// Data Movement Instructions
IsaData("move", "Move"),
IsaData("movea", "Move Address", altMnemonics = listOf("move"), opSize = "L"),
IsaData("movem", "Move Multiple Registers", opSize = "Wl"),
IsaData("movep", "Move Peripheral", opSize = ""),
IsaData("moveq", "Move Quick", opSize = "L"),
IsaData("exg", "Exchange Registers", opSize = "L"),
IsaData("lea", "Load Effective Address", opSize = ""),
IsaData("pea", "Push Effective Address", opSize = ""),
IsaData("link", "Link and Allocate", opSize = ""),
IsaData("unlk", "Unlink", opSize = ""),
// Integer Arithmetic Instructions
IsaData("add", "Add"),
IsaData("adda", "Add Address", altMnemonics = listOf("add")),
IsaData("adda", "Add Address", altMnemonics = listOf("add"), opSize = "Wl"),
IsaData("addi", "Add Immediate", altMnemonics = listOf("add")),
IsaData("addq", "Add Quick"),
IsaData("addx", "Add with Extend"),
IsaData("and", "Logical AND"),
IsaData("andi", "Logical AND Immediate", altMnemonics = listOf("and")),
IsaData("andi", "to CCR AND Immediate to Condition Code Register", altMnemonics = listOf("and")),
IsaData("andi", "to SR AND Immediate to Status Register", altMnemonics = listOf("and")),
IsaData("asl", "Arithmetic Shift Left"),
IsaData("asr", "Arithmetic Shift Right"),
IsaData("bCC", "Branch Conditionally", conditionCodes = conditionCodesBcc),
IsaData("bchg", "Test Bit and Change"),
IsaData("bclr", "Test Bit and Clear"),
IsaData("bra", "Branch"),
IsaData("bset", "Test Bit and Set"),
IsaData("bsr", "Branch to Subroutine"),
IsaData("btst", "Test Bit"),
IsaData("chk", "Check Register Against Bound"),
IsaData("clr", "Clear"),
IsaData("cmp", "Compare"),
IsaData("cmpa", "Compare Address", altMnemonics = listOf("cmp")),
IsaData("cmpi", "Compare Immediate", altMnemonics = listOf("cmp")),
IsaData("cmpm", "Compare Memory to Memory", altMnemonics = listOf("cmp")),
IsaData(
"dbCC",
"Test Condition, Decrement, and Branch",
altMnemonics = listOf("dbra"),
conditionCodes = conditionCodes
),
IsaData("divs", "Signed Divide"),
IsaData("divu", "Unsigned Divide"),
IsaData("eor", "Logical Exclusive-OR"),
IsaData("eori", "Logical Exclusive-OR Immediate", altMnemonics = listOf("eor")),
IsaData("eori", "to CCR Exclusive-OR Immediate to Condition Code Register", altMnemonics = listOf("eor")),
IsaData("eori", "to SR Exclusive-OR Immediate to Status Register", altMnemonics = listOf("eor")),
IsaData("exg", "Exchange Registers"),
IsaData("ext", "Sign Extend"),
IsaData("illegal", "Take Illegal Instruction Trap"),
IsaData("jmp", "Jump"),
IsaData("jsr", "Jump to Subroutine"),
IsaData("lea", "Load Effective Address"),
IsaData("link", "Link and Allocate"),
IsaData("lsl", "Logical Shift Left"),
IsaData("lsr", "Logical Shift Right"),
IsaData("move", "Move"),
IsaData("movea", "Move Address", altMnemonics = listOf("move")),
IsaData("move", "to CCR Move to Condition Code Register"),
IsaData("move", "from SR Move from Status Register"),
IsaData("move", "to SR Move to Status Register"),
IsaData("move", "USP Move User Stack Pointer"),
IsaData("movem", "Move Multiple Registers"),
IsaData("movep", "Move Peripheral"),
IsaData("moveq", "Move Quick"),
IsaData("muls", "Signed Multiply"),
IsaData("mulu", "Unsigned Multiply"),
IsaData("nbcd", "Negate Decimal with Extend"),
IsaData("neg", "Negate"),
IsaData("negx", "Negate with Extend"),
IsaData("nop", "No Operation"),
IsaData("not", "Logical Complement"),
IsaData("or", "Logical Inclusive-OR"),
IsaData("ori", "Logical Inclusive-OR Immediate", altMnemonics = listOf("or")),
IsaData("ori", "to CCR Inclusive-OR Immediate to Condition Code Register", altMnemonics = listOf("or")),
IsaData("ori", "to SR Inclusive-OR Immediate to Status Register", altMnemonics = listOf("or")),
IsaData("pea", "Push Effective Address"),
IsaData("reset", "Reset External Devices"),
IsaData("rol", "Rotate Left"),
IsaData("ror", "Rotate Right"),
IsaData("roxl", "Rotate with Extend Left"),
IsaData("roxr", "Rotate with Extend Right"),
IsaData("rte", "Return from Exception"),
IsaData("rtr", "Return and Restore"),
IsaData("rts", "Return from Subroutine"),
IsaData("sbcd", "Subtract Decimal with Extend"),
IsaData("sCC", "Set Conditionally", conditionCodes = conditionCodes),
IsaData("stop", "Stop"),
IsaData("sub", "Subtract"),
IsaData("suba", "Subtract Address", altMnemonics = listOf("sub")),
IsaData("subi", "Subtract Immediate", altMnemonics = listOf("sub")),
IsaData("subq", "Subtract Quick"),
IsaData("subx", "Subtract with Extend"),
IsaData("swap", "Swap Register Words"),
IsaData("tas", "Test Operand and Set"),
IsaData("trap", "Trap"),
IsaData("trapv", "Trap on Overflow"),
IsaData("neg", "Negate"),
IsaData("negx", "Negate with Extend"),
IsaData("clr", "Clear"),
IsaData("cmp", "Compare"),
IsaData("cmpa", "Compare Address", altMnemonics = listOf("cmp"), opSize = "Wl"),
IsaData("cmpi", "Compare Immediate", altMnemonics = listOf("cmp")),
IsaData("cmpm", "Compare Memory to Memory", altMnemonics = listOf("cmp")),
IsaData("muls", "Signed Multiply", opSize = "W"),
IsaData("mulu", "Unsigned Multiply", opSize = "W"),
IsaData("divs", "Signed Divide", opSize = "W"),
IsaData("divu", "Unsigned Divide", opSize = "W"),
IsaData("ext", "Sign Extend", opSize = "Wl"),
// Logical Instructions
IsaData("and", "Logical AND"),
IsaData("andi", "Logical AND Immediate", altMnemonics = listOf("and")),
IsaData("eor", "Logical Exclusive-OR"),
IsaData("eori", "Logical Exclusive-OR Immediate", altMnemonics = listOf("eor")),
IsaData("not", "Logical Complement"),
IsaData("or", "Logical Inclusive-OR"),
IsaData("ori", "Logical Inclusive-OR Immediate", altMnemonics = listOf("or")),
// Shift and Rotate Instructions
IsaData("asl", "Arithmetic Shift Left"),
IsaData("asr", "Arithmetic Shift Right"),
IsaData("lsl", "Logical Shift Left"),
IsaData("lsr", "Logical Shift Right"),
IsaData("rol", "Rotate Left"),
IsaData("ror", "Rotate Right"),
IsaData("roxl", "Rotate with Extend Left"),
IsaData("roxr", "Rotate with Extend Right"),
IsaData("swap", "Swap Register Words", opSize = ""),
// Bit Manipulation Instructions
IsaData("bchg", "Test Bit and Change", opSize = "Bl"),
IsaData("bclr", "Test Bit and Clear", opSize = "Bl"),
IsaData("bset", "Test Bit and Set", opSize = "Bl"),
IsaData("btst", "Test Bit", opSize = "Bl"),
// Binary-Coded Decimal Instructions
IsaData("abcd", "Add Decimal with Extend", opSize = ""),
IsaData("sbcd", "Subtract Decimal with Extend", opSize = ""),
IsaData("nbcd", "Negate Decimal with Extend", opSize = ""),
// Program Control Instructions
IsaData("bCC", "Branch Conditionally", conditionCodes = conditionCodesBcc, opSize = "bsW"),
IsaData("bra", "Branch", opSize = "bsW"),
IsaData("bsr", "Branch to Subroutine", opSize = "bsW"),
IsaData(
"dbCC",
"Test Condition, Decrement, and Branch",
altMnemonics = listOf("dbra"),
conditionCodes = conditionCodes, opSize = "W"
),
IsaData("sCC", "Set Conditionally", conditionCodes = conditionCodes, opSize = ""),
IsaData("jmp", "Jump", opSize = ""),
IsaData("jsr", "Jump to Subroutine", opSize = ""),
IsaData("nop", "No Operation", opSize = "", hasOps = false),
IsaData("rtr", "Return and Restore", hasOps = false),
IsaData("rts", "Return from Subroutine", hasOps = false),
IsaData("tst", "Test Operand"),
IsaData("unlk", "Unlink"),
// System Control Instructions
IsaData("andi", "AND Immediate to Status Register", id = "andi to SR", altMnemonics = listOf("and"), isPrivileged = true),
IsaData("eori", "Exclusive-OR Immediate to Status Register", id = "eori to SR", altMnemonics = listOf("eor"), isPrivileged = true),
IsaData("ori", "Inclusive-OR Immediate to Status Register", id = "ori to SR", altMnemonics = listOf("or"), isPrivileged = true),
IsaData("move", "Move from Status Register", id = "move from SR"),
IsaData("move", "Move to Status Register", id = "move to SR", isPrivileged = true),
IsaData("move", "Move User Stack Pointer", id = "move USP", isPrivileged = true),
IsaData("reset", "Reset External Devices", opSize = "", isPrivileged = true, hasOps = false),
IsaData("rte", "Return from Exception", isPrivileged = true, hasOps = false),
IsaData("stop", "Stop", opSize = "", isPrivileged = true),
IsaData("chk", "Check Register Against Bound"),
IsaData("illegal", "Take Illegal Instruction Trap", opSize = "", hasOps = false),
IsaData("trap", "Trap", opSize = ""),
IsaData("trapv", "Trap on Overflow", opSize = ""),
IsaData("andi", "AND Immediate to Condition Code Register", id = "andi to CCR", altMnemonics = listOf("and")),
IsaData("eori", "Exclusive-OR Immediate to Condition Code Register", id = "eori to CCR", altMnemonics = listOf("eor")),
IsaData("ori", "Inclusive-OR Immediate to Condition Code Register", id = "ori to CCR", altMnemonics = listOf("or")),
IsaData("move", "Move to Condition Code Register", id = "move to CCR"),
// Multiprocessor Instructions
IsaData("tas", "Test Operand and Set", opSize = "B"),
)
val mnemonics =
@@ -4,13 +4,20 @@ 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.M68kIcons
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
class M68kMnemonicCompletionContributor : CompletionContributor() {
companion object {
val MNEMONICS = M68kIsa.mnemonics
.map { PrioritizedLookupElement.withPriority(LookupElementBuilder.create(it).withIcon(M68kIcons.MNEMONIC), 10.0) }
}
init {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(M68kTypes.MACRO_INVOKATION), object : CompletionProvider<CompletionParameters>() {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(M68kTypes.MACRO_INVOCATION), object : CompletionProvider<CompletionParameters>() {
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, resultSet: CompletionResultSet) {
resultSet.addAllElements(M68kIsa.mnemonics.map(LookupElementBuilder::create))
resultSet.addAllElements(MNEMONICS)
}
})
}
@@ -4,10 +4,12 @@ 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 {
private val ASSIGNMENT_SEPARATORS = charArrayOf(' ', '\t', '=', ':')
private val TOKEN_SEPARATORS = charArrayOf(' ', '\t')
@JvmStatic
fun isAsmMnemonic(text: CharSequence) = mnemonics.contains(text.toString().lowercase())
@@ -28,6 +30,11 @@ object LexerUtil {
return text.length - text.indexOfAny(ASSIGNMENT_SEPARATORS)
}
@JvmStatic
fun pushbackAfterFirstToken(text: CharSequence): Int {
return text.length - text.indexOfAny(TOKEN_SEPARATORS)
}
@JvmStatic
fun pushbackLabelColons(text: CharSequence): Int {
return text.count { it == ':' }
@@ -38,7 +45,28 @@ object LexerUtil {
if (!lexer.eatOneWhitespace && lexer.lexerPrefs.spaceIntroducesComment) {
lexer.yybegin(_M68kLexer.WAITEOL)
}
lexer.eatOneWhitespace = false;
lexer.eatOneWhitespace = false
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) {
lexer.yybegin(_M68kLexer.YYINITIAL)
return TokenType.BAD_CHARACTER
}
lexer.yybegin(_M68kLexer.MACROLINE)
return TokenType.WHITE_SPACE
}
}
@@ -13,6 +13,9 @@ import static de.platon42.intellij.plugins.m68k.lexer.LexerUtil.*;
%{
private M68kLexerPrefs lexerPrefs;
boolean eatOneWhitespace = false;
int macroLines = 0;
int exprState = 0;
int exprOpState = 0;
public M68kLexerPrefs getLexerPrefs()
{
@@ -23,6 +26,12 @@ import static de.platon42.intellij.plugins.m68k.lexer.LexerUtil.*;
this((java.io.Reader)null);
this.lexerPrefs = lexerPrefs;
}
private void startExpr(int newExprState, int newExprOpState) {
exprState = newExprState;
exprOpState = newExprOpState;
yybegin(exprState);
}
%}
%public
@@ -38,10 +47,12 @@ WHITE_SPACE=\p{Blank}+
AREG=(a[0-6])
DREG=(d[0-7])
ASSIGNMENT=(([:letter:]|_)(([:letter:]|[:digit:])|_)*:?((\p{Blank}+equ\p{Blank}+)|(\p{Blank}+set\p{Blank}+)|\p{Blank}*=\p{Blank}*))
LOCAL_LABEL=(\.([:letter:]|_)(([:letter:]|[:digit:])|_)*:?)|(([:letter:]|_)(([:letter:]|[:digit:])|_)*\$:?)
LOCAL_LABEL_WC=(\.([:letter:]|_)(([:letter:]|[:digit:])|_)*:)|(([:letter:]|_)(([:letter:]|[:digit:])|_)*\$:)
GLOBAL_LABEL=(([:letter:]|_)(([:letter:]|[:digit:])|_)*:?:?)
GLOBAL_LABEL_WC=(([:letter:]|_)(([:letter:]|[:digit:])|_)*::?)
LOCAL_LABEL=(\.([:letter:]|_)([:letter:]|[:digit:]|_)*:?)|(([:letter:]|_)([:letter:]|[:digit:]|_)*\$:?)
LOCAL_LABEL_WC=(\.([:letter:]|_)([:letter:]|[:digit:]|_)*:)|(([:letter:]|_)([:letter:]|[:digit:]|_)*\$:)
GLOBAL_LABEL=(([:letter:]|_)([:letter:]|[:digit:]|_)*:?:?)
GLOBAL_LABEL_WC=(([:letter:]|_)([:letter:]|[:digit:]|_)*::?)
MACRO_DEF_LEFT=(([:letter:]|_)(([:letter:]|[:digit:]|_))*)\p{Blank}+macro\p{Blank}*
MACRO_END_TAG=\p{Blank}+endm\p{Blank}*[^;\r\n]*
//MNEMONIC=(([:letter:])+)
SYMBOL=(([:letter:]|_|\.)(([:letter:]|[:digit:]|[_\$]))*)
BONUSSYMBOL=(([:letter:]|_|\.)(([:letter:]|[:digit:]|[_\$\.\\]))*)
@@ -59,227 +70,159 @@ PLAINPARAM=(`([^`\\\r\n]|\\.)*`|'([^'\\\r\n]|\\.)*'|\"([^\"\\\r\n]|\\.)*\")|<([^
COMMENT=([;].*+)
HASH_COMMENT=([#;*].*+)
SKIP_TO_EOL=[^\r\n]+
PLAIN_MACRO_LINE=[^;\r\n]+
%state NOSOL,INSTRPART,ASMINSTR,ASMOPS,ASMOPS_OP,ASSIGNMENT,EXPR,EXPR_OP,MACROCALL,WAITEOL
%state NOSOL,INSTRPART,ASMINSTR,ASMOPS,ASMOPS_OP,ASSIGNMENT,EXPR,EXPR_OP,MACROCALL,WAITEOL,MACRODEF,MACROLINE,MACROTERMINATION,MACROWAITEOL
%%
<YYINITIAL> {
{WHITE_SPACE} { yybegin(NOSOL); eatOneWhitespace = false; return WHITE_SPACE; }
{EOL} { return WHITE_SPACE; }
{ASSIGNMENT} { yybegin(ASSIGNMENT); eatOneWhitespace = true; yypushback(pushbackAssignment(yytext())); return SYMBOLDEF; }
{LOCAL_LABEL} { yybegin(INSTRPART); eatOneWhitespace = false; yypushback(pushbackLabelColons(yytext())); return LOCAL_LABEL_DEF; }
{GLOBAL_LABEL} { yybegin(INSTRPART); eatOneWhitespace = false; yypushback(pushbackLabelColons(yytext())); return GLOBAL_LABEL_DEF; }
{HASH_COMMENT} { return COMMENT; }
}
<NOSOL> {
{WHITE_SPACE} { return WHITE_SPACE; }
<YYINITIAL, NOSOL>
{
{EOL} { yybegin(YYINITIAL); return WHITE_SPACE; }
{LOCAL_LABEL_WC} { yybegin(INSTRPART); yypushback(pushbackLabelColons(yytext())); return LOCAL_LABEL_DEF; }
{GLOBAL_LABEL_WC} { yybegin(INSTRPART); yypushback(pushbackLabelColons(yytext())); return GLOBAL_LABEL_DEF; }
{DIRECTIVE_KEYWORD} {
if(isAsmMnemonicWithSize(yytext())) { yybegin(ASMINSTR); yypushback(2); return MNEMONIC; }
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;
}
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { yybegin(INSTRPART); return SYMBOL; } }
{MACRONAME} { yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION; }
{HASH_COMMENT} { yybegin(YYINITIAL); return COMMENT; }
}
<INSTRPART> {
{WHITE_SPACE} { return WHITE_SPACE; }
<INSTRPART,ASMINSTR,MACROCALL,ASSIGNMENT,EXPR,EXPR_OP,ASMOPS,ASMOPS_OP>
{
{EOL} { yybegin(YYINITIAL); return EOL; }
":" { return COLON; }
{DIRECTIVE_KEYWORD} {
if(isAsmMnemonicWithSize(yytext())) { yybegin(ASMINSTR); yypushback(2); return MNEMONIC; }
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;
}
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { return SYMBOL; } }
{MACRONAME} { yybegin(MACROCALL); eatOneWhitespace = true; return MACRO_INVOKATION; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
}
<NOSOL, INSTRPART, ASSIGNMENT>
{
{WHITE_SPACE} { return WHITE_SPACE; }
}
<MACROCALL, EXPR, EXPR_OP, ASMOPS, ASMOPS_OP> {
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
}
<YYINITIAL> {
{WHITE_SPACE} { yybegin(NOSOL); eatOneWhitespace = false; return WHITE_SPACE; }
{ASSIGNMENT} { yybegin(ASSIGNMENT); eatOneWhitespace = true; yypushback(pushbackAssignment(yytext())); return SYMBOLDEF; }
{MACRO_DEF_LEFT} { yybegin(MACRODEF); yypushback(pushbackAfterFirstToken(yytext())); return MACRO_NAME; }
{LOCAL_LABEL} { yybegin(INSTRPART); eatOneWhitespace = false; yypushback(pushbackLabelColons(yytext())); return LOCAL_LABEL_DEF; }
{GLOBAL_LABEL} { yybegin(INSTRPART); eatOneWhitespace = false; yypushback(pushbackLabelColons(yytext())); return GLOBAL_LABEL_DEF; }
}
<NOSOL> {
"macro" { yybegin(MACRODEF); return MACRO_TAG; }
{LOCAL_LABEL_WC} { yybegin(INSTRPART); yypushback(pushbackLabelColons(yytext())); return LOCAL_LABEL_DEF; }
{GLOBAL_LABEL_WC} { yybegin(INSTRPART); yypushback(pushbackLabelColons(yytext())); return GLOBAL_LABEL_DEF; }
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { yybegin(INSTRPART); return SYMBOL; } }
}
<NOSOL, INSTRPART>
{
{DIRECTIVE_KEYWORD} {
if(isAsmMnemonicWithSize(yytext())) { yybegin(ASMINSTR); yypushback(2); return MNEMONIC; }
if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; }
if(isDataDirective(yytext())) { startExpr(EXPR, EXPR_OP); return DATA_DIRECTIVE; }
if(isOtherDirective(yytext())) { startExpr(EXPR, EXPR_OP); return OTHER_DIRECTIVE; }
return handleMacroMode(this);
}
{MACRONAME} { return handleMacroMode(this); }
}
<INSTRPART> {
":" { return COLON; }
// {MNEMONIC} { if(isAsmMnemonic(yytext())) { yybegin(ASMINSTR); return MNEMONIC; } else { return SYMBOL; } }
}
<ASMINSTR> {
{WHITE_SPACE} { yybegin(ASMOPS); return WHITE_SPACE; }
{EOL} { yybegin(YYINITIAL); return EOL; }
{WHITE_SPACE} { startExpr(ASMOPS, ASMOPS_OP); return WHITE_SPACE; }
{OPSIZE_BS} { return OPSIZE_BS; }
{OPSIZE_W} { return OPSIZE_W; }
{OPSIZE_L} { return OPSIZE_L; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
}
<MACROCALL> {
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
{EOL} { yybegin(YYINITIAL); return EOL; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
"," { return SEPARATOR; }
{PLAINPARAM} { return STRINGLIT; }
}
<ASSIGNMENT> {
{WHITE_SPACE} { return WHITE_SPACE; }
{EOL} { yybegin(YYINITIAL); return EOL; }
"equ"|"set" { yybegin(EXPR); return EQU; }
"equ"|"set" { startExpr(EXPR, EXPR_OP); return EQU; }
":" { return COLON; }
"=" { yybegin(EXPR); return OP_ASSIGN; }
"=" { startExpr(EXPR, EXPR_OP); return OP_ASSIGN; }
}
<EXPR, ASMOPS> {
{BINARY} { yybegin(exprOpState); return BINARY; }
{HEXADECIMAL} { yybegin(exprOpState); return HEXADECIMAL; }
{OCTAL} { yybegin(exprOpState); return OCTAL; }
{DECIMAL} { yybegin(exprOpState); return DECIMAL; }
{STRINGLIT} { yybegin(exprOpState); return STRINGLIT; }
"^" { return OP_BITWISE_XOR; }
"," { return SEPARATOR; }
"(" { return ROUND_L; }
")" { yybegin(exprOpState); return ROUND_R; }
"!" { return OP_UNARY_NOT; }
"~" { return OP_UNARY_COMPL; }
"+" { return OP_PLUS; }
"-" { return OP_MINUS; }
"*" { yybegin(exprOpState); return CURRENT_PC_SYMBOL; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
}
<EXPR> {
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
{EOL} { yybegin(YYINITIAL); return EOL; }
{BINARY} { yybegin(EXPR_OP); return BINARY; }
{HEXADECIMAL} { yybegin(EXPR_OP); return HEXADECIMAL; }
{OCTAL} { yybegin(EXPR_OP); return OCTAL; }
{DECIMAL} { yybegin(EXPR_OP); return DECIMAL; }
{STRINGLIT} { yybegin(EXPR_OP); return STRINGLIT; }
"^" { return OP_BITWISE_XOR; }
"," { return SEPARATOR; }
"(" { return ROUND_L; }
")" { yybegin(EXPR_OP); return ROUND_R; }
"!" { return OP_UNARY_NOT; }
"~" { return OP_UNARY_COMPL; }
"+" { return OP_PLUS; }
"-" { return OP_MINUS; }
"*" { yybegin(EXPR_OP); return CURRENT_PC_SYMBOL; }
{BONUSSYMBOL} { yybegin(EXPR_OP); return SYMBOL; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
{BONUSSYMBOL} { yybegin(exprOpState); return SYMBOL; }
}
<EXPR_OP> {
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
{EOL} { yybegin(YYINITIAL); return EOL; }
<EXPR_OP, ASMOPS_OP> {
"<<" { yybegin(exprState); return OP_AR_SHIFT_L; }
">>" { yybegin(exprState); return OP_AR_SHIFT_R; }
"&&" { yybegin(exprState); return OP_LOGICAL_AND; }
"||" { yybegin(exprState); return OP_LOGICAL_OR; }
"=="|"=" { yybegin(exprState); return OP_CMP_EQ; }
"<>"|"!=" { yybegin(exprState); return OP_CMP_NOT_EQ; }
">=" { yybegin(exprState); return OP_CMP_GT_EQ; }
"<=" { yybegin(exprState); return OP_CMP_LT_EQ; }
"<" { yybegin(exprState); return OP_CMP_LT; }
">" { yybegin(exprState); return OP_CMP_GT; }
"&" { yybegin(exprState); return OP_BITWISE_AND; }
"|"|"!" { yybegin(exprState); return OP_BITWISE_OR; }
"^" { yybegin(exprState); return OP_BITWISE_XOR; }
"<<" { yybegin(EXPR); return OP_AR_SHIFT_L; }
">>" { yybegin(EXPR); return OP_AR_SHIFT_R; }
"&&" { yybegin(EXPR); return OP_LOGICAL_AND; }
"||" { yybegin(EXPR); return OP_LOGICAL_OR; }
"=="|"=" { yybegin(EXPR); return OP_CMP_EQ; }
"<>"|"!=" { yybegin(EXPR); return OP_CMP_NOT_EQ; }
">=" { yybegin(EXPR); return OP_CMP_GT_EQ; }
"<=" { yybegin(EXPR); return OP_CMP_LT_EQ; }
"<" { yybegin(EXPR); return OP_CMP_LT; }
">" { yybegin(EXPR); return OP_CMP_GT; }
"&" { yybegin(EXPR); return OP_BITWISE_AND; }
"|"|"!" { yybegin(EXPR); return OP_BITWISE_OR; }
"^" { yybegin(EXPR); return OP_BITWISE_XOR; }
// ":" { return COLON; }
// ";" { return SEMICOLON; }
// "[" { return SQUARE_L; }
// "]" { return SQUARE_R; }
"," { yybegin(EXPR); return SEPARATOR; }
"(" { yybegin(EXPR); return ROUND_L; }
"," { yybegin(exprState); return SEPARATOR; }
"(" { yybegin(exprState); return ROUND_L; }
")" { return ROUND_R; }
// "." { return DOT; }
// "$" { return DOLLAR; }
"~" { yybegin(EXPR); return OP_UNARY_COMPL; }
"+" { yybegin(EXPR); return OP_PLUS; }
"-" { yybegin(EXPR); return OP_MINUS; }
"*" { yybegin(EXPR); return OP_AR_MUL; }
"%"|"//" { yybegin(EXPR); return OP_AR_MOD; }
"/" { yybegin(EXPR); return OP_AR_DIV; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
"~" { yybegin(exprState); return OP_UNARY_COMPL; }
"+" { yybegin(exprState); return OP_PLUS; }
"-" { yybegin(exprState); return OP_MINUS; }
"*" { yybegin(exprState); return OP_AR_MUL; }
"%"|"//" { yybegin(exprState); return OP_AR_MOD; }
"/" { yybegin(exprState); return OP_AR_DIV; }
}
<ASMOPS> {
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
{EOL} { yybegin(YYINITIAL); return EOL; }
{BINARY} { yybegin(ASMOPS_OP); return BINARY; }
{HEXADECIMAL} { yybegin(ASMOPS_OP); return HEXADECIMAL; }
{OCTAL} { yybegin(ASMOPS_OP); return OCTAL; }
{DECIMAL} { yybegin(ASMOPS_OP); return DECIMAL; }
{STRINGLIT} { yybegin(ASMOPS_OP); return STRINGLIT; }
{AREG} { yybegin(ASMOPS_OP); return AREG; }
{DREG} { yybegin(ASMOPS_OP); return DREG; }
"sp"|"a7" { yybegin(ASMOPS_OP); return REG_SP; }
"pc" { yybegin(ASMOPS_OP); return PC; }
"ccr" { yybegin(ASMOPS_OP); return REG_CCR; }
"sr" { yybegin(ASMOPS_OP); return REG_SR; }
"usp" { yybegin(ASMOPS_OP); return REG_USP; }
"vbr" { yybegin(ASMOPS_OP); return REG_VBR; }
"^" { return OP_BITWISE_XOR; }
"," { return SEPARATOR; }
"(" { return ROUND_L; }
")" { yybegin(ASMOPS_OP); return ROUND_R; }
"!" { return OP_UNARY_NOT; }
"~" { return OP_UNARY_COMPL; }
"+" { return OP_PLUS; }
"-" { return OP_MINUS; }
"*" { yybegin(ASMOPS_OP); return CURRENT_PC_SYMBOL; }
{AREG} { yybegin(exprOpState); return AREG; }
{DREG} { yybegin(exprOpState); return DREG; }
"sp"|"a7" { yybegin(exprOpState); return REG_SP; }
"pc" { yybegin(exprOpState); return PC; }
"ccr" { yybegin(exprOpState); return REG_CCR; }
"sr" { yybegin(exprOpState); return REG_SR; }
"usp" { yybegin(exprOpState); return REG_USP; }
"vbr" { yybegin(exprOpState); return REG_VBR; }
"#" { return HASH; }
{SYMBOL} { yybegin(ASMOPS_OP); return SYMBOL; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
{SYMBOL} { yybegin(exprOpState); return SYMBOL; }
}
<ASMOPS_OP> {
{WHITE_SPACE} { return handleEolCommentWhitespace(this); }
{EOL} { yybegin(YYINITIAL); return EOL; }
{OPSIZE_BS} { return OPSIZE_BS; }
{OPSIZE_W} { return OPSIZE_W; }
{OPSIZE_L} { return OPSIZE_L; }
"<<" { yybegin(ASMOPS); return OP_AR_SHIFT_L; }
">>" { yybegin(ASMOPS); return OP_AR_SHIFT_R; }
"&&" { yybegin(ASMOPS); return OP_LOGICAL_AND; }
"||" { yybegin(ASMOPS); return OP_LOGICAL_OR; }
"=="|"=" { yybegin(ASMOPS); return OP_CMP_EQ; }
"<>"|"!=" { yybegin(ASMOPS); return OP_CMP_NOT_EQ; }
">=" { yybegin(ASMOPS); return OP_CMP_GT_EQ; }
"<=" { yybegin(ASMOPS); return OP_CMP_LT_EQ; }
"<" { yybegin(ASMOPS); return OP_CMP_LT; }
">" { yybegin(ASMOPS); return OP_CMP_GT; }
"&" { yybegin(ASMOPS); return OP_BITWISE_AND; }
"|"|"!" { yybegin(ASMOPS); return OP_BITWISE_OR; }
"^" { yybegin(ASMOPS); return OP_BITWISE_XOR; }
// ":" { return COLON; }
// ";" { return SEMICOLON; }
// "[" { return SQUARE_L; }
// "]" { return SQUARE_R; }
"," { yybegin(ASMOPS); return SEPARATOR; }
"(" { yybegin(ASMOPS); return ROUND_L; }
")" { return ROUND_R; }
// "." { return DOT; }
// "$" { return DOLLAR; }
"~" { yybegin(ASMOPS); return OP_UNARY_COMPL; }
"+" { yybegin(ASMOPS); return OP_PLUS; }
"-" { yybegin(ASMOPS); return OP_MINUS; }
"*" { yybegin(ASMOPS); return OP_AR_MUL; }
"%"|"//" { yybegin(ASMOPS); return OP_AR_MOD; }
"/" { yybegin(ASMOPS); return OP_AR_DIV; }
{SYMBOL} { return SYMBOL; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
}
<WAITEOL>
@@ -288,4 +231,35 @@ SKIP_TO_EOL=[^\r\n]+
{SKIP_TO_EOL} { return COMMENT; }
}
// The macro mess starts here
<MACRODEF> {
{WHITE_SPACE} { return WHITE_SPACE; }
{EOL} { yybegin(MACROLINE); macroLines = 0; return WHITE_SPACE; }
"macro" { return MACRO_TAG; }
{MACRONAME} { return MACRO_NAME; }
{COMMENT} { yybegin(MACROWAITEOL); return COMMENT; }
}
<MACROLINE> {
{EOL} { return handleMacroLineEol(this); }
{MACRO_END_TAG} { yybegin(MACROTERMINATION); return MACRO_END_TAG; }
{PLAIN_MACRO_LINE} { return MACRO_LINE; }
{COMMENT} { yybegin(MACROWAITEOL); return COMMENT; }
}
<MACROTERMINATION> {
{WHITE_SPACE} { return WHITE_SPACE; }
{EOL} { yybegin(YYINITIAL); return EOL; }
{COMMENT} { yybegin(WAITEOL); return COMMENT; }
}
<MACROWAITEOL>
{
{EOL} { return handleMacroLineEol(this); }
{SKIP_TO_EOL} { return COMMENT; }
}
[^] { return BAD_CHARACTER; }
@@ -2,6 +2,7 @@
parserClass="de.platon42.intellij.plugins.m68k.parser.M68kParser"
parserUtilClass="de.platon42.intellij.plugins.m68k.parser.M68kParserUtilBase"
implements = "de.platon42.intellij.plugins.m68k.psi.M68kPsiElement"
extends="com.intellij.extapi.psi.ASTWrapperPsiElement"
psiClassPrefix="M68k"
psiImplClassSuffix="Impl"
@@ -117,7 +118,7 @@
M68kFile ::= line*
private line ::= !<<eof>> statement EOL
private line ::= !<<eof>> (MacroDefinition | statement) (<<eof>>|EOL)
statement ::= (Assignment
| PreprocessorDirective
@@ -129,6 +130,8 @@ private statement_recover ::= !(EOL)
SymbolDefinition ::= SYMBOLDEF {
implements = "de.platon42.intellij.plugins.m68k.psi.M68kNamedElement"
mixin = "de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinitionMixin"
elementTypeFactory = "de.platon42.intellij.plugins.m68k.stubs.M68kStubElementTypeFactory.stubFactory"
stubClass = "de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStub"
methods = [getName setName getNameIdentifier]
}
@@ -142,7 +145,6 @@ private InstructionOnly ::= Instruction
LocalLabel ::= LOCAL_LABEL_DEF COLON? {
name = "local label"
extends = Label
implements = "de.platon42.intellij.plugins.m68k.psi.M68kNamedElement"
mixin = "de.platon42.intellij.plugins.m68k.psi.M68kLocalLabelMixin"
methods = [getName setName getNameIdentifier]
@@ -150,15 +152,14 @@ LocalLabel ::= LOCAL_LABEL_DEF COLON? {
GlobalLabel ::= GLOBAL_LABEL_DEF COLON* {
name = "global label"
extends = Label
implements = "de.platon42.intellij.plugins.m68k.psi.M68kNamedElement"
mixin = "de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabelMixin"
// elementTypeFactory = "de.platon42.intellij.plugins.m68k.stubs.M68kStubElementTypeFactory.stubFactory"
// stubClass = "de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStub"
elementTypeFactory = "de.platon42.intellij.plugins.m68k.stubs.M68kStubElementTypeFactory.stubFactory"
stubClass = "de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStub"
methods = [getName setName getNameIdentifier]
}
Label ::= LocalLabel | GlobalLabel
private Label ::= LocalLabel | GlobalLabel
OperandSize ::= (OPSIZE_BS|OPSIZE_W|OPSIZE_L) { name = ".s|.b|.w|.l" }
AddressSize ::= (OPSIZE_W|OPSIZE_L) { name = ".w|.l" }
@@ -169,7 +170,25 @@ AsmOp ::= MNEMONIC OperandSize?
PreprocessorDirective ::= Label? (DATA_DIRECTIVE | OTHER_DIRECTIVE)
PreprocessorOperands?
MacroCall ::= MACRO_INVOKATION PlainOperands?
MacroPlainLine ::= MACRO_LINE
MacroNameDefinition ::= MACRO_NAME
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]
}
AsmInstruction ::= AsmOp AsmOperands?
private Instruction ::= AsmInstruction | MacroCall
//external Instruction ::= parseMacroCallOrAsmInstruction
@@ -179,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 {
@@ -6,11 +6,11 @@ import com.intellij.lexer.Lexer
import com.intellij.openapi.project.Project
import com.intellij.psi.FileViewProvider
import com.intellij.psi.tree.TokenSet
import de.platon42.intellij.plugins.m68k.M68kFileElementType
import de.platon42.intellij.plugins.m68k.lexer.M68kLexer
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
import de.platon42.intellij.plugins.m68k.psi.M68kFile
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
import de.platon42.intellij.plugins.m68k.stubs.M68kElementTypes
class M68kParserDefinition : ParserDefinition {
@@ -23,7 +23,7 @@ class M68kParserDefinition : ParserDefinition {
override fun createParser(project: Project) = M68kParser()
override fun getFileNodeType() = M68kFileElementType.INSTANCE
override fun getFileNodeType() = M68kElementTypes.FILE
override fun getCommentTokens() = COMMENTS
@@ -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
}
@@ -1,19 +1,29 @@
package de.platon42.intellij.plugins.m68k.psi
import com.intellij.extapi.psi.ASTWrapperPsiElement
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.M68kGlobalLabelStub
import javax.swing.Icon
abstract class M68kGlobalLabelMixin(node: ASTNode) : ASTWrapperPsiElement(node), M68kGlobalLabel {
abstract class M68kGlobalLabelMixin : StubBasedPsiElementBase<M68kGlobalLabelStub>, M68kGlobalLabel {
constructor(node: ASTNode) : super(node)
constructor(stub: M68kGlobalLabelStub, nodeType: IStubElementType<*, *>) : super(stub, nodeType)
override fun getPresentation(): ItemPresentation? {
return PresentationData(name, containingFile?.name, getIcon(0), null)
return PresentationData(name, containingFile.name, getIcon(0), null)
}
override fun getIcon(flags: Int): Icon? {
return M68kIcons.GLOBAL_LABEL
}
override fun toString(): String {
return javaClass.simpleName + "(GLOBAL_LABEL)"
}
}
@@ -1,31 +1,47 @@
package de.platon42.intellij.plugins.m68k.psi
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiManager
import com.intellij.psi.search.FileTypeIndex
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import com.intellij.psi.util.PsiTreeUtil
import de.platon42.intellij.plugins.m68k.M68kFileType
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 {
fun findAllGlobalLabels(project: Project): List<M68kGlobalLabel> {
return getFiles(project)
.flatMap(::findAllGlobalLabels)
.toList()
val results: MutableList<M68kGlobalLabel> = ArrayList()
StubIndex.getInstance().processAllKeys(M68kGlobalLabelStubIndex.KEY, project)
{
results.addAll(StubIndex.getElements(M68kGlobalLabelStubIndex.KEY, it, project, GlobalSearchScope.allScope(project), M68kGlobalLabel::class.java))
true
}
return results
}
fun findAllGlobalLabels(file: M68kFile): List<M68kGlobalLabel> {
val results: MutableList<M68kGlobalLabel> = ArrayList()
var currentStatement = file.firstChild
while (currentStatement != null) {
val child = currentStatement.firstChild
if (child is M68kGlobalLabel) results.add(child)
currentStatement = PsiTreeUtil.getNextSiblingOfType(currentStatement, M68kStatement::class.java)
}
StubIndex.getInstance().processAllKeys(
M68kGlobalLabelStubIndex.KEY,
{
results.addAll(
StubIndex.getElements(
M68kGlobalLabelStubIndex.KEY,
it,
file.project,
GlobalSearchScope.fileScope(file),
M68kGlobalLabel::class.java
)
)
true
}, GlobalSearchScope.fileScope(file), null
)
return results
}
fun findAllGlobalLabelNames(project: Project): Collection<String> = StubIndex.getInstance().getAllKeys(M68kGlobalLabelStubIndex.KEY, project).toList()
fun findAllLocalLabels(globalLabel: M68kGlobalLabel): List<M68kLocalLabel> {
val statement = PsiTreeUtil.getStubOrPsiParentOfType(globalLabel, M68kStatement::class.java)!!
val results: MutableList<M68kLocalLabel> = ArrayList()
@@ -40,23 +56,85 @@ object M68kLookupUtil {
}
fun findAllSymbolDefinitions(project: Project): List<M68kSymbolDefinition> {
return getFiles(project)
.flatMap(::findAllSymbolDefinitions)
.toList()
}
fun findAllSymbolDefinitions(file: M68kFile): List<M68kSymbolDefinition> {
val results: MutableList<M68kSymbolDefinition> = ArrayList()
var currentStatement = file.firstChild
while (currentStatement != null) {
val child = currentStatement.firstChild
if (child is M68kAssignment) results.add(child.firstChild as M68kSymbolDefinition)
currentStatement = PsiTreeUtil.getNextSiblingOfType(currentStatement, M68kStatement::class.java)
StubIndex.getInstance().processAllKeys(M68kSymbolDefinitionStubIndex.KEY, project)
{
results.addAll(
StubIndex.getElements(
M68kSymbolDefinitionStubIndex.KEY,
it,
project,
GlobalSearchScope.allScope(project),
M68kSymbolDefinition::class.java
)
)
true
}
return results
}
private fun getFiles(project: Project) =
FileTypeIndex.getFiles(M68kFileType.INSTANCE, GlobalSearchScope.allScope(project)).asSequence()
.map { PsiManager.getInstance(project).findFile(it) as M68kFile }
fun findAllSymbolDefinitions(file: M68kFile): List<M68kSymbolDefinition> {
val results: MutableList<M68kSymbolDefinition> = ArrayList()
StubIndex.getInstance().processAllKeys(
M68kSymbolDefinitionStubIndex.KEY,
{
results.addAll(
StubIndex.getElements(
M68kSymbolDefinitionStubIndex.KEY,
it,
file.project,
GlobalSearchScope.fileScope(file),
M68kSymbolDefinition::class.java
)
)
true
}, GlobalSearchScope.fileScope(file), null
)
return results
}
fun findAllSymbolDefinitionNames(project: Project): Collection<String> = StubIndex.getInstance().getAllKeys(M68kSymbolDefinitionStubIndex.KEY, project)
fun findAllMacroDefinitions(project: Project): List<M68kMacroDefinition> {
val results: MutableList<M68kMacroDefinition> = 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<M68kMacroDefinition> {
val results: MutableList<M68kMacroDefinition> = 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<String> = StubIndex.getInstance().getAllKeys(M68kMacroDefinitionStubIndex.KEY, project)
}
@@ -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<PsiReference> {
return ReferenceProvidersRegistry.getReferencesFromProviders(this)
}
}
@@ -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<M68kMacroDefinitionStub>, 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)"
}
}
@@ -3,4 +3,4 @@ package de.platon42.intellij.plugins.m68k.psi
import com.intellij.psi.NavigatablePsiElement
import com.intellij.psi.PsiNameIdentifierOwner
interface M68kNamedElement : PsiNameIdentifierOwner, NavigatablePsiElement
interface M68kNamedElement : M68kPsiElement, PsiNameIdentifierOwner, NavigatablePsiElement
@@ -0,0 +1,5 @@
package de.platon42.intellij.plugins.m68k.psi
import com.intellij.psi.PsiElement
interface M68kPsiElement : PsiElement
@@ -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
}
@@ -13,12 +13,13 @@ class M68kRenameInputValidator : RenameInputValidator {
override fun getPattern(): ElementPattern<out PsiElement?> = 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
}
@@ -1,19 +1,29 @@
package de.platon42.intellij.plugins.m68k.psi
import com.intellij.extapi.psi.ASTWrapperPsiElement
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.M68kSymbolDefinitionStub
import javax.swing.Icon
abstract class M68kSymbolDefinitionMixin(node: ASTNode) : ASTWrapperPsiElement(node), M68kSymbolDefinition {
abstract class M68kSymbolDefinitionMixin : StubBasedPsiElementBase<M68kSymbolDefinitionStub>, M68kSymbolDefinition {
constructor(node: ASTNode) : super(node)
constructor(stub: M68kSymbolDefinitionStub, nodeType: IStubElementType<*, *>) : super(stub, nodeType)
override fun getPresentation(): ItemPresentation? {
return PresentationData(name, containingFile?.name, getIcon(0), null)
return PresentationData(name, containingFile.name, getIcon(0), null)
}
override fun getIcon(flags: Int): Icon? {
return M68kIcons.SYMBOL_DEF
}
override fun toString(): String {
return javaClass.simpleName + "(SYMBOL_DEFINITION)"
}
}
@@ -1,24 +1,38 @@
package de.platon42.intellij.plugins.m68k.refs
import com.intellij.navigation.ChooseByNameContributor
import com.intellij.navigation.ChooseByNameContributorEx
import com.intellij.navigation.NavigationItem
import com.intellij.openapi.project.Project
import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil.findAllGlobalLabels
import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil.findAllSymbolDefinitions
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.stubs.StubIndex
import com.intellij.util.Processor
import com.intellij.util.indexing.FindSymbolParameters
import com.intellij.util.indexing.IdFilter
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition
import de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStubIndex
import de.platon42.intellij.plugins.m68k.stubs.M68kSymbolDefinitionStubIndex
class M68kChooseByNameContributor : ChooseByNameContributor {
override fun getNames(project: Project, includeNonProjectItems: Boolean): Array<String> {
return listOf(findAllGlobalLabels(project), findAllSymbolDefinitions(project))
.asSequence()
.flatten()
.mapNotNull { it.name }
.toList()
.toTypedArray()
class M68kChooseByNameContributor : ChooseByNameContributorEx {
// override fun processNames(processor: Processor<in String>, parameters: FindSymbolParameters) {
// processNames(processor, parameters.searchScope, parameters.idFilter)
// }
// override fun getItemsByName(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean): Array<NavigationItem> {
// val result: MutableList<NavigationItem> = ArrayList()
// processElementsWithName(name, result::add, FindSymbolParameters.wrap(pattern, project, includeNonProjectItems))
// return result.toTypedArray()
// }
override fun processNames(processor: Processor<in String>, scope: GlobalSearchScope, filter: IdFilter?) {
StubIndex.getInstance().processAllKeys(M68kGlobalLabelStubIndex.KEY, processor, scope, filter)
StubIndex.getInstance().processAllKeys(M68kSymbolDefinitionStubIndex.KEY, processor, scope, filter)
}
override fun getItemsByName(name: String, pattern: String, project: Project, includeNonProjectItems: Boolean): Array<NavigationItem> {
return listOf(findAllGlobalLabels(project), findAllSymbolDefinitions(project))
.flatten()
.toTypedArray()
override fun processElementsWithName(name: String, processor: Processor<in NavigationItem>, parameters: FindSymbolParameters) {
StubIndex.getInstance()
.processElements(M68kGlobalLabelStubIndex.KEY, name, parameters.project, parameters.searchScope, M68kGlobalLabel::class.java, processor)
StubIndex.getInstance()
.processElements(M68kSymbolDefinitionStubIndex.KEY, name, parameters.project, parameters.searchScope, M68kSymbolDefinition::class.java, processor)
}
}
@@ -0,0 +1,33 @@
package de.platon42.intellij.plugins.m68k.refs
import com.intellij.codeInsight.completion.*
import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.patterns.PlatformPatterns
import com.intellij.util.ProcessingContext
import de.platon42.intellij.plugins.m68k.M68kIcons
import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
class M68kGlobalLabelSymbolCompletionContributor : CompletionContributor() {
companion object {
val REGISTER_SUGGESTIONS: List<LookupElement> =
listOf(
"d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
"a0", "a1", "a2", "a3", "a4", "a5", "a6", "sp",
"pc"
)
.map { PrioritizedLookupElement.withPriority(LookupElementBuilder.create(it).withIcon(M68kIcons.REGISTER).withBoldness(true), 2.0) }
}
init {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(M68kTypes.SYMBOL), object : CompletionProvider<CompletionParameters>() {
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, resultSet: CompletionResultSet) {
resultSet.addAllElements(REGISTER_SUGGESTIONS)
resultSet.addAllElements(M68kLookupUtil.findAllGlobalLabels(parameters.originalFile.project).map(LookupElementBuilder::createWithIcon))
resultSet.addAllElements(M68kLookupUtil.findAllSymbolDefinitions(parameters.originalFile.project).map(LookupElementBuilder::createWithIcon))
}
})
}
}
@@ -1,6 +1,5 @@
package de.platon42.intellij.plugins.m68k.refs
import com.intellij.codeInsight.lookup.LookupElementBuilder
import com.intellij.openapi.util.TextRange
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementResolveResult
@@ -8,59 +7,53 @@ 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.M68kGlobalLabel
import de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil
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<M68kSymbolReference>(element, TextRange(0, element.textLength)) {
companion object {
val INSTANCE = Resolver()
fun findGlobalLabels(element: M68kSymbolReference, predicate: (M68kGlobalLabel) -> Boolean): List<M68kGlobalLabel> {
return M68kLookupUtil.findAllGlobalLabels(element.project).filter(predicate)
}
fun findSymbolDefinitions(element: M68kSymbolReference, predicate: (M68kSymbolDefinition) -> Boolean): List<M68kSymbolDefinition> {
return M68kLookupUtil.findAllSymbolDefinitions(element.project).filter(predicate)
}
private fun getCurrentFileSearchScope(element: PsiElement): GlobalSearchScope {
return GlobalSearchScope.fileScope(element.containingFile.originalFile)
}
}
class Resolver : ResolveCache.PolyVariantResolver<M68kGlobalLabelSymbolReference> {
override fun resolve(ref: M68kGlobalLabelSymbolReference, incompleteCode: Boolean): Array<ResolveResult> {
val refName = ref.element.symbolName
val project = ref.element.project
val globalLabelMatches: Array<ResolveResult> = findGlobalLabels(ref.myElement) { it.name == refName }
.map { PsiElementResolveResult(it) }
.toTypedArray()
if (globalLabelMatches.isNotEmpty()) return globalLabelMatches
return findSymbolDefinitions(ref.myElement) { it.name == refName }
.map { PsiElementResolveResult(it) }
val targets: MutableList<M68kNamedElement> = SmartList()
StubIndex.getInstance()
.processElements(M68kGlobalLabelStubIndex.KEY, refName, project, GlobalSearchScope.allScope(project), M68kGlobalLabel::class.java)
{
targets.add(it)
true
}
StubIndex.getInstance()
.processElements(M68kSymbolDefinitionStubIndex.KEY, refName, project, GlobalSearchScope.allScope(project), M68kSymbolDefinition::class.java)
{
targets.add(it)
true
}
return targets
.map(::PsiElementResolveResult)
.toTypedArray()
}
}
override fun multiResolve(incompleteCode: Boolean): Array<ResolveResult> {
return ResolveCache.getInstance(element.project)
override fun multiResolve(incompleteCode: Boolean): Array<ResolveResult> =
ResolveCache.getInstance(element.project)
.resolveWithCaching(this, INSTANCE, false, incompleteCode)
}
override fun resolve(): PsiElement? {
val resolveResults = multiResolve(false)
return resolveResults.singleOrNull()?.element
}
override fun resolve(): PsiElement? = multiResolve(false).singleOrNull()?.element
override fun getVariants(): Array<Any> {
return listOf(findGlobalLabels(element) { true }, findSymbolDefinitions(element) { true }).asSequence()
.flatten()
.map { LookupElementBuilder.createWithIcon(it) }
.toList()
.toTypedArray()
}
override fun getVariants(): Array<Any> = emptyArray()
}
@@ -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<CompletionParameters>() {
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, resultSet: CompletionResultSet) {
resultSet.addAllElements(M68kLookupUtil.findAllMacroDefinitions(parameters.originalFile.project).map(LookupElementBuilder::createWithIcon))
}
})
}
}
@@ -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<M68kMacroCall>() {
@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
}
}
@@ -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<M68kMacroCall>(element, TextRange(0, element.macroName.length)) {
companion object {
val INSTANCE = Resolver()
}
class Resolver : ResolveCache.PolyVariantResolver<M68kMacroReference> {
override fun resolve(ref: M68kMacroReference, incompleteCode: Boolean): Array<ResolveResult> {
val macroName = ref.element.macroName
val project = ref.element.project
val targets: MutableList<M68kMacroDefinition> = 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<ResolveResult> =
ResolveCache.getInstance(element.project)
.resolveWithCaching(this, INSTANCE, false, incompleteCode)
override fun resolve(): PsiElement? = multiResolve(false).singleOrNull()?.element
override fun getVariants(): Array<Any> = emptyArray()
}
@@ -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<PsiReference> =
arrayOf(M68kMacroReference(element as M68kMacroCall))
}
}
@@ -1,55 +0,0 @@
package de.platon42.intellij.plugins.m68k.refs
import com.intellij.codeInsight.lookup.LookupElementBuilder
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 de.platon42.intellij.plugins.m68k.psi.M68kLookupUtil
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolReference
class M68kSymbolDefinitionReference(element: M68kSymbolReference) :
PsiPolyVariantReferenceBase<M68kSymbolReference>(element, TextRange(0, element.textLength)) {
companion object {
val INSTANCE = Resolver()
fun findSymbolDefinitions(element: M68kSymbolReference, predicate: (M68kSymbolDefinition) -> Boolean): List<M68kSymbolDefinition> {
return M68kLookupUtil.findAllSymbolDefinitions(element.project).filter(predicate)
}
private fun getCurrentFileSearchScope(element: PsiElement): GlobalSearchScope {
return GlobalSearchScope.fileScope(element.containingFile.originalFile)
}
}
class Resolver : ResolveCache.PolyVariantResolver<M68kSymbolDefinitionReference> {
override fun resolve(ref: M68kSymbolDefinitionReference, incompleteCode: Boolean): Array<ResolveResult> {
val refName = ref.element.symbolName
return findSymbolDefinitions(ref.myElement) { it.name == refName }
.map { PsiElementResolveResult(it) }
.toTypedArray()
}
}
override fun multiResolve(incompleteCode: Boolean): Array<ResolveResult> {
return ResolveCache.getInstance(element.project)
.resolveWithCaching(this, INSTANCE, false, incompleteCode)
}
override fun resolve(): PsiElement? {
val resolveResults = multiResolve(false)
return resolveResults.singleOrNull()?.element
}
override fun getVariants(): Array<Any> {
return findSymbolDefinitions(element) { true }
.map { LookupElementBuilder.createWithIcon(it) }
.toTypedArray()
}
}
@@ -4,7 +4,6 @@ import com.intellij.lang.cacheBuilder.DefaultWordsScanner
import com.intellij.lang.cacheBuilder.WordsScanner
import com.intellij.lang.findUsages.FindUsagesProvider
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiNamedElement
import com.intellij.psi.tree.TokenSet
import de.platon42.intellij.plugins.m68k.lexer.M68kLexer
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
@@ -14,23 +13,18 @@ import org.jetbrains.annotations.NonNls
class M68kFindUsagesProvider : FindUsagesProvider {
override fun getWordsScanner(): WordsScanner {
return DefaultWordsScanner(
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),
TokenSet.create(M68kTypes.STRINGLIT, M68kTypes.DECIMAL, M68kTypes.HEXADECIMAL, M68kTypes.OCTAL, M68kTypes.BINARY),
TokenSet.EMPTY
)
}
override fun canFindUsagesFor(psiElement: PsiElement): Boolean {
return psiElement is PsiNamedElement
}
override fun canFindUsagesFor(psiElement: PsiElement): Boolean = psiElement is M68kNamedElement
override fun getHelpId(psiElement: PsiElement): @NonNls String? {
return null
}
override fun getHelpId(psiElement: PsiElement): @NonNls String? = null
override fun getType(element: PsiElement): @Nls String {
return when (element) {
@@ -38,6 +32,10 @@ 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 -> ""
}
}
@@ -48,11 +46,13 @@ 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 -> ""
}
}
override fun getNodeText(element: PsiElement, useFullName: Boolean): @Nls String {
return getDescriptiveName(element)
}
override fun getNodeText(element: PsiElement, useFullName: Boolean): @Nls String = getDescriptiveName(element)
}
@@ -18,8 +18,11 @@ class M68kStructureViewElement(private val myElement: NavigatablePsiElement) : S
return when (myElement) {
is M68kFile -> {
listOf(
M68kLookupUtil.findAllSymbolDefinitions(myElement),
M68kLookupUtil.findAllGlobalLabels(myElement)
M68kLookupUtil.findAllSymbolDefinitions(myElement).sortedBy { it.textRange.startOffset },
M68kLookupUtil.findAllMacroDefinitions(myElement).sortedBy { it.textRange.startOffset },
M68kLookupUtil.findAllGlobalLabels(myElement).sortedBy { it.textRange.startOffset },
// M68kLookupUtil.findAllSymbolDefinitions(myElement).sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name!! }),
// M68kLookupUtil.findAllGlobalLabels(myElement).sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.name!! })
)
.flatten()
.map(::M68kStructureViewElement)
@@ -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<Sorter> {
@@ -0,0 +1,97 @@
package de.platon42.intellij.plugins.m68k.stubs
import com.intellij.lang.LighterAST
import com.intellij.lang.LighterASTNode
import com.intellij.psi.PsiElement
import com.intellij.psi.impl.source.tree.LightTreeUtil
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
interface M68kElementTypes {
companion object {
@JvmField
val FILE = ILightStubFileElementType<M68kFileStub>(INSTANCE)
@JvmField
val GLOBAL_LABEL: IStubElementType<M68kGlobalLabelStub, M68kGlobalLabel> =
object : M68kStubElementType<M68kGlobalLabelStub, M68kGlobalLabel>("GLOBAL_LABEL") {
override fun createPsi(stub: M68kGlobalLabelStub): M68kGlobalLabel = M68kGlobalLabelImpl(stub, this)
override fun createStub(psi: M68kGlobalLabel, parentStub: StubElement<out PsiElement>): M68kGlobalLabelStub =
M68kGlobalLabelStubImpl(parentStub, this, psi.name!!)
override fun createStub(tree: LighterAST, node: LighterASTNode, parentStub: StubElement<*>): M68kGlobalLabelStub {
val idNode = LightTreeUtil.requiredChildOfType(tree, node, M68kTypes.GLOBAL_LABEL_DEF)
return M68kGlobalLabelStubImpl(parentStub, this, LightTreeUtil.toFilteredString(tree, idNode, null))
}
@Throws(IOException::class)
override fun serialize(stub: M68kGlobalLabelStub, dataStream: StubOutputStream) = dataStream.writeName(stub.name)
@Throws(IOException::class)
override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>): M68kGlobalLabelStub =
M68kGlobalLabelStubImpl(parentStub, this, dataStream.readName()!!)
override fun indexStub(stub: M68kGlobalLabelStub, sink: IndexSink) = sink.occurrence(M68kGlobalLabelStubIndex.KEY, stub.name!!)
}
@JvmField
val SYMBOL_DEFINITION: IStubElementType<M68kSymbolDefinitionStub, M68kSymbolDefinition> =
object : M68kStubElementType<M68kSymbolDefinitionStub, M68kSymbolDefinition>("SYMBOL_DEFINITION") {
override fun createPsi(stub: M68kSymbolDefinitionStub): M68kSymbolDefinition = M68kSymbolDefinitionImpl(stub, this)
override fun createStub(psi: M68kSymbolDefinition, parentStub: StubElement<out PsiElement>): M68kSymbolDefinitionStub =
M68kSymbolDefinitionStubImpl(parentStub, this, psi.name!!)
override fun createStub(tree: LighterAST, node: LighterASTNode, parentStub: StubElement<*>): M68kSymbolDefinitionStub {
val idNode = LightTreeUtil.requiredChildOfType(tree, node, M68kTypes.SYMBOLDEF)
return M68kSymbolDefinitionStubImpl(parentStub, this, LightTreeUtil.toFilteredString(tree, idNode, null))
}
@Throws(IOException::class)
override fun serialize(stub: M68kSymbolDefinitionStub, dataStream: StubOutputStream) = dataStream.writeName(stub.name)
@Throws(IOException::class)
override fun deserialize(dataStream: StubInputStream, parentStub: StubElement<*>): M68kSymbolDefinitionStub =
M68kSymbolDefinitionStubImpl(parentStub, this, dataStream.readName()!!)
override fun indexStub(stub: M68kSymbolDefinitionStub, sink: IndexSink) = sink.occurrence(M68kSymbolDefinitionStubIndex.KEY, stub.name!!)
}
@JvmField
val MACRO_DEFINITION: IStubElementType<M68kMacroDefinitionStub, M68kMacroDefinition> =
object : M68kStubElementType<M68kMacroDefinitionStub, M68kMacroDefinition>("MACRO_DEFINITION") {
override fun createPsi(stub: M68kMacroDefinitionStub): M68kMacroDefinition = M68kMacroDefinitionImpl(stub, this)
override fun createStub(psi: M68kMacroDefinition, parentStub: StubElement<out PsiElement>): 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!!)
}
}
}
@@ -3,4 +3,4 @@ package de.platon42.intellij.plugins.m68k.stubs
import com.intellij.psi.stubs.PsiFileStubImpl
import de.platon42.intellij.plugins.m68k.psi.M68kFile
class M68kFileStub(file: M68kFile?) : PsiFileStubImpl<M68kFile?>(file)
class M68kFileStub(file: M68kFile) : PsiFileStubImpl<M68kFile>(file)
@@ -0,0 +1,6 @@
package de.platon42.intellij.plugins.m68k.stubs
import com.intellij.psi.stubs.NamedStub
import de.platon42.intellij.plugins.m68k.psi.M68kGlobalLabel
interface M68kGlobalLabelStub : NamedStub<M68kGlobalLabel>
@@ -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.M68kGlobalLabel
class M68kGlobalLabelStubIndex : StringStubIndexExtension<M68kGlobalLabel>() {
override fun getKey(): StubIndexKey<String, M68kGlobalLabel> = KEY
override fun getVersion(): Int = M68kFileElementType.STUB_VERSION
companion object {
val KEY = StubIndexKey.createIndexKey<String, M68kGlobalLabel>("mc68000.globallabel.index")
}
}
@@ -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<M68kMacroDefinition>
@@ -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<M68kMacroDefinition>() {
override fun getKey(): StubIndexKey<String, M68kMacroDefinition> = KEY
override fun getVersion(): Int = M68kFileElementType.STUB_VERSION
companion object {
val KEY = StubIndexKey.createIndexKey<String, M68kMacroDefinition>("mc68000.macrodef.index")
}
}
@@ -0,0 +1,13 @@
package de.platon42.intellij.plugins.m68k.stubs
import com.intellij.psi.stubs.ILightStubElementType
import com.intellij.psi.stubs.StubElement
import de.platon42.intellij.plugins.m68k.M68kFileElementType
import de.platon42.intellij.plugins.m68k.MC68000Language.Companion.INSTANCE
import de.platon42.intellij.plugins.m68k.psi.M68kPsiElement
abstract class M68kStubElementType<STUB : StubElement<out M68kPsiElement>, PSI_TYPE : M68kPsiElement>(debugName: String) :
ILightStubElementType<STUB, PSI_TYPE>(debugName, INSTANCE) {
override fun getExternalId(): String = M68kFileElementType.STUB_EXTERNAL_ID_PREFIX + this
}
@@ -0,0 +1,17 @@
package de.platon42.intellij.plugins.m68k.stubs
import com.intellij.psi.stubs.IStubElementType
import com.intellij.psi.stubs.StubElement
import de.platon42.intellij.plugins.m68k.psi.M68kPsiElement
object M68kStubElementTypeFactory {
@JvmStatic
fun stubFactory(name: String): IStubElementType<out StubElement<out M68kPsiElement>, out M68kPsiElement> {
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'")
}
}
}
@@ -0,0 +1,6 @@
package de.platon42.intellij.plugins.m68k.stubs
import com.intellij.psi.stubs.NamedStub
import de.platon42.intellij.plugins.m68k.psi.M68kSymbolDefinition
interface M68kSymbolDefinitionStub : NamedStub<M68kSymbolDefinition>
@@ -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.M68kSymbolDefinition
class M68kSymbolDefinitionStubIndex : StringStubIndexExtension<M68kSymbolDefinition>() {
override fun getKey(): StubIndexKey<String, M68kSymbolDefinition> = KEY
override fun getVersion(): Int = M68kFileElementType.STUB_VERSION
companion object {
val KEY = StubIndexKey.createIndexKey<String, M68kSymbolDefinition>("mc68000.symboldef.index")
}
}
@@ -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.M68kGlobalLabel
import de.platon42.intellij.plugins.m68k.stubs.M68kGlobalLabelStub
class M68kGlobalLabelStubImpl : NamedStubBase<M68kGlobalLabel>, M68kGlobalLabelStub {
constructor(parent: StubElement<*>, elementType: IStubElementType<*, *>, name: StringRef) : super(parent, elementType, name)
constructor(parent: StubElement<*>, elementType: IStubElementType<*, *>, name: String) : super(parent, elementType, name)
}

Some files were not shown because too many files have changed in this diff Show More