Documentation for instruction with special register shows specific register expected.

This commit is contained in:
2021-09-05 18:42:20 +02:00
parent 665947827b
commit 1bff1a12c2
4 changed files with 19 additions and 6 deletions
@@ -92,8 +92,8 @@ class M68kInstructionDocumentationProvider : AbstractDocumentationProvider() {
val cellsPerRow = ArrayList<HtmlChunk>(3)
cellsPerRow.add(contentBuilder.toFragment())
if (allowedAdrMode.op1 != null) cellsPerRow.add(collectAddressModes(allowedAdrMode.op1))
if (allowedAdrMode.op1 != null) cellsPerRow.add(collectAddressModes(allowedAdrMode.op2))
if (allowedAdrMode.op1 != null) cellsPerRow.add(collectAddressModes(allowedAdrMode.op1, allowedAdrMode.specialReg))
if (allowedAdrMode.op1 != null) cellsPerRow.add(collectAddressModes(allowedAdrMode.op2, allowedAdrMode.specialReg))
addressModeInfoRows.append(HtmlChunk.tag("tr").children(cellsPerRow.map { it.wrapWith(DocumentationMarkup.SECTION_CONTENT_CELL) }))
addressModeInfoRows.toFragment()
@@ -126,11 +126,12 @@ class M68kInstructionDocumentationProvider : AbstractDocumentationProvider() {
return defBuilder
}
private fun collectAddressModes(addressModes: Set<AddressMode>?): HtmlChunk {
private fun collectAddressModes(addressModes: Set<AddressMode>?, specialReg: String?): HtmlChunk {
if (addressModes == null) return HtmlChunk.text("")
val modes = HtmlBuilder()
addressModes.sortedBy(AddressMode::ordinal)
.forEach { modes.append(HtmlChunk.text(it.syntax).wrapWith(HtmlChunk.div())) }
.map { if (it == AddressMode.SPECIAL_REGISTER_DIRECT) specialReg!! else it.syntax }
.forEach { modes.append(HtmlChunk.text(it).wrapWith(HtmlChunk.div())) }
return modes.toFragment()
}
@@ -108,6 +108,16 @@ internal class M68kInstructionDocumentationProviderTest : AbstractDocumentationP
assertThat(generateDocumentation(myFixture)).contains("Reset External Devices", "(privileged)")
}
@Test
internal fun check_documentation_for_instruction_with_special_register(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(
"documentme.asm", """
<caret>move.l usp,a0
"""
)
assertThat(generateDocumentation(myFixture)).contains("<div>usp</div>")
}
@Test
internal fun check_documentation_if_there_is_no_concrete_match(@MyFixture myFixture: CodeInsightTestFixture) {
myFixture.configureByText(