Skip to content

Commit

Permalink
Merge pull request #39 from marcelkliemannel/develop
Browse files Browse the repository at this point in the history
4.2.0
  • Loading branch information
marcelkliemannel authored Apr 11, 2024
2 parents d6b83e6 + d3befc4 commit 7168170
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 33 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@

### Fixed

## 4.2.0 - 2024-04-11

### Added

- Support for Java 23 with ASM 9.7

### Changed

- Lower minimum IntelliJ version to 2023.2 to support Android Studio

## 4.1.0 - 2023-12-25

### Changed
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Class files can be opened directly from the tool window or the "Analyze Byte Cod

If the editor is the origin of the action execution, the analyzer will pick the class relative to the current cursor position. With this, it is easy to analyze inner, locale, or anonymous classes.

The plugin currently uses [ASM 9.6](https://asm.ow2.io) under the hood, supporting JVM class files up to version 22.
The plugin currently uses [ASM 9.7](https://asm.ow2.io) under the hood, supporting JVM class files up to version 23.

## Features

Expand Down Expand Up @@ -91,8 +91,8 @@ If you want to contribute something, please follow the code style in the `.edito
To update the bundled ASM library:

- Set the new version in the main `build.gradle.kts`. (The new bundled ASM library should automatically be created or execute the Gradle task `shadowAsmJar`.)
- Update the globally defined ASM API version in: `dev.turingcomplete.intellijbytecodeplugin._ui.DefaultClassFileContext.ASM_API`.
- Set the new version in the description block of the `plugin.xml` and in the `README.md`.
- Update the globally defined ASM API version in `dev.turingcomplete.intellijbytecodeplugin._ui.DefaultClassFileContext.ASM_API` to the highest available version.
- Set the new ASM version and latest supported Java version in the description block of the `plugin.xml` and in the `README.md`.
- New supported Java versions must be added to the field: `dev.turingcomplete.intellijbytecodeplugin.bytecode.ClassVersionUtils.CLASS_VERSIONS`.

### Extension Points
Expand Down Expand Up @@ -133,7 +133,7 @@ Some tests are testing the parsing of the structure tree and the constant pool a

## License

Copyright (c) 2022 Marcel Kliemannel
Copyright (c) 2024 Marcel Kliemannel

Licensed under the **Apache License, Version 2.0** (the "License"); you may not use this file except in compliance with the License.

Expand Down
11 changes: 7 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.INVALID_P
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.MISSING_DEPENDENCIES
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.NON_EXTENDABLE_API_USAGES
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.OVERRIDE_ONLY_API_USAGES
import org.jetbrains.intellij.tasks.RunPluginVerifierTask.FailureLevel.SCHEDULED_FOR_REMOVAL_API_USAGES

fun properties(key: String) = project.findProperty(key).toString()

Expand All @@ -27,24 +26,29 @@ repositories {
}

val asm: Configuration by configurations.creating
val asmVersion = "9.7"

val shadowAsmJar = tasks.create("shadowAsmJar", com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar::class) {
group = "shadow"
relocate("org.objectweb.asm", "dev.turingcomplete.intellijbytecodeplugin.org.objectweb.asm")
configurations = listOf(asm)
archiveClassifier.set("asm")
exclude { file -> file.name == "module-info.class" }
manifest {
attributes("Asm-Version" to asmVersion)
}
}

dependencies {
api(shadowAsmJar.outputs.files)

val asmVersion = "9.6"
asm("org.ow2.asm:asm:$asmVersion")
asm("org.ow2.asm:asm-analysis:$asmVersion")
asm("org.ow2.asm:asm-util:$asmVersion")
asm("org.ow2.asm:asm-commons:$asmVersion")

implementation("org.apache.commons:commons-text:1.11.0")

testImplementation("org.assertj:assertj-core:3.24.2")

val jUnit5Version = "5.10.1"
Expand Down Expand Up @@ -88,8 +92,7 @@ tasks {
failureLevel.set(
listOf(
COMPATIBILITY_PROBLEMS, INTERNAL_API_USAGES, NON_EXTENDABLE_API_USAGES,
OVERRIDE_ONLY_API_USAGES, MISSING_DEPENDENCIES, SCHEDULED_FOR_REMOVAL_API_USAGES,
INVALID_PLUGIN
OVERRIDE_ONLY_API_USAGES, MISSING_DEPENDENCIES, INVALID_PLUGIN
)
)
}
Expand Down
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pluginGroup=dev.turingcomplete
pluginVersion=4.1.0
pluginSinceBuild=233
pluginVersion=4.2.0
pluginSinceBuild=232
pluginUntilBuild=
# LATEST-EAP-SNAPSHOT
platformType=IC
# LATEST-EAP-SNAPSHOT
platformVersion=2023.3
platformDownloadSources=true
pluginVerifierIdeVersions=2023.3
pluginVerifierIdeVersions=2023.2,2023.3,2024.1
platformPlugins=com.intellij.java,org.jetbrains.kotlin

# Opt-out flag for bundling Kotlin standard library.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ object ClassVersionUtils {
// -- Properties -------------------------------------------------------------------------------------------------- //

val CLASS_VERSIONS = arrayOf(
ClassVersion(Opcodes.V23.toByte(), "Java SE 23"),
ClassVersion(Opcodes.V22.toByte(), "Java SE 22"),
ClassVersion(Opcodes.V21.toByte(), "Java SE 21"),
ClassVersion(Opcodes.V20.toByte(), "Java SE 20"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ internal class AccessConverterTool : ByteCodeTool("Access Converter", AllIcons.N
return JPanel(GridBagLayout()).apply {
border = IdeBorderFactory.createTitledBorder("Access Calculators")

val accessGroups = AccessGroup.values()
val accessGroups = AccessGroup.entries.toTypedArray()

val bag = GridBag().withCommonsDefaults()
.setDefaultFill(GridBagConstraints.BOTH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import com.intellij.util.concurrency.InvokerSupplier
import com.intellij.util.ui.EmptyIcon
import com.intellij.util.ui.UIUtil
import com.intellij.util.ui.tree.TreeUtil
import dev.turingcomplete.intellijbytecodeplugin._ui.ToggleActionButton
import dev.turingcomplete.intellijbytecodeplugin._ui.CopyValueAction
import dev.turingcomplete.intellijbytecodeplugin._ui.ToggleActionButton
import dev.turingcomplete.intellijbytecodeplugin._ui.UiUtils.Table.createContextMenuMouseListener
import dev.turingcomplete.intellijbytecodeplugin._ui.ViewValueAction
import dev.turingcomplete.intellijbytecodeplugin._ui.configureForCell
Expand Down Expand Up @@ -157,7 +157,7 @@ internal class StructureTree(classFileContext: ClassFileContext, parent: Disposa
BaseTreeModel<TreeNode>(), InvokerSupplier {

var rootNode: ClassStructureNode? = null
private val myInvoker = Invoker.forBackgroundThreadWithoutReadAction(this)
private val invoker = Invoker.forBackgroundThreadWithoutReadAction(this)

override fun getRoot(): ClassStructureNode {
if (rootNode == null) {
Expand All @@ -181,7 +181,7 @@ internal class StructureTree(classFileContext: ClassFileContext, parent: Disposa
treeStructureChanged(null, null, null)
}

override fun getInvoker(): Invoker = myInvoker
override fun getInvoker(): Invoker = invoker

private fun createRootNode(): ClassStructureNode {
return ClassStructureNode(classFileContext.classNode(), classFileContext.classFile())
Expand All @@ -198,7 +198,7 @@ internal class StructureTree(classFileContext: ClassFileContext, parent: Disposa
}

override fun getTreeCellRendererComponent(tree: JTree, value: Any, selected: Boolean, expanded: Boolean, leaf: Boolean, row: Int, hasFocus: Boolean): Component {
tree.rowHeight = 0 // Will use height of component
tree.rowHeight = 0 // Will use the height of component

return when (value) {
is LoadingNode -> loadingNodeLabel
Expand Down Expand Up @@ -245,7 +245,7 @@ internal class StructureTree(classFileContext: ClassFileContext, parent: Disposa
init {
templatePresentation.icon = AllIcons.Actions.Edit

TypeUtils.TypeNameRenderMode.values().forEach {
TypeUtils.TypeNameRenderMode.entries.forEach {
add(ToggleActionButton(it.title, { context.typeNameRenderMode = it }, { context.typeNameRenderMode == it }))
}

Expand All @@ -256,7 +256,7 @@ internal class StructureTree(classFileContext: ClassFileContext, parent: Disposa

addSeparator()

MethodDeclarationUtils.MethodDescriptorRenderMode.values().forEach {
MethodDeclarationUtils.MethodDescriptorRenderMode.entries.forEach {
add(ToggleActionButton(it.title, { context.methodDescriptorRenderMode = it }, { context.methodDescriptorRenderMode == it }))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,23 @@ internal abstract class StructureNode(val goToProvider: GoToProvider? = null)
// No children to load
false
}

asyncAddChildrenInExecution.getAndSet(true) -> {
// Already in progress
true
}

else -> {
// Load children
if (workAsync) {
ApplicationManager.getApplication().executeOnPooledThread {
asyncAddChildren!!()
asyncAddChildren = null
asyncAddChildrenInExecution.set(false)
try {
asyncAddChildren!!()
}
finally {
asyncAddChildren = null
asyncAddChildrenInExecution.set(false)
}
}
true
}
Expand Down Expand Up @@ -125,10 +131,14 @@ internal abstract class StructureNode(val goToProvider: GoToProvider? = null)
}

fun addAccessNode(access: Int, accessGroup: AccessGroup) {
add(HtmlTextNode("Access:",
{ ctx -> if (ctx.showAccessAsHex) "0x${Integer.toHexString(access).uppercase(Locale.getDefault())}" else access.toString() },
postFix = "<span class=\"contextHelp\">${accessGroup.toReadableAccess(access).joinToString(", ")}</span>",
icon = AllIcons.Nodes.RwAccess))
add(
HtmlTextNode(
"Access:",
{ ctx -> if (ctx.showAccessAsHex) "0x${Integer.toHexString(access).uppercase(Locale.getDefault())}" else access.toString() },
postFix = "<span class=\"contextHelp\">${accessGroup.toReadableAccess(access).joinToString(", ")}</span>",
icon = AllIcons.Nodes.RwAccess
)
)
}

fun addSignatureNode(signature: String?) {
Expand Down Expand Up @@ -179,14 +189,16 @@ internal abstract class StructureNode(val goToProvider: GoToProvider? = null)
private fun createAnnotationNode(annotation: AnnotationNode, postFix: String? = null): StructureNode {
val values = annotation.values?.let { values ->
generateSequence(0) { if ((it + 2) < values.size) it + 2 else null }
.map { "${values[it]} = ${formatAnnotationValue(values[it + 1])}" }
.joinToString(", ", prefix = "(", postfix = ")")
.map { "${values[it]} = ${formatAnnotationValue(values[it + 1])}" }
.joinToString(", ", prefix = "(", postfix = ")")
} ?: ""
val internalName = Type.getType(annotation.desc).internalName
return HtmlTextNode(displayValue = { ctx -> TypeUtils.toReadableName(internalName, ctx.typeNameRenderMode) + values },
postFix = postFix,
icon = AllIcons.Nodes.Annotationtype,
goToProvider = GoToProvider.Class(internalName))
return HtmlTextNode(
displayValue = { ctx -> TypeUtils.toReadableName(internalName, ctx.typeNameRenderMode) + values },
postFix = postFix,
icon = AllIcons.Nodes.Annotationtype,
goToProvider = GoToProvider.Class(internalName)
)
}

private fun formatAnnotationValue(value: Any?): String {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<vendor email="dev@marcelkliemannel.com" url="https://marcelkliemannel.com/projects/intellij-byte-code-plugin">Marcel Kliemannel</vendor>

<description><![CDATA[
<p>This IntelliJ plugin provides a modern and powerful tool window to analyze byte code. Its supports Java, Kotlin, Groovy, and other JVM language class files. Based on ASM 9.6, it currently supports class files up to Java 22.</p>
<p>This IntelliJ plugin provides a modern and powerful tool window to analyze byte code. Its supports Java, Kotlin, Groovy, and other JVM language class files. Based on ASM 9.7, it currently supports class files up to Java 23.</p>
<h2>Features</h2>
Expand Down

0 comments on commit 7168170

Please sign in to comment.