Permalink
Browse files

Kotlin 1.1.61

  • Loading branch information...
ingokegel committed Nov 26, 2017
1 parent 4772bc1 commit e19b12a39547963688ce92d44e55db0efb8d77e5
Showing with 84 additions and 166 deletions.
  1. +1 −1 build.gradle
  2. +1 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserHistory.kt
  3. +5 −12 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserTab.kt
  4. +2 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserTabbedPane.kt
  5. +1 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserTreePane.kt
  6. +2 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/ClassAttributeHyperlinkListener.kt
  7. +2 −6 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/DetailPane.kt
  8. +2 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/FrameContent.kt
  9. +1 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/config/classpath/ClasspathBrowser.kt
  10. +2 −6 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/config/classpath/ClasspathEntry.kt
  11. +1 −5 ...rc/main/kotlin/org/gjt/jclasslib/browser/detail/attributes/BootstrapMethodsAttributeDetailPane.kt
  12. +1 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/detail/attributes/LinkRenderer.kt
  13. +2 −3 .../browser/src/main/kotlin/org/gjt/jclasslib/browser/detail/attributes/ModuleAttributeDetailPane.kt
  14. +1 −4 ...r/src/main/kotlin/org/gjt/jclasslib/browser/detail/attributes/StackMapTableAttributeDetailPane.kt
  15. +2 −3 ...es/browser/src/main/kotlin/org/gjt/jclasslib/browser/detail/attributes/code/ByteCodeDetailPane.kt
  16. +5 −12 modules/browser/src/main/kotlin/org/gjt/jclasslib/util/DnDTabbedPane.kt
  17. +1 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/util/MultiFileFilter.kt
  18. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/bytecode/PaddedInstruction.kt
  19. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/io/ClassFileReader.kt
  20. +2 −6 modules/data/src/main/kotlin/org/gjt/jclasslib/io/CountedInputStream.kt
  21. +4 −6 modules/data/src/main/kotlin/org/gjt/jclasslib/io/Jimage.kt
  22. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/AccessFlag.kt
  23. +3 −6 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/ClassFile.kt
  24. +2 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/FieldInfo.kt
  25. +2 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/MethodInfo.kt
  26. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/Package.kt
  27. +2 −6 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/Structure.kt
  28. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/InnerClassesAttribute.kt
  29. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/LineNumberTableAttribute.kt
  30. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/LocalVariableAttribute.kt
  31. +1 −3 ...les/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/SourceDebugExtensionAttribute.kt
  32. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/StackMapFrameEntry.kt
  33. +1 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/UnknownAttribute.kt
  34. +4 −6 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/VerificationType.kt
  35. +12 −15 modules/idea/src/main/kotlin/org/gjt/jclasslib/idea/Action.kt
  36. +11 −9 modules/idea/src/main/kotlin/org/gjt/jclasslib/idea/KotlinClassNameProvider.kt
View
@@ -7,7 +7,7 @@ buildDir = file('build/gradle')
ext.externalLibsDir = file("$buildDir/externalLibs")
buildscript {scriptHandler ->
ext.kotlinVersion = '1.1.50'
ext.kotlinVersion = '1.1.61'
repositories {
flatDir {
@@ -49,9 +49,7 @@ class BrowserHistory(private val services: BrowserServices) {
private var before: BrowserHistoryEntry? = null
override fun canUndo(): Boolean {
return before != null
}
override fun canUndo(): Boolean = before != null
override fun toString() = treePath.toString() + " / " + (resetter?.toString() ?: "null")
override fun addEdit(newEdit: UndoableEdit): Boolean {
@@ -27,7 +27,7 @@ import javax.swing.JOptionPane
import javax.swing.JPanel
import javax.swing.SwingUtilities
class BrowserTab(val fileName: String, val moduleName: String, frame : BrowserFrame) : JPanel(), BrowserServices {
class BrowserTab(val fileName: String, val moduleName: String, frame: BrowserFrame) : JPanel(), BrowserServices {
private val tabbedPane: BrowserTabbedPane
get() = SwingUtilities.getAncestorOfClass(BrowserTabbedPane::class.java, this) as BrowserTabbedPane
@@ -72,11 +72,7 @@ class BrowserTab(val fileName: String, val moduleName: String, frame : BrowserFr
}
}
private tailrec fun findClass(className: String): FindResult? {
val findResult: FindResult? = parentFrame.config.findClass(className, false)
return if (findResult != null) {
findResult
} else {
private tailrec fun findClass(className: String): FindResult? = parentFrame.config.findClass(className, false) ?:
if (GUIHelper.showOptionDialog(parentFrame,
"The class $className could not be found.\nYou can check your classpath configuration and try again.",
arrayOf("Setup classpath", "Cancel"),
@@ -86,8 +82,6 @@ class BrowserTab(val fileName: String, val moduleName: String, frame : BrowserFr
parentFrame.setupClasspathAction()
findClass(className)
}
}
}
init {
layout = BorderLayout()
@@ -115,7 +109,7 @@ class BrowserTab(val fileName: String, val moduleName: String, frame : BrowserFr
browserComponent.browserPath = browserPath
}
private fun readClassFile(frame : BrowserFrame): ClassFile {
private fun readClassFile(frame: BrowserFrame): ClassFile {
try {
return when {
fileName.startsWith(ClasspathJrtEntry.JRT_PREFIX) -> {
@@ -159,8 +153,7 @@ class BrowserTab(val fileName: String, val moduleName: String, frame : BrowserFr
private val ATTRIBUTE_FILE_NAME = "fileName"
private val ATTRIBUTE_MODULE_NAME = "moduleName"
fun create(element: Element, frame : BrowserFrame): BrowserTab {
return BrowserTab(element.getAttribute(ATTRIBUTE_FILE_NAME), element.getAttributeNode(ATTRIBUTE_MODULE_NAME)?.value ?: ClasspathEntry.UNNAMED_MODULE, frame)
}
fun create(element: Element, frame: BrowserFrame): BrowserTab =
BrowserTab(element.getAttribute(ATTRIBUTE_FILE_NAME), element.getAttributeNode(ATTRIBUTE_MODULE_NAME)?.value ?: ClasspathEntry.UNNAMED_MODULE, frame)
}
}
@@ -90,9 +90,8 @@ class BrowserTabbedPane(val container: FrameContent) : DnDTabbedPane() {
selectedTab?.browserComponent?.history?.updateActions()
}
override fun isDataFlavorSupported(transferable: Transferable): Boolean {
return transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)
}
override fun isDataFlavorSupported(transferable: Transferable): Boolean =
transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)
override fun handleDrop(event: DropTargetDropEvent) {
event.acceptDrop(DnDConstants.ACTION_COPY)
@@ -52,9 +52,7 @@ class BrowserTreePane(private val services: BrowserServices) : JPanel() {
val root: BrowserTreeNode
get() = tree.model.root as BrowserTreeNode
fun getPathForCategory(category: NodeType): TreePath {
return categoryToPath[category]!!
}
fun getPathForCategory(category: NodeType): TreePath = categoryToPath[category]!!
@Suppress("unused")
fun showMethod(methodName: String, methodSignature: String) {
@@ -34,8 +34,7 @@ class ClassAttributeHyperlinkListener(private val services: BrowserServices, pri
(detailPane.getDetailPane(attributeInfoClass) as TableDetailPane).selectIndex(index)
}
private fun findChildNode(attributesNode: BrowserTreeNode, attributeInfoClass: Class<out AttributeInfo>): BrowserTreeNode? {
return attributesNode.find { it.element?.let { it::class.java } == attributeInfoClass }
}
private fun findChildNode(attributesNode: BrowserTreeNode, attributeInfoClass: Class<out AttributeInfo>): BrowserTreeNode? =
attributesNode.find { it.element?.let { it::class.java } == attributeInfoClass }
}
@@ -51,13 +51,9 @@ abstract class DetailPane<out T : Any>(private val elementClass: Class<T>, val s
isUnderlined = true
}
fun getElement(treePath: TreePath): T {
return getElementOrNull(treePath)!!
}
fun getElement(treePath: TreePath): T = getElementOrNull(treePath)!!
fun getElementOrNull(treePath: TreePath): T? {
return elementClass.cast(treeNode(treePath).element)
}
fun getElementOrNull(treePath: TreePath): T? = elementClass.cast(treeNode(treePath).element)
fun treeNode(treePath: TreePath) = treePath.lastPathComponent as BrowserTreeNode
@@ -123,9 +123,8 @@ class FrameContent(val frame: BrowserFrame) : JPanel() {
wrappers[targetPosition].transferTabsFrom(wrappers[sourcePosition])
}
fun findTab(fileName: String): BrowserTab? {
return wrappers.flatMap { it.tabbedPane.tabs() }.firstOrNull { it.fileName == fileName }
}
fun findTab(fileName: String): BrowserTab? =
wrappers.flatMap { it.tabbedPane.tabs() }.firstOrNull { it.fileName == fileName }
val totalTabCount: Int
get() = wrappers.sumBy { it.tabbedPane.tabs().count() }
@@ -217,7 +217,5 @@ class ClasspathBrowser(private val frame: BrowserFrame, title: String, private v
private fun getModel(reset: Boolean, tree: JTree) = if (reset) DefaultTreeModel(ClassTreeNode()) else tree.model as DefaultTreeModel
private fun getSelectedTree(): JTree {
return trees[tabbedPane.selectedIndex]
}
private fun getSelectedTree(): JTree = trees[tabbedPane.selectedIndex]
}
@@ -32,9 +32,7 @@ abstract class ClasspathEntry(fileName : String) : ClasspathComponent {
return file == other.file
}
override fun hashCode(): Int {
return file.hashCode()
}
override fun hashCode(): Int = file.hashCode()
// classpath entries are immutable
override fun addClasspathChangeListener(listener: ClasspathChangeListener) {
@@ -71,9 +69,7 @@ abstract class ClasspathEntry(fileName : String) : ClasspathComponent {
return newNode
}
protected fun String.stripClassSuffix(): String {
return this.substring(0, this.length - CLASSFILE_SUFFIX.length)
}
protected fun String.stripClassSuffix(): String = this.substring(0, this.length - CLASSFILE_SUFFIX.length)
protected fun addEntry(path: String, moduleName: String?, classPathModel: DefaultTreeModel, modulePathModel: DefaultTreeModel, reset: Boolean) {
val pathComponents = path.stripClassSuffix().replace('\\', '/').split(Regex("/"))
@@ -35,15 +35,11 @@ class BootstrapMethodsAttributeDetailPane(services: BrowserServices) : TableDeta
override fun getConstantPoolIndex(row: BootstrapMethodsEntry) = row.methodRefIndex
})
add(object : StringColumn<BootstrapMethodsEntry>("Arguments", 400) {
override fun createValue(row: BootstrapMethodsEntry): String {
return row.verbose.replace("\n", "<br>")
}
override fun createValue(row: BootstrapMethodsEntry): String = row.verbose.replace("\n", "<br>")
override fun createTableCellRenderer() = createTableCellEditor()
override fun createTableCellEditor() = MultiLineHtmlCellHandler { description ->
ConstantPoolHyperlinkListener.link(services, Integer.parseInt(description))
}
override fun isEditable(row: BootstrapMethodsEntry) = true
})
}
@@ -54,7 +54,5 @@ class LinkRenderer : TableCellRenderer {
}
}
fun isLinkLabelHit(point: Point): Boolean {
return linkLineRenderer.bounds.contains(point)
}
fun isLinkLabelHit(point: Point): Boolean = linkLineRenderer.bounds.contains(point)
}
@@ -22,9 +22,8 @@ class ModuleAttributeDetailPane(services: BrowserServices) : DocumentDetailPane<
override fun createKeyValueDetailPane() = ModuleAttributeValueDetailPane()
override fun createDocument(styles: StyleContext, attribute: ModuleAttribute, classFile: ClassFile): ModuleDocument {
return ModuleDocument(styles, attribute, classFile)
}
override fun createDocument(styles: StyleContext, attribute: ModuleAttribute, classFile: ClassFile): ModuleDocument =
ModuleDocument(styles, attribute, classFile)
override fun offsetToPosition(offset: Int): Int = offset
@@ -35,10 +35,7 @@ class StackMapTableAttributeDetailPane(services: BrowserServices) : TableDetailP
override fun createTableCellEditor() = MultiLineHtmlCellHandler { description ->
ConstantPoolHyperlinkListener.link(services, Integer.parseInt(description))
}
override fun isEditable(row: StackMapFrameEntry): Boolean {
return true
}
override fun isEditable(row: StackMapFrameEntry): Boolean = true
})
}
}
@@ -23,9 +23,8 @@ class ByteCodeDetailPane(services: BrowserServices, private val codeAttributeDet
name = "Bytecode"
}
override fun createDocument(styles: StyleContext, attribute: CodeAttribute, classFile: ClassFile): ByteCodeDocument {
return ByteCodeDocument(styles, attribute, services.classFile)
}
override fun createDocument(styles: StyleContext, attribute: CodeAttribute, classFile: ClassFile): ByteCodeDocument =
ByteCodeDocument(styles, attribute, services.classFile)
override fun offsetToPosition(offset: Int) = attributeDocument.getPosition(offset)
@@ -16,14 +16,13 @@ import java.awt.image.BufferedImage
import java.util.*
import javax.swing.*
@Suppress("RedundantOverride")
open class DnDTabbedPane : JTabbedPane() {
private val glassPane : GhostGlassPane by lazy { createOrGetGlassPane(rootPane) }
val tabAcceptor: TabAcceptor = object : TabAcceptor {
override fun isDropAcceptable(tabbedPane: DnDTabbedPane, index: Int): Boolean {
return true
}
override fun isDropAcceptable(tabbedPane: DnDTabbedPane, index: Int): Boolean = true
}
init {
@@ -143,9 +142,7 @@ open class DnDTabbedPane : JTabbedPane() {
return if (r.contains(point)) tabCount else -1
}
private fun getFirstVisibleTabBound(): Rectangle? {
return getNextVisibleTabBound(-1)
}
private fun getFirstVisibleTabBound(): Rectangle? = getNextVisibleTabBound(-1)
private fun getNextVisibleTabBound(index: Int): Rectangle? {
for (i in index + 1 until tabCount) {
@@ -161,15 +158,11 @@ open class DnDTabbedPane : JTabbedPane() {
return null
}
private fun getLastVisibleTabBound(): Rectangle? {
return getPreviousVisibleTabBound(tabCount)
}
private fun getLastVisibleTabBound(): Rectangle? = getPreviousVisibleTabBound(tabCount)
// Nullable return value is important because tabs will be hidden for tab overflow
// and the bounds of such tabs are null
override fun getBoundsAt(index: Int): Rectangle? {
return super.getBoundsAt(index)
}
override fun getBoundsAt(index: Int): Rectangle? = super.getBoundsAt(index)
private fun convertTab(data: TabTransferData, targetIndex: Int) {
val source = data.tabbedPane
@@ -29,8 +29,6 @@ class MultiFileFilter(private val extensions: List<String>, description: String)
file.name.endsWith(extension)
}
override fun getDescription(): String {
return description
}
override fun getDescription(): String = description
}
@@ -22,9 +22,7 @@ open class PaddedInstruction(opcode: Opcode) : Instruction(opcode) {
* @param offset the offset at which this instruction is found.
* @return the padded size in bytes
*/
fun getPaddedSize(offset: Int): Int {
return size + paddingBytes(offset + 1)
}
fun getPaddedSize(offset: Int): Int = size + paddingBytes(offset + 1)
override fun read(input: ByteCodeInput) {
super.read(input)
@@ -62,9 +62,7 @@ object ClassFileReader {
*/
@Throws(InvalidByteCodeException::class, IOException::class)
@JvmStatic
fun readFromFile(file: File): ClassFile {
return readFromInputStream(FileInputStream(file))
}
fun readFromFile(file: File): ClassFile = readFromInputStream(FileInputStream(file))
/**
* Converts a class file to a ClassFile structure.
@@ -31,9 +31,7 @@ class CountedInputStream(input: InputStream) : FilterInputStream(input) {
}
@Throws(IOException::class)
override fun read(b: ByteArray): Int {
return read(b, 0, b.size)
}
override fun read(b: ByteArray): Int = read(b, 0, b.size)
@Throws(IOException::class)
override fun read(b: ByteArray, offset: Int, len: Int): Int {
@@ -51,7 +49,5 @@ class CountedInputStream(input: InputStream) : FilterInputStream(input) {
}
// Marking invalidates bytesRead
override fun markSupported(): Boolean {
return false
}
override fun markSupported(): Boolean = false
}
@@ -23,18 +23,16 @@ private val classFileSuffix = ".class"
* @param fileName the file name to the class file in the JRT, including the module
* @param jreHome the home directory of the JRE
*/
fun getJrtInputStream(fileName: String, jreHome: File): InputStream {
return Files.newInputStream(getModulesRoot(jreHome).resolve(fileName))
}
fun getJrtInputStream(fileName: String, jreHome: File): InputStream =
Files.newInputStream(getModulesRoot(jreHome).resolve(fileName))
/**
* Find a class with a prepended module name in the JRT (Java 9+)
* @param moduleNameAndClassName the module name and the class name, separated by a slash
* @param jreHome the home directory of the JRE
*/
fun findClassWithModuleNameInJrt(moduleNameAndClassName: String, jreHome: File): Path? {
return getModulesRoot(jreHome).resolve(moduleNameAndClassName + classFileSuffix)
}
fun findClassWithModuleNameInJrt(moduleNameAndClassName: String, jreHome: File): Path? =
getModulesRoot(jreHome).resolve(moduleNameAndClassName + classFileSuffix)
/**
* Find a class in the JRT (Java 9+)
* @param className the class name
@@ -79,9 +79,7 @@ enum class AccessFlag(val flag: Int, val verbose: String) {
/** Checks if this access flag is set in the supplied access flags.
* @param accessFlags the access flags
*/
fun isSet(accessFlags: Int): Boolean {
return accessFlags and flag == flag
}
fun isSet(accessFlags: Int): Boolean = accessFlags and flag == flag
override fun toString() = verbose
@@ -95,9 +95,7 @@ class ClassFile : Structure(), AttributeContainer {
*
* @param constant the constant pool entry
*/
fun getConstantPoolIndex(constant: Constant): Int {
return constantPoolEntryToIndex[constant] ?: -1
}
fun getConstantPoolIndex(constant: Constant): Int = constantPoolEntryToIndex[constant] ?: -1
/**
* Set all constant pool entries where the new array
@@ -169,9 +167,8 @@ class ClassFile : Structure(), AttributeContainer {
* @param index the index
*/
@Throws(InvalidByteCodeException::class)
fun getConstantPoolUtf8Entry(index: Int): ConstantUtf8Info {
return getConstantPoolEntry(index, ConstantUtf8Info::class.java)
}
fun getConstantPoolUtf8Entry(index: Int): ConstantUtf8Info =
getConstantPoolEntry(index, ConstantUtf8Info::class.java)
/**
* Get the constant pool entry at the specified index and cast it to a specified class.
@@ -12,8 +12,7 @@ package org.gjt.jclasslib.structures
*/
class FieldInfo(classFile: ClassFile) : ClassMember(classFile) {
override fun formatAccessFlagsVerbose(accessFlags: Int): String {
return formatAccessFlagsVerbose(AccessFlag.FIELD_ACCESS_FLAGS, accessFlags)
}
override fun formatAccessFlagsVerbose(accessFlags: Int): String =
formatAccessFlagsVerbose(AccessFlag.FIELD_ACCESS_FLAGS, accessFlags)
}
Oops, something went wrong.

0 comments on commit e19b12a

Please sign in to comment.