Skip to content

Commit d1dd6e0

Browse files
committed
Cleanup
1 parent e431170 commit d1dd6e0

File tree

4 files changed

+44
-30
lines changed

4 files changed

+44
-30
lines changed

src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/DependencyCache.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package dev.romainguy.kotlin.explorer
1717

1818
import java.io.FileNotFoundException
19+
import java.net.URI
1920
import java.net.URL
2021
import java.nio.file.Path
2122
import java.nio.file.StandardOpenOption.*
@@ -58,7 +59,7 @@ class DependencyCache(private val root: Path) {
5859
private fun getDependency(repo: String, basePath: String, dst: Path, onOutput: (String) -> Unit): Boolean {
5960
try {
6061
// Does the artifact exist in repo?
61-
URL("$repo/$basePath.pom").openStream().reader().close()
62+
URI("$repo/$basePath.pom").toURL().openStream().reader().close()
6263
} catch (_: FileNotFoundException) {
6364
return false
6465
}

src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/Disassembly.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ suspend fun buildAndRun(
6767
Files.writeString(path, source)
6868
writeSupportFiles(directory)
6969

70-
val kotlinc = KotlinCompiler(toolPaths, settingsDirectory, directory).compile(kotlinOnlyConsumers, compilerFlags, composeVersion, path)
70+
val kotlinc = KotlinCompiler(toolPaths, settingsDirectory, directory).compile(
71+
kotlinOnlyConsumers,
72+
compilerFlags,
73+
composeVersion,
74+
path
75+
)
7176

7277
if (kotlinc.exitCode != 0) {
7378
withContext(ui) {
@@ -131,7 +136,12 @@ suspend fun buildAndDisassemble(
131136
Files.writeString(path, source)
132137
writeSupportFiles(directory)
133138

134-
val kotlinc = KotlinCompiler(toolPaths, settingsDirectory, directory).compile(kotlinOnlyConsumers, compilerFlags, composeVersion, path)
139+
val kotlinc = KotlinCompiler(toolPaths, settingsDirectory, directory).compile(
140+
kotlinOnlyConsumers,
141+
compilerFlags,
142+
composeVersion,
143+
path
144+
)
135145

136146
if (kotlinc.exitCode != 0) {
137147
updater.addJob(launch(ui) {

src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/KotlinExplorer.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
@file:Suppress("FunctionName")
17+
@file:Suppress("FunctionName", "UnstableApiUsage")
1818
@file:OptIn(ExperimentalJewelApi::class)
1919

2020
package dev.romainguy.kotlin.explorer
@@ -58,8 +58,11 @@ import androidx.compose.ui.window.*
5858
import androidx.compose.ui.window.WindowPosition.Aligned
5959
import dev.romainguy.kotlin.explorer.Shortcut.*
6060
import dev.romainguy.kotlin.explorer.code.*
61+
import kotlinx.coroutines.CoroutineDispatcher
6162
import kotlinx.coroutines.CoroutineScope
63+
import kotlinx.coroutines.Dispatchers
6264
import kotlinx.coroutines.launch
65+
import kotlinx.coroutines.withContext
6366
import org.fife.rsta.ui.search.FindDialog
6467
import org.fife.rsta.ui.search.SearchEvent
6568
import org.fife.rsta.ui.search.SearchListener
@@ -153,7 +156,9 @@ private class UiState(val explorerState: ExplorerState, scope: CoroutineScope, w
153156
val dexTextArea = dexTextArea(explorerState, focusTracker, sourceTextArea)
154157
val oatTextArea = oatTextArea(explorerState, focusTracker) { code, line, _ ->
155158
scope.launch {
156-
val blocks = markdownProcessor.generateInlineDocumentation(code, line)
159+
val blocks = withContext(Dispatchers.Default) {
160+
markdownProcessor.generateInlineDocumentation(code, line)
161+
}
157162
if (blocks.isNotEmpty()) markdownBlocks = blocks
158163
}
159164
}

src/jvmMain/kotlin/dev/romainguy/kotlin/explorer/code/Documentation.kt

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*/
1616

1717
@file:OptIn(ExperimentalJewelApi::class)
18+
@file:Suppress("UnstableApiUsage")
1819

1920
package dev.romainguy.kotlin.explorer.code
2021

22+
import androidx.collection.ScatterMap
2123
import androidx.collection.mutableScatterMapOf
22-
import kotlinx.coroutines.Dispatchers
23-
import kotlinx.coroutines.withContext
2424
import org.jetbrains.jewel.foundation.ExperimentalJewelApi
2525
import org.jetbrains.jewel.markdown.InlineMarkdown
2626
import org.jetbrains.jewel.markdown.MarkdownBlock
@@ -41,41 +41,39 @@ private val Conditions = mutableScatterMapOf(
4141
"lt" to "signed less than.",
4242
"gt" to "signed greater than.",
4343
"le" to "signed less than or equal."
44-
)
44+
) as ScatterMap<String, String>
4545

46-
suspend fun MarkdownProcessor.generateInlineDocumentation(code: Code, line: Int): List<MarkdownBlock> {
46+
fun MarkdownProcessor.generateInlineDocumentation(code: Code, line: Int): List<MarkdownBlock> {
4747
if (code.isa == ISA.Aarch64) {
4848
val fullOp = code.instructions[line]?.op ?: ""
4949
val op = fullOp.substringBefore('.')
5050
val opDocumentation = Aarch64Docs[op]
5151
if (opDocumentation != null) {
52-
return withContext(Dispatchers.Default) {
53-
val blocks = ArrayList<MarkdownBlock>()
54-
blocks += MarkdownBlock.Heading(2, InlineMarkdown.Text(opDocumentation.name))
52+
val blocks = ArrayList<MarkdownBlock>()
53+
blocks += MarkdownBlock.Heading(2, InlineMarkdown.Text(opDocumentation.name))
5554

56-
val condition = fullOp.substringAfter('.', "")
57-
if (condition.isNotEmpty()) {
58-
val conditionDocumentation = Conditions[condition]
59-
if (conditionDocumentation != null) {
60-
blocks += MarkdownBlock.Paragraph(
61-
InlineMarkdown.StrongEmphasis("**", InlineMarkdown.Text("Condition: ")),
62-
InlineMarkdown.Text(conditionDocumentation)
63-
)
64-
}
55+
val condition = fullOp.substringAfter('.', "")
56+
if (condition.isNotEmpty()) {
57+
val conditionDocumentation = Conditions[condition]
58+
if (conditionDocumentation != null) {
59+
blocks += MarkdownBlock.Paragraph(
60+
InlineMarkdown.StrongEmphasis("**", InlineMarkdown.Text("Condition: ")),
61+
InlineMarkdown.Text(conditionDocumentation)
62+
)
6563
}
64+
}
6665

67-
blocks += processMarkdownDocument(opDocumentation.documentation)
66+
blocks += processMarkdownDocument(opDocumentation.documentation)
6867

69-
blocks += MarkdownBlock.Paragraph(
70-
InlineMarkdown.Link(
71-
opDocumentation.url,
72-
"See full documentation",
73-
InlineMarkdown.Text("See full documentation")
74-
)
68+
blocks += MarkdownBlock.Paragraph(
69+
InlineMarkdown.Link(
70+
opDocumentation.url,
71+
"See full documentation",
72+
InlineMarkdown.Text("See full documentation")
7573
)
74+
)
7675

77-
blocks
78-
}
76+
return blocks
7977
}
8078
}
8179
return emptyList()

0 commit comments

Comments
 (0)