Added semantic highlighting.
This commit is contained in:
parent
87cca67049
commit
b785b716bb
@ -1,4 +1,4 @@
|
||||
# MC68000 Assembly Language Plugin [![Build Status](https://app.travis-ci.com/chrisly42/mc68000-asm-plugin.svg?branch=master)](https://app.travis-ci.com/chrisly42/mc68000-asm-plugin)
|
||||
# MC68000 Assembly Language Plugin [![Build Status](https://app.travis-ci.com/chrisly42/mc68000-asm-plugin.svg?branch=master)](https://app.travis-ci.com/chrisly42/mc68000-asm-plugin) [![Coverage Status](https://coveralls.io/repos/github/chrisly42/mc68000-asm-plugin/badge.svg?branch=main)](https://coveralls.io/github/chrisly42/mc68000-asm-plugin?branch=main)
|
||||
|
||||
_MC68000 Assembly Language Plugin_ is plugin for Jetbrains IDEs (CLion, IntelliJ, etc.).
|
||||
|
||||
|
@ -7,7 +7,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'de.platon42'
|
||||
version = '0.9'
|
||||
version = '0.10'
|
||||
sourceCompatibility = "1.8"
|
||||
targetCompatibility = "1.8"
|
||||
|
||||
@ -61,12 +61,9 @@ runPluginVerifier {
|
||||
|
||||
patchPluginXml {
|
||||
setChangeNotes("""
|
||||
<h4>V0.9 (16-Aug-22)</h4>
|
||||
<h4>V0.10 (undefined)</h4>
|
||||
<ul>
|
||||
<li>Maintenance. Updated all dependencies to the latest versions.
|
||||
<li>Bugfix: Fixed condition code for asr/lsr/lsl, which is has a different behaviour for V flag than asl.
|
||||
<li>Bugfix: Fixed 'Unknown op size' exception when uppercase sizes were used.
|
||||
<li>Bugfix: Refactoring was broken for newer IDE versions, at least for me, this now works again by unknown magic.
|
||||
<li>New: Added semantic highlighting. Currently available for data and address registers and local labels.
|
||||
</ul>
|
||||
<p>Full changelog available at <a href="https://github.com/chrisly42/mc68000-asm-plugin#changelog">Github project site</a>.</p>
|
||||
""")
|
||||
|
@ -1,11 +1,13 @@
|
||||
package de.platon42.intellij.plugins.m68k.syntax
|
||||
|
||||
import com.intellij.codeHighlighting.RainbowHighlighter
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey
|
||||
import com.intellij.openapi.fileTypes.SyntaxHighlighter
|
||||
import com.intellij.openapi.options.colors.AttributesDescriptor
|
||||
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.MC68000Language
|
||||
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.COLON
|
||||
@ -34,7 +36,9 @@ import de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighter.Companion.
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import javax.swing.Icon
|
||||
|
||||
class M68kColorSettingsPage : ColorSettingsPage {
|
||||
class M68kColorSettingsPage : RainbowColorSettingsPage {
|
||||
|
||||
override fun getLanguage() = MC68000Language.INSTANCE
|
||||
|
||||
override fun getIcon(): Icon {
|
||||
return FILE
|
||||
@ -49,6 +53,8 @@ class M68kColorSettingsPage : ColorSettingsPage {
|
||||
return """; This is an example assembly language program
|
||||
PIC_HEIGHT = 256
|
||||
|
||||
* Semantic highlighting is available for registers and local labels
|
||||
|
||||
include "../includes/hardware/custom.i"
|
||||
|
||||
BLTHOGON MACRO ; macro definition
|
||||
@ -80,23 +86,21 @@ hello: dc.b 'Hello World!',10,0
|
||||
"""
|
||||
}
|
||||
|
||||
override fun getAdditionalHighlightingTagToDescriptorMap(): Map<String, TextAttributesKey>? {
|
||||
return null
|
||||
override fun getAdditionalHighlightingTagToDescriptorMap(): Map<String, TextAttributesKey> {
|
||||
return RainbowHighlighter.createRainbowHLM()
|
||||
}
|
||||
|
||||
override fun getAttributeDescriptors(): Array<AttributesDescriptor> {
|
||||
return DESCRIPTORS
|
||||
}
|
||||
override fun isRainbowType(type: TextAttributesKey) = RAINBOW_TYPES.contains(type)
|
||||
|
||||
override fun getColorDescriptors(): Array<ColorDescriptor> {
|
||||
return ColorDescriptor.EMPTY_ARRAY
|
||||
}
|
||||
override fun getAttributeDescriptors() = DESCRIPTORS
|
||||
|
||||
override fun getDisplayName(): String {
|
||||
return "M68k Assembly"
|
||||
}
|
||||
override fun getColorDescriptors() = ColorDescriptor.EMPTY_ARRAY
|
||||
|
||||
override fun getDisplayName() = "M68k Assembly"
|
||||
|
||||
companion object {
|
||||
private val RAINBOW_TYPES = setOf(AREG, DREG, LOCAL_LABEL)
|
||||
|
||||
private val DESCRIPTORS = arrayOf(
|
||||
AttributesDescriptor("Global labels", GLOBAL_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,6 +21,7 @@
|
||||
implementationClass="de.platon42.intellij.plugins.m68k.parser.M68kParserDefinition"/>
|
||||
<lang.syntaxHighlighterFactory language="MC68000"
|
||||
implementationClass="de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighterFactory"/>
|
||||
<highlightVisitor implementation="de.platon42.intellij.plugins.m68k.syntax.M68kRainbowVisitor"/>
|
||||
<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.refs.M68kGlobalLabelSymbolCompletionContributor"/>
|
||||
|
Loading…
Reference in New Issue
Block a user