Flushing current state for a release.
This commit is contained in:
parent
df2a220473
commit
e3efc545a8
14
README.md
14
README.md
@ -133,6 +133,7 @@ If the current statement has no valid syntax, the instruction details of all mat
|
|||||||
- Switching the spaces option usually needs the caches to be invalidated. Find Usages word scanner always uses default settings, as it is not configurable per
|
- Switching the spaces option usually needs the caches to be invalidated. Find Usages word scanner always uses default settings, as it is not configurable per
|
||||||
project :-/
|
project :-/
|
||||||
- Unit Test coverage is not as good as it could be (ahem).
|
- Unit Test coverage is not as good as it could be (ahem).
|
||||||
|
- Code flow sometimes outputs "uhm?"
|
||||||
- Missing but planned features:
|
- Missing but planned features:
|
||||||
- Macro evaluation on invocation
|
- Macro evaluation on invocation
|
||||||
- Folding
|
- Folding
|
||||||
@ -164,6 +165,19 @@ are appreciated. It really is keeping me motivated to continue development.
|
|||||||
|
|
||||||
## Changelog
|
## Changelog
|
||||||
|
|
||||||
|
### V0.10 (20-Feb-24)
|
||||||
|
|
||||||
|
- Decided to release some features that have been sitting on my harddrive for almost two years, but never got released,
|
||||||
|
because I was unable to get that damn formatter working in a way that was acceptable (the API and the docs are easily one
|
||||||
|
the worst abominations I've come across).
|
||||||
|
- Maintenance. Updated all dependencies to the latest versions.
|
||||||
|
- New: Added semantic highlighting. Currently available for data and address registers and local labels.
|
||||||
|
- Bugfix: addq/subq for address register stated it would affect the condition codes, which it in fact doesn't.
|
||||||
|
- New: Added simple custom navigation bar.
|
||||||
|
- New: Added folding support for functions and macro definitions.
|
||||||
|
- 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).
|
||||||
|
|
||||||
### V0.9 (16-Aug-22)
|
### V0.9 (16-Aug-22)
|
||||||
|
|
||||||
- Maintenance. Updated all dependencies to the latest versions.
|
- Maintenance. Updated all dependencies to the latest versions.
|
||||||
|
38
build.gradle
38
build.gradle
@ -1,13 +1,12 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'org.jetbrains.intellij' version '1.11.0'
|
id 'org.jetbrains.intellij' version '1.17.1'
|
||||||
id 'org.jetbrains.kotlin.jvm' version '1.8.0-RC2'
|
id 'org.jetbrains.kotlin.jvm' version '1.9.22'
|
||||||
id 'jacoco'
|
id 'jacoco'
|
||||||
id 'com.github.kt3k.coveralls' version '2.12.0'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'de.platon42'
|
group = 'de.platon42'
|
||||||
version = '0.10'
|
version = '0.11'
|
||||||
sourceCompatibility = 17
|
sourceCompatibility = 17
|
||||||
targetCompatibility = 17
|
targetCompatibility = 17
|
||||||
|
|
||||||
@ -22,12 +21,12 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
|
||||||
testImplementation 'org.assertj:assertj-core:3.23.1'
|
testImplementation 'org.assertj:assertj-core:3.25.3'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.1'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.1'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
|
||||||
testImplementation "org.jetbrains.kotlin:kotlin-test"
|
testImplementation "org.jetbrains.kotlin:kotlin-test"
|
||||||
testImplementation "org.jetbrains.kotlin:kotlin-reflect"
|
testImplementation "org.jetbrains.kotlin:kotlin-reflect"
|
||||||
testImplementation 'org.junit.platform:junit-platform-launcher:1.9.1'
|
testImplementation 'org.junit.platform:junit-platform-launcher:1.10.2'
|
||||||
// testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
|
// testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,21 +37,20 @@ intellij {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runPluginVerifier {
|
runPluginVerifier {
|
||||||
ideVersions = ["IC-203.6682.168", "IC-223.7571.182", // 2020.3 - 2022.3
|
ideVersions = ["IC-203.6682.168", "IC-233.14015.106", // 2020.3 - 2023.3
|
||||||
"CL-203.8084.11", // 2020.3
|
"CL-203.8084.11", "CL-233.14015.92"] // 2020.3 - 2023.3
|
||||||
"CL-211.7628.27", // 2021.1
|
|
||||||
"CL-212.5712.21", // 2021.2
|
|
||||||
"CL-213.7172.20", // 2021.3.4
|
|
||||||
"CL-221.5921.22", // 2022.1.3
|
|
||||||
"CL-222.4345.21", // 2022.2.4
|
|
||||||
"CL-223.7571.171"] // 2022.3
|
|
||||||
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.10 (undefined)</h4>
|
<h4>V0.10 (20-Feb-24)</h4>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>Decided to release some features that have been sitting on my harddrive for almost two years, but never got released,
|
||||||
|
because I was unable to get that damn formatter working in a way that was acceptable (the API and the docs are easily one
|
||||||
|
the worst abominations I've come across).
|
||||||
|
<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>New: Added semantic highlighting. Currently available for data and address registers and local labels.
|
||||||
<li>Bugfix: addq/subq for address register stated it would affect the condition codes, which it in fact doesn't.
|
<li>Bugfix: addq/subq for address register stated it would affect the condition codes, which it in fact doesn't.
|
||||||
<li>New: Added simple custom navigation bar.
|
<li>New: Added simple custom navigation bar.
|
||||||
@ -60,7 +58,7 @@ patchPluginXml {
|
|||||||
<li>New: Added assembler directives to code completion (only lower-case except for other directives like IF
|
<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).
|
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://git.platon42.de/chrisly42/mc68000-asm-plugin#changelog">Gitea project site</a>.</p>
|
||||||
""")
|
""")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,10 +74,6 @@ test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.coveralls {
|
|
||||||
dependsOn jacocoTestReport
|
|
||||||
}
|
|
||||||
|
|
||||||
jacoco {
|
jacoco {
|
||||||
toolVersion = '0.8.8'
|
toolVersion = '0.8.8'
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@ object AssemblerDirectives {
|
|||||||
"align", "even", "odd", "cnop", "long", "dphrase", "phrase", "qphrase",
|
"align", "even", "odd", "cnop", "long", "dphrase", "phrase", "qphrase",
|
||||||
|
|
||||||
"cargs", "comm", "comment",
|
"cargs", "comm", "comment",
|
||||||
"rsset", "clrfo", "clrso", "setfo", "setso"
|
"rsset", "clrfo", "clrso", "setfo", "setso",
|
||||||
|
|
||||||
|
"rsreset", "rs.b", "rs.w", "rs.l"
|
||||||
)
|
)
|
||||||
|
|
||||||
val plainDirectives: Set<String> = setOf(
|
val plainDirectives: Set<String> = setOf(
|
||||||
|
@ -0,0 +1,23 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.formatter
|
||||||
|
|
||||||
|
import com.intellij.formatting.Alignment
|
||||||
|
import com.intellij.formatting.Block
|
||||||
|
import com.intellij.formatting.Spacing
|
||||||
|
import com.intellij.formatting.Wrap
|
||||||
|
import com.intellij.lang.ASTNode
|
||||||
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
|
import com.intellij.psi.formatter.common.AbstractBlock
|
||||||
|
|
||||||
|
class M68kAsmAssignmentBlock(
|
||||||
|
node: ASTNode, wrap: Wrap?, alignment: Alignment?,
|
||||||
|
private val codeStyleSettings: CodeStyleSettings
|
||||||
|
) : AbstractBlock(node, wrap, alignment) {
|
||||||
|
|
||||||
|
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
||||||
|
return Spacing.getReadOnlySpacing()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isLeaf() = true
|
||||||
|
|
||||||
|
override fun buildChildren() = emptyList<Block>()
|
||||||
|
}
|
@ -1,6 +1,9 @@
|
|||||||
package de.platon42.intellij.plugins.m68k.formatter
|
package de.platon42.intellij.plugins.m68k.formatter
|
||||||
|
|
||||||
import com.intellij.formatting.*
|
import com.intellij.formatting.Alignment
|
||||||
|
import com.intellij.formatting.Block
|
||||||
|
import com.intellij.formatting.Spacing
|
||||||
|
import com.intellij.formatting.Wrap
|
||||||
import com.intellij.lang.ASTNode
|
import com.intellij.lang.ASTNode
|
||||||
import com.intellij.psi.TokenType
|
import com.intellij.psi.TokenType
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
@ -9,17 +12,21 @@ import de.platon42.intellij.plugins.m68k.psi.M68kTypes
|
|||||||
|
|
||||||
class M68kAsmBlock(
|
class M68kAsmBlock(
|
||||||
node: ASTNode, wrap: Wrap?, alignment: Alignment?,
|
node: ASTNode, wrap: Wrap?, alignment: Alignment?,
|
||||||
private val column: Int,
|
val column: Int,
|
||||||
private val codeStyleSettings: CodeStyleSettings
|
private val codeStyleSettings: CodeStyleSettings
|
||||||
) : AbstractBlock(node, wrap, alignment) {
|
) : AbstractBlock(node, wrap, alignment) {
|
||||||
|
|
||||||
override fun getIndent() = Indent.getNoneIndent()
|
|
||||||
|
|
||||||
private fun normalIndent(): Indent {
|
|
||||||
return IndentImpl(Indent.Type.SPACES, true, codeStyleSettings.indentOptions.INDENT_SIZE, false, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
||||||
|
if (child1 is M68kAsmBlock && child2 is M68kAsmBlock) {
|
||||||
|
val columnDiff = child2.column - child1.column
|
||||||
|
if (columnDiff > 0) {
|
||||||
|
var minSpaces = columnDiff * codeStyleSettings.indentOptions.INDENT_SIZE - child1.node.textLength
|
||||||
|
while (minSpaces < 1) {
|
||||||
|
minSpaces += codeStyleSettings.indentOptions.INDENT_SIZE
|
||||||
|
}
|
||||||
|
return Spacing.createSpacing(minSpaces, minSpaces, 0, false, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,6 +34,10 @@ class M68kAsmBlock(
|
|||||||
|
|
||||||
override fun buildChildren(): List<Block> {
|
override fun buildChildren(): List<Block> {
|
||||||
val subBlocks = ArrayList<Block>()
|
val subBlocks = ArrayList<Block>()
|
||||||
|
if (myNode.elementType == M68kTypes.ASM_OP) {
|
||||||
|
return subBlocks
|
||||||
|
}
|
||||||
|
|
||||||
var child = myNode.firstChildNode
|
var child = myNode.firstChildNode
|
||||||
var newColumn = column
|
var newColumn = column
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
@ -34,14 +45,14 @@ class M68kAsmBlock(
|
|||||||
subBlocks.add(
|
subBlocks.add(
|
||||||
M68kAsmBlock(
|
M68kAsmBlock(
|
||||||
child,
|
child,
|
||||||
Wrap.createWrap(WrapType.NONE, false),
|
null,
|
||||||
Alignment.createAlignment(),
|
null,
|
||||||
newColumn,
|
newColumn,
|
||||||
codeStyleSettings
|
codeStyleSettings
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
if (child.elementType == M68kTypes.ASM_OP) {
|
if (child.elementType == M68kTypes.ASM_OP) {
|
||||||
newColumn++
|
newColumn += 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
child = child.treeNext
|
child = child.treeNext
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.formatter
|
||||||
|
|
||||||
|
import com.intellij.formatting.Block
|
||||||
|
import com.intellij.formatting.Spacing
|
||||||
|
import com.intellij.lang.ASTNode
|
||||||
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
|
import com.intellij.psi.formatter.common.AbstractBlock
|
||||||
|
|
||||||
|
class M68kAsmCommentBlock(
|
||||||
|
node: ASTNode,
|
||||||
|
private val codeStyleSettings: CodeStyleSettings
|
||||||
|
) : AbstractBlock(node, null, null) {
|
||||||
|
|
||||||
|
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
||||||
|
return Spacing.getReadOnlySpacing()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isLeaf() = true
|
||||||
|
|
||||||
|
override fun buildChildren() = emptyList<Block>()
|
||||||
|
}
|
@ -1,15 +1,10 @@
|
|||||||
package de.platon42.intellij.plugins.m68k.formatter
|
package de.platon42.intellij.plugins.m68k.formatter
|
||||||
|
|
||||||
import com.intellij.formatting.*
|
import com.intellij.formatting.Block
|
||||||
import com.intellij.lang.ASTNode
|
import com.intellij.lang.ASTNode
|
||||||
import com.intellij.psi.formatter.common.AbstractBlock
|
import com.intellij.psi.formatter.common.AbstractBlock
|
||||||
|
|
||||||
class M68kAsmEolBlock(node: ASTNode) : AbstractBlock(
|
class M68kAsmEolBlock(node: ASTNode) : AbstractBlock(node, null, null) {
|
||||||
node, Wrap.createWrap(WrapType.NONE, false),
|
|
||||||
Alignment.createAlignment()
|
|
||||||
) {
|
|
||||||
|
|
||||||
override fun getIndent() = Indent.getNoneIndent()
|
|
||||||
|
|
||||||
override fun getSpacing(child1: Block?, child2: Block) = null
|
override fun getSpacing(child1: Block?, child2: Block) = null
|
||||||
|
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package de.platon42.intellij.plugins.m68k.formatter
|
package de.platon42.intellij.plugins.m68k.formatter
|
||||||
|
|
||||||
import com.intellij.formatting.*
|
import com.intellij.formatting.Alignment
|
||||||
|
import com.intellij.formatting.Block
|
||||||
|
import com.intellij.formatting.Spacing
|
||||||
|
import com.intellij.formatting.Wrap
|
||||||
import com.intellij.lang.ASTNode
|
import com.intellij.lang.ASTNode
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
import com.intellij.psi.formatter.common.AbstractBlock
|
import com.intellij.psi.formatter.common.AbstractBlock
|
||||||
@ -10,10 +13,6 @@ class M68kAsmLabelBlock(
|
|||||||
private val codeStyleSettings: CodeStyleSettings
|
private val codeStyleSettings: CodeStyleSettings
|
||||||
) : AbstractBlock(node, wrap, alignment) {
|
) : AbstractBlock(node, wrap, alignment) {
|
||||||
|
|
||||||
override fun getIndent(): Indent? {
|
|
||||||
return Indent.getAbsoluteNoneIndent()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
||||||
return Spacing.getReadOnlySpacing()
|
return Spacing.getReadOnlySpacing()
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
package de.platon42.intellij.plugins.m68k.formatter
|
||||||
|
|
||||||
|
import com.intellij.formatting.Block
|
||||||
|
import com.intellij.formatting.Spacing
|
||||||
|
import com.intellij.lang.ASTNode
|
||||||
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
|
import com.intellij.psi.formatter.common.AbstractBlock
|
||||||
|
|
||||||
|
class M68kAsmMacroDefBlock(
|
||||||
|
node: ASTNode,
|
||||||
|
private val codeStyleSettings: CodeStyleSettings
|
||||||
|
) : AbstractBlock(node, null, null) {
|
||||||
|
|
||||||
|
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
||||||
|
return Spacing.getReadOnlySpacing()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isLeaf() = true
|
||||||
|
|
||||||
|
override fun buildChildren() = emptyList<Block>()
|
||||||
|
}
|
@ -1,22 +1,39 @@
|
|||||||
package de.platon42.intellij.plugins.m68k.formatter
|
package de.platon42.intellij.plugins.m68k.formatter
|
||||||
|
|
||||||
import com.intellij.formatting.*
|
import com.intellij.formatting.Block
|
||||||
|
import com.intellij.formatting.Indent
|
||||||
|
import com.intellij.formatting.Spacing
|
||||||
import com.intellij.lang.ASTNode
|
import com.intellij.lang.ASTNode
|
||||||
|
import com.intellij.psi.PsiComment
|
||||||
import com.intellij.psi.TokenType
|
import com.intellij.psi.TokenType
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
import com.intellij.psi.formatter.common.AbstractBlock
|
import com.intellij.psi.formatter.common.AbstractBlock
|
||||||
|
import de.platon42.intellij.plugins.m68k.psi.M68kMacroDefinition
|
||||||
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
|
import de.platon42.intellij.plugins.m68k.psi.M68kStatement
|
||||||
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
|
import de.platon42.intellij.plugins.m68k.psi.M68kTypes
|
||||||
|
|
||||||
class M68kAsmRootBlock(node: ASTNode, private val codeStyleSettings: CodeStyleSettings) : AbstractBlock(node, null, null) {
|
class M68kAsmRootBlock(node: ASTNode, private val codeStyleSettings: CodeStyleSettings) : AbstractBlock(node, null, null) {
|
||||||
|
|
||||||
override fun getIndent(): Indent? {
|
override fun getIndent(): Indent? {
|
||||||
return Indent.getNoneIndent()
|
return Indent.getAbsoluteNoneIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
||||||
if (child2 is M68kAsmEolBlock) {
|
if (child2 is M68kAsmEolBlock) {
|
||||||
return Spacing.createSpacing(0, 0, 0, false, 0)
|
return Spacing.createSpacing(0, 0, 0, false, 0)
|
||||||
|
//return null
|
||||||
|
}
|
||||||
|
if (child2 is M68kAsmMacroDefBlock) {
|
||||||
|
return child2.getSpacing(child1, child2)
|
||||||
|
}
|
||||||
|
if (child2 is M68kAsmCommentBlock) {
|
||||||
|
if (child1 is M68kAsmStatementBlock) {
|
||||||
|
val indentSize = codeStyleSettings.indentOptions.INDENT_SIZE
|
||||||
|
val oddIdent = indentSize - (child1.node.textLength % indentSize)
|
||||||
|
return Spacing.createSpacing(oddIdent, Integer.MAX_VALUE, 0, false, 0)
|
||||||
|
} else {
|
||||||
|
return Spacing.getReadOnlySpacing()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (child2.subBlocks.isNotEmpty()) {
|
if (child2.subBlocks.isNotEmpty()) {
|
||||||
return child2.getSpacing(child1, child2.subBlocks.first())
|
return child2.getSpacing(child1, child2.subBlocks.first())
|
||||||
@ -37,15 +54,12 @@ class M68kAsmRootBlock(node: ASTNode, private val codeStyleSettings: CodeStyleSe
|
|||||||
} else if (child.elementType != TokenType.WHITE_SPACE) {
|
} else if (child.elementType != TokenType.WHITE_SPACE) {
|
||||||
if (child.psi is M68kStatement) {
|
if (child.psi is M68kStatement) {
|
||||||
subBlocks.add(M68kAsmStatementBlock(child, codeStyleSettings))
|
subBlocks.add(M68kAsmStatementBlock(child, codeStyleSettings))
|
||||||
|
} else if (child.psi is M68kMacroDefinition) {
|
||||||
|
subBlocks.add(M68kAsmMacroDefBlock(child, codeStyleSettings))
|
||||||
|
} else if (child.psi is PsiComment) {
|
||||||
|
subBlocks.add(M68kAsmCommentBlock(child, codeStyleSettings))
|
||||||
} else {
|
} else {
|
||||||
subBlocks.add(
|
subBlocks.add(M68kAsmBlock(child, null, null, 0, codeStyleSettings))
|
||||||
M68kAsmBlock(
|
|
||||||
child,
|
|
||||||
Wrap.createWrap(WrapType.NONE, false),
|
|
||||||
Alignment.createAlignment(),
|
|
||||||
0, codeStyleSettings
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package de.platon42.intellij.plugins.m68k.formatter
|
package de.platon42.intellij.plugins.m68k.formatter
|
||||||
|
|
||||||
import com.intellij.formatting.*
|
import com.intellij.formatting.Block
|
||||||
|
import com.intellij.formatting.Indent
|
||||||
|
import com.intellij.formatting.Spacing
|
||||||
import com.intellij.lang.ASTNode
|
import com.intellij.lang.ASTNode
|
||||||
import com.intellij.psi.TokenType
|
import com.intellij.psi.TokenType
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings
|
import com.intellij.psi.codeStyle.CodeStyleSettings
|
||||||
@ -8,15 +10,15 @@ import com.intellij.psi.formatter.common.AbstractBlock
|
|||||||
import de.platon42.intellij.plugins.m68k.psi.*
|
import de.platon42.intellij.plugins.m68k.psi.*
|
||||||
|
|
||||||
class M68kAsmStatementBlock(node: ASTNode, private val codeStyleSettings: CodeStyleSettings) :
|
class M68kAsmStatementBlock(node: ASTNode, private val codeStyleSettings: CodeStyleSettings) :
|
||||||
AbstractBlock(node, Wrap.createWrap(WrapType.NONE, false), Alignment.createAlignment()) {
|
AbstractBlock(node, null, null) {
|
||||||
|
|
||||||
override fun getIndent(): Indent {
|
override fun getIndent(): Indent? {
|
||||||
val statement = myNode.psi as M68kStatement
|
val statement = myNode.psi as M68kStatement
|
||||||
if (((statement.asmInstruction != null) || (statement.preprocessorDirective != null)
|
if (((statement.asmInstruction != null) || (statement.asmInstruction != null) || (statement.preprocessorDirective != null)
|
||||||
|| (statement.macroCall != null))
|
|| (statement.macroCall != null))
|
||||||
&& ((statement.localLabel == null) && (statement.globalLabel == null))
|
&& ((statement.localLabel == null) && (statement.globalLabel == null))
|
||||||
) {
|
) {
|
||||||
return IndentImpl(Indent.Type.SPACES, true, codeStyleSettings.indentOptions.INDENT_SIZE, false, false)
|
return null
|
||||||
} else {
|
} else {
|
||||||
return Indent.getAbsoluteNoneIndent()
|
return Indent.getAbsoluteNoneIndent()
|
||||||
}
|
}
|
||||||
@ -24,22 +26,22 @@ class M68kAsmStatementBlock(node: ASTNode, private val codeStyleSettings: CodeSt
|
|||||||
|
|
||||||
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
override fun getSpacing(child1: Block?, child2: Block): Spacing? {
|
||||||
if (child2 is M68kAsmBlock) {
|
if (child2 is M68kAsmBlock) {
|
||||||
val indentSize = codeStyleSettings.indentOptions.INDENT_SIZE
|
val indentSize = codeStyleSettings.indentOptions.INDENT_SIZE * child2.column
|
||||||
if (child1 is M68kAsmEolBlock) {
|
if (child1 is M68kAsmEolBlock || child1 is M68kAsmCommentBlock) {
|
||||||
return Spacing.createSpacing(1, indentSize, 0, true, 0)
|
return Spacing.createSpacing(indentSize, indentSize, 0, true, 0)
|
||||||
}
|
}
|
||||||
if (child1 is M68kAsmLabelBlock) {
|
if (child1 is M68kAsmLabelBlock) {
|
||||||
val spacesLeft = indentSize - child1.node.textLength
|
val spacesLeft = indentSize - child1.node.textLength
|
||||||
if (spacesLeft <= 0) {
|
if (spacesLeft <= 0) {
|
||||||
return Spacing.createSpacing(1, indentSize, 1, false, 0)
|
return Spacing.createSpacing(0, 0, 1, true, 0)
|
||||||
} else {
|
} else {
|
||||||
return Spacing.createSpacing(1, spacesLeft, 0, false, 0)
|
return Spacing.createSpacing(spacesLeft, spacesLeft, 0, true, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Spacing.createSpacing(1, indentSize, 0, false, 0)
|
return Spacing.createSpacing(indentSize, indentSize, 0, true, 0)
|
||||||
}
|
}
|
||||||
if (child2 is M68kAsmLabelBlock) {
|
if (child2 is M68kAsmLabelBlock || child2 is M68kAsmAssignmentBlock) {
|
||||||
return Spacing.createSpacing(0, 0, 0, false, 0)
|
return Spacing.createSpacing(0, 0, 0, true, 0)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@ -53,49 +55,15 @@ class M68kAsmStatementBlock(node: ASTNode, private val codeStyleSettings: CodeSt
|
|||||||
if (child.elementType != TokenType.WHITE_SPACE) {
|
if (child.elementType != TokenType.WHITE_SPACE) {
|
||||||
val element = child.psi
|
val element = child.psi
|
||||||
when (element) {
|
when (element) {
|
||||||
is M68kAssignment ->
|
is M68kAssignment -> subBlocks.add(M68kAsmAssignmentBlock(child, null, null, codeStyleSettings))
|
||||||
subBlocks.add(
|
|
||||||
M68kAsmBlock(
|
|
||||||
child,
|
|
||||||
Wrap.createWrap(WrapType.NORMAL, false),
|
|
||||||
Alignment.createAlignment(),
|
|
||||||
0,
|
|
||||||
codeStyleSettings
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
is M68kAsmInstruction, is M68kPreprocessorDirective, is M68kMacroCall ->
|
is M68kAsmInstruction, is M68kPreprocessorDirective, is M68kMacroCall ->
|
||||||
subBlocks.add(
|
subBlocks.add(M68kAsmBlock(child, null, null, 2, codeStyleSettings))
|
||||||
M68kAsmBlock(
|
|
||||||
child,
|
|
||||||
Wrap.createWrap(WrapType.NORMAL, false),
|
|
||||||
Alignment.createAlignment(),
|
|
||||||
1,
|
|
||||||
codeStyleSettings
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
is M68kGlobalLabel, is M68kLocalLabel ->
|
is M68kGlobalLabel, is M68kLocalLabel ->
|
||||||
subBlocks.add(
|
subBlocks.add(M68kAsmLabelBlock(child, null, null, codeStyleSettings))
|
||||||
M68kAsmLabelBlock(
|
|
||||||
child,
|
|
||||||
Wrap.createWrap(WrapType.NONE, false),
|
|
||||||
Alignment.createAlignment(),
|
|
||||||
codeStyleSettings
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
else -> subBlocks.add(M68kAsmBlock(child, null, null, 1, codeStyleSettings))
|
||||||
else ->
|
|
||||||
subBlocks.add(
|
|
||||||
M68kAsmBlock(
|
|
||||||
child,
|
|
||||||
Wrap.createWrap(WrapType.NONE, false),
|
|
||||||
Alignment.createAlignment(),
|
|
||||||
1,
|
|
||||||
codeStyleSettings
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
implementationClass="de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighterFactory"/>
|
implementationClass="de.platon42.intellij.plugins.m68k.syntax.M68kSyntaxHighlighterFactory"/>
|
||||||
<lang.foldingBuilder language="MC68000"
|
<lang.foldingBuilder language="MC68000"
|
||||||
implementationClass="de.platon42.intellij.plugins.m68k.folding.M68kFoldingBuilder"/>
|
implementationClass="de.platon42.intellij.plugins.m68k.folding.M68kFoldingBuilder"/>
|
||||||
<lang.formatter language="MC68000"
|
<!--lang.formatter language="MC68000"
|
||||||
implementationClass="de.platon42.intellij.plugins.m68k.formatter.M68kAsmFormattingModelBuilder"/>
|
implementationClass="de.platon42.intellij.plugins.m68k.formatter.M68kAsmFormattingModelBuilder"/-->
|
||||||
<codeStyleSettingsProvider implementation="de.platon42.intellij.plugins.m68k.formatter.M68kAsmCodeStyleSettingsProvider"/>
|
<codeStyleSettingsProvider implementation="de.platon42.intellij.plugins.m68k.formatter.M68kAsmCodeStyleSettingsProvider"/>
|
||||||
<langCodeStyleSettingsProvider implementation="de.platon42.intellij.plugins.m68k.formatter.M68kLanguageCodeStyleSettingsProvider"/>
|
<langCodeStyleSettingsProvider implementation="de.platon42.intellij.plugins.m68k.formatter.M68kLanguageCodeStyleSettingsProvider"/>
|
||||||
<navbar implementation="de.platon42.intellij.plugins.m68k.navigation.M68kStructureAwareNavbar"/>
|
<navbar implementation="de.platon42.intellij.plugins.m68k.navigation.M68kStructureAwareNavbar"/>
|
||||||
|
@ -1,13 +1,32 @@
|
|||||||
moveq.l #10,d1
|
FOO = 1234
|
||||||
|
BAR = 1235
|
||||||
|
|
||||||
|
COUNTER SET COUNTER+1
|
||||||
|
|
||||||
|
FISH MACRO
|
||||||
|
.fish\@ rts
|
||||||
|
ENDM
|
||||||
|
MACRO SOUP
|
||||||
|
moveq.l #0,d0
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
; with space
|
||||||
|
|
||||||
|
; standalone comment
|
||||||
|
moveq.l #10,d1 ; end of line comment
|
||||||
|
FISH
|
||||||
add.l #10,d1
|
add.l #10,d1
|
||||||
subq.b #2,d2
|
SOUP
|
||||||
|
subq.b #2,d2 ; end of line comment
|
||||||
bra.s .foo
|
bra.s .foo
|
||||||
nop
|
nop
|
||||||
.foo move.l d2,d1
|
.foo move.l d2,d1
|
||||||
rts
|
rts
|
||||||
.verylonglabel: stop #$2000
|
.verylonglabel:
|
||||||
|
stop #$2000
|
||||||
|
|
||||||
.narf
|
.narf
|
||||||
moveq.l #2,d0
|
moveq.l #2,d0
|
||||||
|
|
||||||
globallabel: moveq.l #0,d0
|
globallabel:
|
||||||
|
moveq.l #0,d0
|
||||||
|
@ -1,6 +1,24 @@
|
|||||||
moveq.l #10,d1
|
FOO = 1234
|
||||||
|
BAR = 1235
|
||||||
|
|
||||||
|
COUNTER SET COUNTER+1
|
||||||
|
|
||||||
|
FISH MACRO
|
||||||
|
.fish\@ rts
|
||||||
|
ENDM
|
||||||
|
MACRO SOUP
|
||||||
|
moveq.l #0,d0
|
||||||
|
ENDM
|
||||||
|
|
||||||
|
; with space
|
||||||
|
|
||||||
|
; standalone comment
|
||||||
|
|
||||||
|
moveq.l #10,d1; end of line comment
|
||||||
|
FISH
|
||||||
add.l #10,d1
|
add.l #10,d1
|
||||||
subq.b #2,d2
|
SOUP
|
||||||
|
subq.b #2,d2 ; end of line comment
|
||||||
bra.s .foo
|
bra.s .foo
|
||||||
nop
|
nop
|
||||||
.foo move.l d2,d1
|
.foo move.l d2,d1
|
||||||
|
Loading…
Reference in New Issue
Block a user