Added some more settings for maximum parsed lines inside a macro and maximum displayed lines of code for documentation.
RegisterFlow line counting fixed.
This commit is contained in:
parent
e0bd6981e3
commit
85b2596c64
@ -26,7 +26,7 @@ to get started, and I can return to demo coding with its current state.
|
||||
## Features
|
||||
|
||||
- Parser / Lexer for MC680xx assembly language files in VAsm / DevPac style
|
||||
- Validates the assembly syntax against the 68000 ISA and 68020+ addressing modes (no complete >68020 support yet!)
|
||||
- Validates the assembly syntax against the 68000/68010 ISA and 68020+ addressing modes (no complete >68020 support yet!)
|
||||
- Syntax highlighting and Color Settings Page (you should really modify the color settings to your likings!)
|
||||
- Mnemonics code completion
|
||||
- Symbols / labels / macros code completion
|
||||
@ -164,7 +164,7 @@ are appreciated. It really is keeping me motivated to continue development.
|
||||
|
||||
## Changelog
|
||||
|
||||
### V0.8 (unreleased)
|
||||
### V0.8 (15-Oct-21)
|
||||
|
||||
- New: Support for MC68020+ addressing modes! However, MC68020+ specific instructions have not been added yet.
|
||||
- New: Full support for MC68010 ISA (`movec`, `moves` and new special registers `SFC` and `DFC`).
|
||||
@ -172,6 +172,7 @@ are appreciated. It really is keeping me motivated to continue development.
|
||||
- Enhancement: Symbol definition documentation now also includes comments in the same way as the label documentation does.
|
||||
- New: Macro definition / invocation documentation provider that even tries to expand macros.
|
||||
- New: Added Language settings page with one option so far (-spaces option).
|
||||
- New: Added some more settings for maximum parsed lines inside a macro and maximum displayed lines of code for documentation.
|
||||
|
||||
### V0.7 (26-Sep-21)
|
||||
|
||||
|
@ -48,7 +48,7 @@ intellij {
|
||||
}
|
||||
|
||||
runPluginVerifier {
|
||||
ideVersions = ["IC-203.6682.168", "IC-212.5284.40", // 2020.3 - 2021.2.2
|
||||
ideVersions = ["IC-203.6682.168", "IC-212.5457.46", // 2020.3 - 2021.2.3
|
||||
"CL-203.5981.166", "CL-203.8084.11", // 2020.3
|
||||
"CL-211.6693.114", "CL-211.7628.27", // 2021.1
|
||||
"CL-212.4746.93", "CL-212.5284.51"] // 2021.2 - 2021.2.2
|
||||
@ -58,7 +58,7 @@ runPluginVerifier {
|
||||
patchPluginXml {
|
||||
setChangeNotes("""
|
||||
<p>I still got zero feedback and zero <a href="https://plugins.jetbrains.com/plugin/17268-mc68000-assembly-language-support/reviews">ratings</a> :-(</p>
|
||||
<h4>V0.8 (unreleased)</h4>
|
||||
<h4>V0.8 (15-Oct-21)</h4>
|
||||
<ul>
|
||||
<li>New: Support for MC68020+ addressing modes! However, MC68020+ specific instructions have not been added yet.
|
||||
<li>New: Full support for MC68010 ISA ('movec', 'moves' and new special registers 'SFC' and 'DFC').
|
||||
@ -66,6 +66,7 @@ patchPluginXml {
|
||||
<li>Enhancement: Symbol definition documentation now also includes comments in the same way as the label documentation does.
|
||||
<li>New: Macro definition / invocation documentation provider that even tries to expand macros.
|
||||
<li>New: Added Language settings page with one option so far (-spaces option).
|
||||
<li>New: Added some more settings for maximum parsed lines inside a macro and maximum displayed lines of code for documentation.
|
||||
</ul>
|
||||
<p>Full changelog available at <a href="https://github.com/chrisly42/mc68000-asm-plugin#changelog">Github project site</a>.</p>
|
||||
""")
|
||||
|
@ -5,11 +5,15 @@ import com.intellij.lang.documentation.DocumentationMarkup
|
||||
import com.intellij.openapi.util.text.HtmlBuilder
|
||||
import com.intellij.openapi.util.text.HtmlChunk
|
||||
import com.intellij.psi.PsiElement
|
||||
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
|
||||
import de.platon42.intellij.plugins.m68k.psi.M68kNamedElement
|
||||
import de.platon42.intellij.plugins.m68k.psi.utils.M68kPsiWalkUtil
|
||||
import de.platon42.intellij.plugins.m68k.settings.M68kProjectSettings
|
||||
|
||||
abstract class AbstractM68kDocumentationProvider : AbstractDocumentationProvider() {
|
||||
|
||||
fun getSettings(element: PsiElement): M68kLexerPrefs = element.project.getService(M68kProjectSettings::class.java).settings
|
||||
|
||||
fun getComments(element: PsiElement): HtmlChunk {
|
||||
val builder = HtmlBuilder()
|
||||
val comments = M68kPsiWalkUtil.collectRelatedComments(element).map { HtmlChunk.text(it.text) }
|
||||
|
@ -15,11 +15,11 @@ class M68kMacroDefinitionDocumentationProvider : AbstractM68kDocumentationProvid
|
||||
}
|
||||
|
||||
override fun generateDoc(element: PsiElement, originalElement: PsiElement?): String? {
|
||||
return if (element is M68kMacroDefinition) createDoc(element, originalElement, 100) else null // TODO make this configurable
|
||||
return if (element is M68kMacroDefinition) createDoc(element, originalElement, getSettings(element).maxLongDocumentationLines) else null
|
||||
}
|
||||
|
||||
override fun generateHoverDoc(element: PsiElement, originalElement: PsiElement?): String? {
|
||||
return if (element is M68kMacroDefinition) createDoc(element, originalElement, 4) else null // TODO make this configurable
|
||||
return if (element is M68kMacroDefinition) createDoc(element, originalElement, getSettings(element).maxShortDocumentationLines) else null
|
||||
}
|
||||
|
||||
private fun createDoc(macrodef: M68kMacroDefinition, originalElement: PsiElement?, linesLimit: Int): String {
|
||||
|
@ -22,14 +22,14 @@ class M68kRegisterFlowDocumentationProvider : AbstractM68kDocumentationProvider(
|
||||
|
||||
override fun generateDoc(element: PsiElement, originalElement: PsiElement?): String? {
|
||||
if (element is M68kDataRegister || element is M68kAddressRegister) {
|
||||
return createDoc(element as M68kRegister, 100) // TODO make this configurable
|
||||
return createDoc(element as M68kRegister, getSettings(element).maxLongDocumentationLines)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun generateHoverDoc(element: PsiElement, originalElement: PsiElement?): String? {
|
||||
if (element is M68kDataRegister || element is M68kAddressRegister) {
|
||||
return createDoc(element as M68kRegister, 4) // TODO make this configurable
|
||||
return createDoc(element as M68kRegister, getSettings(element).maxShortDocumentationLines)
|
||||
}
|
||||
return null
|
||||
}
|
||||
@ -81,8 +81,9 @@ class M68kRegisterFlowDocumentationProvider : AbstractM68kDocumentationProvider(
|
||||
PsiTreeUtil.getPrevSiblingOfType(it, M68kStatement::class.java)
|
||||
})
|
||||
backtrace.reverse()
|
||||
val remLines = linesLimit - backtrace.size.coerceAtLeast(1)
|
||||
val traceBits = (cursorRwm or (cursorRwm ushr RWM_MODIFY_SHIFT) or (cursorRwm ushr RWM_READ_SHIFT)) and RWM_SIZE_MASK
|
||||
backtrace.addAll(analyseFlow(register, traceBits, false, initialStatement, linesLimit) {
|
||||
backtrace.addAll(analyseFlow(register, traceBits, false, initialStatement, remLines) {
|
||||
PsiTreeUtil.getNextSiblingOfType(it, M68kStatement::class.java)
|
||||
})
|
||||
|
||||
|
@ -4,5 +4,8 @@ data class M68kLexerPrefs(
|
||||
var spaceIntroducesComment: Boolean = false,
|
||||
var maxLinesPerMacro: Int = 250,
|
||||
var macroSectionUnparsed: Boolean = false,
|
||||
var macroParametersUnparsed: Boolean = true
|
||||
var macroParametersUnparsed: Boolean = true,
|
||||
|
||||
var maxShortDocumentationLines: Int = 5,
|
||||
var maxLongDocumentationLines: Int = 100,
|
||||
)
|
@ -9,7 +9,13 @@ import com.intellij.uiDesigner.core.Spacer
|
||||
import com.intellij.util.ui.FormBuilder
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import de.platon42.intellij.plugins.m68k.lexer.M68kLexerPrefs
|
||||
import java.text.NumberFormat
|
||||
import java.text.ParseException
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JFormattedTextField
|
||||
import javax.swing.JLabel
|
||||
import javax.swing.text.DefaultFormatterFactory
|
||||
import javax.swing.text.NumberFormatter
|
||||
|
||||
class M68kProjectSettingsConfigurable(project: Project?) : Configurable {
|
||||
|
||||
@ -17,6 +23,10 @@ class M68kProjectSettingsConfigurable(project: Project?) : Configurable {
|
||||
|
||||
private val spacesOptionField = JBCheckBox("Space introduces comment (-spaces)", settings?.settings?.spaceIntroducesComment ?: false)
|
||||
|
||||
private val maxLinesPerMacroField = createNumberField(settings?.settings?.maxLinesPerMacro)
|
||||
private val maxShortDocumentationLinesField = createNumberField(settings?.settings?.maxShortDocumentationLines)
|
||||
private val maxLongDocumentationLinesField = createNumberField(settings?.settings?.maxLongDocumentationLines)
|
||||
|
||||
override fun getDisplayName(): @ConfigurableName String = "M68k"
|
||||
|
||||
override fun createComponent(): JComponent? {
|
||||
@ -25,21 +35,57 @@ class M68kProjectSettingsConfigurable(project: Project?) : Configurable {
|
||||
.setHorizontalGap(UIUtil.DEFAULT_HGAP)
|
||||
.setVerticalGap(UIUtil.DEFAULT_VGAP)
|
||||
.addComponent(spacesOptionField)
|
||||
.addLabeledComponent(JLabel("Maximum lines parsed inside macro"), maxLinesPerMacroField)
|
||||
.addSeparator()
|
||||
.addLabeledComponent(JLabel("Lines of code in hovered documentation"), maxShortDocumentationLinesField)
|
||||
.addLabeledComponent(JLabel("Lines of code in full documentation"), maxLongDocumentationLinesField)
|
||||
.addComponentFillVertically(Spacer(), 0)
|
||||
.panel
|
||||
}
|
||||
|
||||
private fun createNumberField(value: Any?): JFormattedTextField {
|
||||
val valueField = JFormattedTextField()
|
||||
valueField.columns = 4
|
||||
val formatter = NumberFormat.getIntegerInstance()
|
||||
formatter.isParseIntegerOnly = true
|
||||
valueField.formatterFactory = DefaultFormatterFactory(NumberFormatter(formatter))
|
||||
valueField.value = value
|
||||
return valueField
|
||||
}
|
||||
|
||||
override fun isModified(): Boolean {
|
||||
return settings?.settings?.spaceIntroducesComment != spacesOptionField.isSelected
|
||||
val prefs = settings?.settings ?: return false
|
||||
|
||||
return prefs.spaceIntroducesComment != spacesOptionField.isSelected
|
||||
|| fieldDiffers(maxLinesPerMacroField, prefs.maxLinesPerMacro)
|
||||
|| fieldDiffers(maxShortDocumentationLinesField, prefs.maxShortDocumentationLines)
|
||||
|| fieldDiffers(maxLongDocumentationLinesField, prefs.maxLongDocumentationLines)
|
||||
}
|
||||
|
||||
@Throws(ConfigurationException::class)
|
||||
override fun apply() {
|
||||
settings?.settings?.spaceIntroducesComment = spacesOptionField.isSelected
|
||||
val prefs = settings?.settings ?: return
|
||||
prefs.spaceIntroducesComment = spacesOptionField.isSelected
|
||||
getFieldValue(maxLinesPerMacroField).let { if (it != null) prefs.maxLinesPerMacro = it }
|
||||
getFieldValue(maxShortDocumentationLinesField).let { if (it != null) prefs.maxShortDocumentationLines = it }
|
||||
getFieldValue(maxLongDocumentationLinesField).let { if (it != null) prefs.maxLongDocumentationLines = it }
|
||||
}
|
||||
|
||||
private fun fieldDiffers(field: JFormattedTextField, value: Int?): Boolean {
|
||||
val fieldValue = getFieldValue(field)
|
||||
return (fieldValue != null) && (value != null) && (fieldValue != value)
|
||||
}
|
||||
|
||||
private fun getFieldValue(field: JFormattedTextField): Int? {
|
||||
return try {
|
||||
val value = field.value
|
||||
(value as Number).toInt()
|
||||
} catch (ex: ParseException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
override fun reset() {
|
||||
val default = M68kLexerPrefs()
|
||||
settings?.settings?.spaceIntroducesComment = default.spaceIntroducesComment
|
||||
settings?.settings = M68kLexerPrefs()
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user