Compare commits
6
Commits
v0.9
...
130f6a106d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
130f6a106d | ||
|
|
def6fe306f | ||
|
|
cd0bcd22ff | ||
|
|
f87bc7fea9 | ||
|
|
64b7042208 | ||
|
|
b785b716bb |
@@ -1,4 +1,4 @@
|
|||||||
# MC68000 Assembly Language Plugin [](https://app.travis-ci.com/chrisly42/mc68000-asm-plugin)
|
# MC68000 Assembly Language Plugin [](https://app.travis-ci.com/chrisly42/mc68000-asm-plugin) [](https://coveralls.io/github/chrisly42/mc68000-asm-plugin?branch=main)
|
||||||
|
|
||||||
_MC68000 Assembly Language Plugin_ is plugin for Jetbrains IDEs (CLion, IntelliJ, etc.).
|
_MC68000 Assembly Language Plugin_ is plugin for Jetbrains IDEs (CLion, IntelliJ, etc.).
|
||||||
|
|
||||||
|
|||||||
+14
-12
@@ -1,13 +1,13 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.jetbrains.intellij' version '1.8.0'
|
id 'org.jetbrains.intellij' version '1.9.0'
|
||||||
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
|
id 'org.jetbrains.kotlin.jvm' version '1.7.20'
|
||||||
id 'jacoco'
|
id 'jacoco'
|
||||||
id 'com.github.kt3k.coveralls' version '2.12.0'
|
id 'com.github.kt3k.coveralls' version '2.12.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'de.platon42'
|
group = 'de.platon42'
|
||||||
version = '0.9'
|
version = '0.10'
|
||||||
sourceCompatibility = "1.8"
|
sourceCompatibility = "1.8"
|
||||||
targetCompatibility = "1.8"
|
targetCompatibility = "1.8"
|
||||||
|
|
||||||
@@ -43,30 +43,32 @@ compileTestKotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
intellij {
|
intellij {
|
||||||
setVersion("2022.2") // LATEST-EAP-SNAPSHOT
|
setVersion("2022.2.3") // LATEST-EAP-SNAPSHOT
|
||||||
setUpdateSinceUntilBuild(false)
|
setUpdateSinceUntilBuild(false)
|
||||||
// setPlugins(["com.intellij.java"])
|
// setPlugins(["com.intellij.java"])
|
||||||
}
|
}
|
||||||
|
|
||||||
runPluginVerifier {
|
runPluginVerifier {
|
||||||
ideVersions = ["IC-203.6682.168", "IC-222.3345.118", // 2020.3 - 2022.2
|
ideVersions = ["IC-203.6682.168", "IC-222.4345.14", // 2020.3 - 2022.2.3
|
||||||
"CL-203.8084.11", // 2020.3
|
"CL-203.8084.11", // 2020.3
|
||||||
"CL-211.7628.27", // 2021.1
|
"CL-211.7628.27", // 2021.1
|
||||||
"CL-212.5712.21", // 2021.2
|
"CL-212.5712.21", // 2021.2
|
||||||
"CL-213.7172.20", // 2021.3.4
|
"CL-213.7172.20", // 2021.3.4
|
||||||
"CL-221.5080.224", // 2022.1
|
"CL-221.5921.22", // 2022.1.3
|
||||||
"CL-222.3345.126"] // 2022.2
|
"CL-222.4345.21"] // 2022.2.4
|
||||||
downloadDir = System.getProperty("user.home") + "/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/verifier"
|
downloadDir = System.getProperty("user.home") + "/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/verifier"
|
||||||
}
|
}
|
||||||
|
|
||||||
patchPluginXml {
|
patchPluginXml {
|
||||||
setChangeNotes("""
|
setChangeNotes("""
|
||||||
<h4>V0.9 (16-Aug-22)</h4>
|
<h4>V0.10 (undefined)</h4>
|
||||||
<ul>
|
<ul>
|
||||||
<li>Maintenance. Updated all dependencies to the latest versions.
|
<li>New: Added semantic highlighting. Currently available for data and address registers and local labels.
|
||||||
<li>Bugfix: Fixed condition code for asr/lsr/lsl, which is has a different behaviour for V flag than asl.
|
<li>Bugfix: addq/subq for address register stated it would affect the condition codes, which it in fact doesn't.
|
||||||
<li>Bugfix: Fixed 'Unknown op size' exception when uppercase sizes were used.
|
<li>New: Added simple custom navigation bar.
|
||||||
<li>Bugfix: Refactoring was broken for newer IDE versions, at least for me, this now works again by unknown magic.
|
<li>New: Added folding support for functions and macro definitions.
|
||||||
|
<li>New: Added assembler directives to code completion (only lower-case except for other directives like IF
|
||||||
|
and MACRO, which are only suggested for upper-case).
|
||||||
</ul>
|
</ul>
|
||||||
<p>Full changelog available at <a href="https://github.com/chrisly42/mc68000-asm-plugin#changelog">Github project site</a>.</p>
|
<p>Full changelog available at <a href="https://github.com/chrisly42/mc68000-asm-plugin#changelog">Github project site</a>.</p>
|
||||||
""")
|
""")
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.asm
|
||||||
|
|
||||||
|
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 M68kDirectiveCompletionContributor : CompletionContributor() {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val DIRECTIVES =
|
||||||
|
listOf(AssemblerDirectives.dataDirectives, AssemblerDirectives.plainDirectives, AssemblerDirectives.otherDirectives.map(String::uppercase))
|
||||||
|
.flatten()
|
||||||
|
.toSortedSet()
|
||||||
|
.map { PrioritizedLookupElement.withPriority(LookupElementBuilder.create(it).withIcon(M68kIcons.MNEMONIC), 1.5) }
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
extend(CompletionType.BASIC, PlatformPatterns.psiElement(M68kTypes.MACRO_INVOCATION), object : CompletionProvider<CompletionParameters>() {
|
||||||
|
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, resultSet: CompletionResultSet) {
|
||||||
|
resultSet.addAllElements(DIRECTIVES)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -294,7 +294,7 @@ object M68kIsa {
|
|||||||
AllowedAdrMode(
|
AllowedAdrMode(
|
||||||
setOf(AddressMode.IMMEDIATE_DATA), ALL_EXCEPT_AREG_IMMEDIATE_AND_PC_REL, modInfo = RWM_MODIFY_OP2_OPSIZE, affectedCc = cc("C****")
|
setOf(AddressMode.IMMEDIATE_DATA), ALL_EXCEPT_AREG_IMMEDIATE_AND_PC_REL, modInfo = RWM_MODIFY_OP2_OPSIZE, affectedCc = cc("C****")
|
||||||
),
|
),
|
||||||
AllowedAdrMode(setOf(AddressMode.IMMEDIATE_DATA), AREG_ONLY, size = OP_SIZE_WL, modInfo = RWM_MODIFY_OP2_L, affectedCc = cc("C****"))
|
AllowedAdrMode(setOf(AddressMode.IMMEDIATE_DATA), AREG_ONLY, size = OP_SIZE_WL, modInfo = RWM_MODIFY_OP2_L)
|
||||||
)
|
)
|
||||||
|
|
||||||
private val ADDX_SUBX_MODES = listOf(
|
private val ADDX_SUBX_MODES = listOf(
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.folding
|
||||||
|
|
||||||
|
import com.intellij.lang.ASTNode
|
||||||
|
import com.intellij.lang.folding.FoldingBuilderEx
|
||||||
|
import com.intellij.lang.folding.FoldingDescriptor
|
||||||
|
import com.intellij.openapi.editor.Document
|
||||||
|
import com.intellij.openapi.project.DumbAware
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
|
import com.intellij.refactoring.suggested.endOffset
|
||||||
|
import com.intellij.refactoring.suggested.startOffset
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kFile
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.utils.M68kPsiWalkUtil.getBeginningOfRelatedComment
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.utils.M68kPsiWalkUtil.isSignificantLine
|
||||||
|
|
||||||
|
class M68kFoldingBuilder : FoldingBuilderEx(), DumbAware {
|
||||||
|
|
||||||
|
override fun buildFoldRegions(root: PsiElement, document: Document, quick: Boolean): Array<FoldingDescriptor> {
|
||||||
|
if (root !is M68kFile) return FoldingDescriptor.EMPTY
|
||||||
|
|
||||||
|
val descriptors = ArrayList<FoldingDescriptor>()
|
||||||
|
var lineElement = root.firstChild
|
||||||
|
var foldingOpen = false
|
||||||
|
var foldingStart: PsiElement? = null
|
||||||
|
var foldingName: String? = null
|
||||||
|
var lastStatement = lineElement as? M68kStatement
|
||||||
|
while (lineElement != null) {
|
||||||
|
if (lineElement is M68kMacroDefinition) {
|
||||||
|
val fd = FoldingDescriptor(lineElement, lineElement.startOffset, lineElement.endOffset, null, "[[[ MACRO " + lineElement.name!! + " ]]]")
|
||||||
|
descriptors.add(fd)
|
||||||
|
}
|
||||||
|
if (lineElement is M68kStatement) {
|
||||||
|
val label = lineElement.globalLabel
|
||||||
|
if (label != null) {
|
||||||
|
foldingOpen = true
|
||||||
|
foldingStart = getBeginningOfRelatedComment(lineElement)
|
||||||
|
foldingName = "[[[ ${label.name} ]]]"
|
||||||
|
}
|
||||||
|
lastStatement = lineElement
|
||||||
|
}
|
||||||
|
lineElement = PsiTreeUtil.skipWhitespacesAndCommentsForward(lineElement)
|
||||||
|
if (foldingOpen) {
|
||||||
|
val stopIt = (lineElement == null) || isSignificantLine(lineElement)
|
||||||
|
if (stopIt) {
|
||||||
|
val fd = FoldingDescriptor(
|
||||||
|
foldingStart!!.parent!!,
|
||||||
|
foldingStart.startOffsetInParent, lastStatement!!.textRangeInParent.endOffset,
|
||||||
|
null, foldingName!!
|
||||||
|
)
|
||||||
|
descriptors.add(fd)
|
||||||
|
foldingOpen = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return descriptors.toArray(FoldingDescriptor.EMPTY)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getPlaceholderText(node: ASTNode): String? {
|
||||||
|
return "..."
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isCollapsedByDefault(node: ASTNode): Boolean {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.navigation
|
||||||
|
|
||||||
|
import com.intellij.ide.navigationToolbar.AbstractNavBarModelExtension
|
||||||
|
import com.intellij.ide.ui.UISettings
|
||||||
|
import com.intellij.openapi.actionSystem.CommonDataKeys
|
||||||
|
import com.intellij.openapi.actionSystem.DataContext
|
||||||
|
import com.intellij.openapi.project.IndexNotReadyException
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
|
import de.platon42.intellij.plugins.m68k.M68kIcons
|
||||||
|
import de.platon42.intellij.plugins.m68k.MC68000Language
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.*
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.utils.M68kPsiWalkUtil.findStatementForElement
|
||||||
|
import org.jetbrains.annotations.Nullable
|
||||||
|
import javax.swing.Icon
|
||||||
|
|
||||||
|
class M68kStructureAwareNavbar : AbstractNavBarModelExtension() {
|
||||||
|
|
||||||
|
override fun getLeafElement(dataContext: DataContext): PsiElement? {
|
||||||
|
if (UISettings.getInstance().showMembersInNavigationBar) {
|
||||||
|
val psiFile = CommonDataKeys.PSI_FILE.getData(dataContext)
|
||||||
|
val editor = CommonDataKeys.EDITOR.getData(dataContext)
|
||||||
|
if (psiFile == null || !psiFile.isValid || editor == null) return null
|
||||||
|
val psiElement = psiFile.findElementAt(editor.caretModel.offset)
|
||||||
|
if (isAcceptableLanguage(psiElement)) {
|
||||||
|
try {
|
||||||
|
var statement = findStatementForElement(psiElement!!) ?: return null
|
||||||
|
do {
|
||||||
|
if (statement.localLabel != null) return statement.localLabel
|
||||||
|
if (statement.globalLabel != null) return statement.globalLabel
|
||||||
|
statement = PsiTreeUtil.getPrevSiblingOfType(statement, M68kStatement::class.java) ?: return null
|
||||||
|
} while (true)
|
||||||
|
} catch (ignored: IndexNotReadyException) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun isAcceptableLanguage(psiElement: @Nullable PsiElement?) = psiElement?.language == MC68000Language.INSTANCE
|
||||||
|
|
||||||
|
override fun getPresentableText(obj: Any?): String? {
|
||||||
|
return when (obj) {
|
||||||
|
is M68kFile -> obj.name
|
||||||
|
is M68kGlobalLabel -> obj.name
|
||||||
|
is M68kLocalLabel -> obj.name
|
||||||
|
is M68kSymbolDefinition -> obj.name
|
||||||
|
is M68kMacroDefinition -> obj.macroNameDefinition.text
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getParent(psiElement: PsiElement): PsiElement? {
|
||||||
|
if (!isAcceptableLanguage(psiElement)) return null
|
||||||
|
var statement = findStatementForElement(psiElement) ?: return null
|
||||||
|
if (statement.localLabel != null) {
|
||||||
|
do {
|
||||||
|
if (statement.globalLabel != null) return statement.globalLabel
|
||||||
|
statement = PsiTreeUtil.getPrevSiblingOfType(statement, M68kStatement::class.java) ?: return null
|
||||||
|
} while (true)
|
||||||
|
}
|
||||||
|
return psiElement.containingFile
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getIcon(obj: Any?): Icon? {
|
||||||
|
return when (obj) {
|
||||||
|
is M68kFile -> M68kIcons.FILE
|
||||||
|
is M68kGlobalLabel -> M68kIcons.GLOBAL_LABEL
|
||||||
|
is M68kLocalLabel -> M68kIcons.LOCAL_LABEL
|
||||||
|
is M68kSymbolDefinition -> M68kIcons.SYMBOL_DEF
|
||||||
|
is M68kMacroDefinition -> M68kIcons.MACRO_DEF
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,10 +2,13 @@ package de.platon42.intellij.plugins.m68k.psi.utils
|
|||||||
|
|
||||||
import com.intellij.psi.PsiComment
|
import com.intellij.psi.PsiComment
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.PsiWhiteSpace
|
||||||
import com.intellij.psi.util.PsiTreeUtil
|
import com.intellij.psi.util.PsiTreeUtil
|
||||||
import com.intellij.util.SmartList
|
import com.intellij.util.SmartList
|
||||||
import com.intellij.util.containers.addIfNotNull
|
import com.intellij.util.containers.addIfNotNull
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kFile
|
||||||
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
|
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
|
||||||
|
|
||||||
object M68kPsiWalkUtil {
|
object M68kPsiWalkUtil {
|
||||||
|
|
||||||
@@ -28,4 +31,37 @@ object M68kPsiWalkUtil {
|
|||||||
|
|
||||||
return comments.reversed()
|
return comments.reversed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getBeginningOfRelatedComment(lineElement: PsiElement): PsiElement {
|
||||||
|
// go back to catch comments that are not more than one empty line away
|
||||||
|
var relStart = lineElement
|
||||||
|
var prevLine = relStart.prevSibling ?: return lineElement
|
||||||
|
var eolCount = 2
|
||||||
|
do {
|
||||||
|
if (prevLine is PsiComment) {
|
||||||
|
relStart = prevLine
|
||||||
|
eolCount = 1
|
||||||
|
} else if (prevLine is PsiWhiteSpace) {
|
||||||
|
if (--eolCount < 0) break
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
prevLine = prevLine.prevSibling ?: break
|
||||||
|
} while (true)
|
||||||
|
return relStart
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isSignificantLine(element: PsiElement) = when (element) {
|
||||||
|
is M68kStatement -> (element.assignment != null) || (element.globalLabel != null)
|
||||||
|
is M68kMacroDefinition -> true
|
||||||
|
else -> false
|
||||||
|
}
|
||||||
|
|
||||||
|
fun findStatementForElement(psiElement: PsiElement): M68kStatement? {
|
||||||
|
if (psiElement is M68kStatement) return psiElement
|
||||||
|
if (psiElement.parent is M68kFile) {
|
||||||
|
return PsiTreeUtil.getPrevSiblingOfType(psiElement, M68kStatement::class.java)
|
||||||
|
}
|
||||||
|
return PsiTreeUtil.getParentOfType(psiElement, M68kStatement::class.java);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -32,7 +32,7 @@ class M68kLocalLabelDefCompletionContributor : CompletionContributor() {
|
|||||||
}
|
}
|
||||||
referencedLocalLabels.removeAll(definedLocalLabels)
|
referencedLocalLabels.removeAll(definedLocalLabels)
|
||||||
resultSet.addAllElements(
|
resultSet.addAllElements(
|
||||||
if (parameters.originalPosition?.text == ".") {
|
if (parameters.originalPosition?.text?.startsWith(".") == true) {
|
||||||
referencedLocalLabels.map { LookupElementBuilder.create(it.removePrefix(".")) }
|
referencedLocalLabels.map { LookupElementBuilder.create(it.removePrefix(".")) }
|
||||||
} else {
|
} else {
|
||||||
referencedLocalLabels.map(LookupElementBuilder::create)
|
referencedLocalLabels.map(LookupElementBuilder::create)
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package de.platon42.intellij.plugins.m68k.syntax
|
package de.platon42.intellij.plugins.m68k.syntax
|
||||||
|
|
||||||
|
import com.intellij.codeHighlighting.RainbowHighlighter
|
||||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter
|
import com.intellij.openapi.fileTypes.SyntaxHighlighter
|
||||||
import com.intellij.openapi.options.colors.AttributesDescriptor
|
import com.intellij.openapi.options.colors.AttributesDescriptor
|
||||||
import com.intellij.openapi.options.colors.ColorDescriptor
|
import com.intellij.openapi.options.colors.ColorDescriptor
|
||||||
import com.intellij.openapi.options.colors.ColorSettingsPage
|
import com.intellij.openapi.options.colors.RainbowColorSettingsPage
|
||||||
import de.platon42.intellij.plugins.m68k.M68kIcons.FILE
|
import de.platon42.intellij.plugins.m68k.M68kIcons.FILE
|
||||||
|
import de.platon42.intellij.plugins.m68k.MC68000Language
|
||||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.AREG
|
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.AREG
|
||||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.BAD_CHARACTER
|
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.BAD_CHARACTER
|
||||||
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.COLON
|
import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.COLON
|
||||||
@@ -34,7 +36,9 @@ import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.
|
|||||||
import org.jetbrains.annotations.NonNls
|
import org.jetbrains.annotations.NonNls
|
||||||
import javax.swing.Icon
|
import javax.swing.Icon
|
||||||
|
|
||||||
class M68kColorSettingsPage : ColorSettingsPage {
|
class M68kColorSettingsPage : RainbowColorSettingsPage {
|
||||||
|
|
||||||
|
override fun getLanguage() = MC68000Language.INSTANCE
|
||||||
|
|
||||||
override fun getIcon(): Icon {
|
override fun getIcon(): Icon {
|
||||||
return FILE
|
return FILE
|
||||||
@@ -49,6 +53,8 @@ class M68kColorSettingsPage : ColorSettingsPage {
|
|||||||
return """; This is an example assembly language program
|
return """; This is an example assembly language program
|
||||||
PIC_HEIGHT = 256
|
PIC_HEIGHT = 256
|
||||||
|
|
||||||
|
* Semantic highlighting is available for registers and local labels
|
||||||
|
|
||||||
include "../includes/hardware/custom.i"
|
include "../includes/hardware/custom.i"
|
||||||
|
|
||||||
BLTHOGON MACRO ; macro definition
|
BLTHOGON MACRO ; macro definition
|
||||||
@@ -80,23 +86,21 @@ hello: dc.b 'Hello World!',10,0
|
|||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAdditionalHighlightingTagToDescriptorMap(): Map<String, TextAttributesKey>? {
|
override fun getAdditionalHighlightingTagToDescriptorMap(): Map<String, TextAttributesKey> {
|
||||||
return null
|
return RainbowHighlighter.createRainbowHLM()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getAttributeDescriptors(): Array<AttributesDescriptor> {
|
override fun isRainbowType(type: TextAttributesKey) = RAINBOW_TYPES.contains(type)
|
||||||
return DESCRIPTORS
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getColorDescriptors(): Array<ColorDescriptor> {
|
override fun getAttributeDescriptors() = DESCRIPTORS
|
||||||
return ColorDescriptor.EMPTY_ARRAY
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getDisplayName(): String {
|
override fun getColorDescriptors() = ColorDescriptor.EMPTY_ARRAY
|
||||||
return "M68k Assembly"
|
|
||||||
}
|
override fun getDisplayName() = "M68k Assembly"
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private val RAINBOW_TYPES = setOf(AREG, DREG, LOCAL_LABEL)
|
||||||
|
|
||||||
private val DESCRIPTORS = arrayOf(
|
private val DESCRIPTORS = arrayOf(
|
||||||
AttributesDescriptor("Global labels", GLOBAL_LABEL),
|
AttributesDescriptor("Global labels", GLOBAL_LABEL),
|
||||||
AttributesDescriptor("Local labels", LOCAL_LABEL),
|
AttributesDescriptor("Local labels", LOCAL_LABEL),
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.syntax
|
||||||
|
|
||||||
|
import com.intellij.codeInsight.daemon.RainbowVisitor
|
||||||
|
import com.intellij.codeInsight.daemon.impl.HighlightVisitor
|
||||||
|
import com.intellij.psi.PsiElement
|
||||||
|
import com.intellij.psi.PsiFile
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kAddressRegister
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kDataRegister
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kFile
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kLocalLabel
|
||||||
|
|
||||||
|
class M68kRainbowVisitor : RainbowVisitor() {
|
||||||
|
|
||||||
|
override fun suitableForFile(file: PsiFile): Boolean = file is M68kFile
|
||||||
|
|
||||||
|
override fun visit(element: PsiElement) {
|
||||||
|
when (element) {
|
||||||
|
is M68kAddressRegister -> addInfo(getInfo(element.containingFile, element, element.text, M68kSyntaxHighlighter.AREG))
|
||||||
|
is M68kDataRegister -> addInfo(getInfo(element.containingFile, element, element.text, M68kSyntaxHighlighter.DREG))
|
||||||
|
// is M68kGlobalLabel -> addInfo(getInfo(element.containingFile, element, element.text, M68kSyntaxHighlighter.GLOBAL_LABEL))
|
||||||
|
is M68kLocalLabel -> addInfo(getInfo(element.containingFile, element, element.text, M68kSyntaxHighlighter.LOCAL_LABEL))
|
||||||
|
// is M68kMacroCall -> addInfo(getInfo(element.containingFile, element.firstChild, element.macroName, M68kSyntaxHighlighter.MACRO_CALL))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun clone(): HighlightVisitor = M68kRainbowVisitor()
|
||||||
|
|
||||||
|
}
|
||||||
@@ -21,8 +21,14 @@
|
|||||||
implementationClass="de.platon42.intellij.plugins.m68k.parser.M68kParserDefinition"/>
|
implementationClass="de.platon42.intellij.plugins.m68k.parser.M68kParserDefinition"/>
|
||||||
<lang.syntaxHighlighterFactory language="MC68000"
|
<lang.syntaxHighlighterFactory language="MC68000"
|
||||||
implementationClass="de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighterFactory"/>
|
implementationClass="de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighterFactory"/>
|
||||||
|
<lang.foldingBuilder
|
||||||
|
language="MC68000"
|
||||||
|
implementationClass="de.platon42.intellij.plugins.m68k.folding.M68kFoldingBuilder"/>
|
||||||
|
<navbar implementation="de.platon42.intellij.plugins.m68k.navigation.M68kStructureAwareNavbar"/>
|
||||||
|
<highlightVisitor implementation="de.platon42.intellij.plugins.m68k.syntax.M68kRainbowVisitor"/>
|
||||||
<colorSettingsPage implementation="de.platon42.intellij.plugins.m68k.syntax.M68kColorSettingsPage"/>
|
<colorSettingsPage implementation="de.platon42.intellij.plugins.m68k.syntax.M68kColorSettingsPage"/>
|
||||||
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.asm.M68kMnemonicCompletionContributor"/>
|
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.asm.M68kMnemonicCompletionContributor"/>
|
||||||
|
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.asm.M68kDirectiveCompletionContributor"/>
|
||||||
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kGlobalLabelSymbolCompletionContributor"/>
|
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kGlobalLabelSymbolCompletionContributor"/>
|
||||||
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kLocalLabelDefCompletionContributor"/>
|
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kLocalLabelDefCompletionContributor"/>
|
||||||
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kMacroCallCompletionContributor"/>
|
<completion.contributor language="MC68000" implementationClass="de.platon42.intellij.plugins.m68k.refs.M68kMacroCallCompletionContributor"/>
|
||||||
|
|||||||
+63
@@ -0,0 +1,63 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.asm
|
||||||
|
|
||||||
|
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||||
|
import de.platon42.intellij.jupiter.LightCodeInsightExtension
|
||||||
|
import de.platon42.intellij.jupiter.MyFixture
|
||||||
|
import de.platon42.intellij.plugins.m68k.AbstractM68kTest
|
||||||
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith
|
||||||
|
|
||||||
|
@ExtendWith(LightCodeInsightExtension::class)
|
||||||
|
internal class M68kDirectiveCompletionContributorTest : AbstractM68kTest() {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
internal fun completion_shows_plain_directive(@MyFixture myFixture: CodeInsightTestFixture) {
|
||||||
|
myFixture.configureByText(
|
||||||
|
"completeme.asm", """
|
||||||
|
inc<caret>
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
myFixture.completeBasic()
|
||||||
|
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("include", "incbin", "incdir")
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
internal fun completion_shows_other_directive(@MyFixture myFixture: CodeInsightTestFixture) {
|
||||||
|
myFixture.configureByText(
|
||||||
|
"completeme.asm", """
|
||||||
|
IF<caret>
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
myFixture.completeBasic()
|
||||||
|
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder(
|
||||||
|
"IF",
|
||||||
|
"IFB",
|
||||||
|
"IFC",
|
||||||
|
"IFD",
|
||||||
|
"IFEQ",
|
||||||
|
"IFGE",
|
||||||
|
"IFGT",
|
||||||
|
"IFLE",
|
||||||
|
"IFLT",
|
||||||
|
"IFMACROD",
|
||||||
|
"IFMACROND",
|
||||||
|
"IFNB",
|
||||||
|
"IFNC",
|
||||||
|
"IFND",
|
||||||
|
"IFNE",
|
||||||
|
"ENDIF"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
internal fun completion_shows_data_directives(@MyFixture myFixture: CodeInsightTestFixture) {
|
||||||
|
myFixture.configureByText(
|
||||||
|
"completeme.asm", """
|
||||||
|
dc<caret>
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
myFixture.completeBasic()
|
||||||
|
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("dc", "dc.b", "dc.w", "dc.l", "dcb", "dcb.b", "dcb.w", "dcb.l", "data_c")
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -30,7 +30,7 @@ label: <caret>
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
myFixture.completeBasic()
|
myFixture.completeBasic()
|
||||||
assertThat(myFixture.lookupElementStrings).hasSameElementsAs(M68kIsa.mnemonics)
|
assertThat(myFixture.lookupElementStrings).containsAnyElementsOf(M68kIsa.mnemonics)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -41,6 +41,6 @@ label: <caret>
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
myFixture.completeBasic()
|
myFixture.completeBasic()
|
||||||
assertThat(myFixture.lookupElementStrings).hasSameElementsAs(M68kIsa.mnemonics)
|
assertThat(myFixture.lookupElementStrings).containsAnyElementsOf(M68kIsa.mnemonics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.folding
|
||||||
|
|
||||||
|
import com.intellij.testFramework.fixtures.CodeInsightTestFixture
|
||||||
|
import de.platon42.intellij.jupiter.LightCodeInsightExtension
|
||||||
|
import de.platon42.intellij.jupiter.MyFixture
|
||||||
|
import de.platon42.intellij.jupiter.TestDataPath
|
||||||
|
import org.junit.jupiter.api.Assertions.*
|
||||||
|
import org.junit.jupiter.api.Test
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith
|
||||||
|
|
||||||
|
@TestDataPath("src/test/resources/folding")
|
||||||
|
@ExtendWith(LightCodeInsightExtension::class)
|
||||||
|
internal class M68kFoldingBuilderTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
internal fun check_documentation_for_a_symbol_definition(@MyFixture myFixture: CodeInsightTestFixture) {
|
||||||
|
myFixture.testFolding(myFixture.testDataPath + "/folding.asm")
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -27,6 +27,6 @@ noppy MACRO
|
|||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
myFixture.completeBasic()
|
myFixture.completeBasic()
|
||||||
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("nop", "not", "noppy")
|
assertThat(myFixture.lookupElementStrings).containsExactlyInAnyOrder("nop", "not", "noppy", "cnop")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
; this is a test
|
||||||
|
|
||||||
|
FOO = 1
|
||||||
|
<fold text='[[[ demo_main ]]]'>; this is the main demo routine
|
||||||
|
demo_main:
|
||||||
|
moveq.l #0,d0
|
||||||
|
rts
|
||||||
|
|
||||||
|
; data area starts here
|
||||||
|
.data dc.w 10,0
|
||||||
|
even</fold>
|
||||||
|
|
||||||
|
; this is an unrelated comment
|
||||||
|
|
||||||
|
<fold text='[[[ intro_part1 ]]]'>; this is another folding area
|
||||||
|
; could be anything.
|
||||||
|
|
||||||
|
intro_part1
|
||||||
|
dc.w $47fe
|
||||||
|
illegal
|
||||||
|
rts</fold>
|
||||||
|
|
||||||
|
; this comment is two lines away
|
||||||
|
|
||||||
|
|
||||||
|
<fold text='[[[ intro_part2 ]]]'>intro_part2:
|
||||||
|
moveq.l #0,d1
|
||||||
|
rts</fold>
|
||||||
|
|
||||||
|
; standard macros
|
||||||
|
<fold text='[[[ MACRO BLTWAIT ]]]'>BLTWAIT MACRO
|
||||||
|
.bw\@
|
||||||
|
btst #DMAB_BLTDONE-8,dmaconr(a5)
|
||||||
|
bne.s .bw\@
|
||||||
|
ENDM</fold>
|
||||||
|
|
||||||
|
********************** foobar
|
||||||
|
|
||||||
|
|
||||||
|
<fold text='[[[ some_more_data ]]]'>some_more_data:
|
||||||
|
dc.w $123
|
||||||
|
dc.w $345
|
||||||
|
dc.w $333
|
||||||
|
dc.w $222</fold>
|
||||||
|
|
||||||
|
CUBE_SIZE = 100
|
||||||
Reference in New Issue
Block a user