Permalink
Browse files

Kotlin 1.1.50

  • Loading branch information...
ingokegel committed Sep 24, 2017
1 parent 9eebc4b commit f1c069fd19a4cc27c082fbe843d10817065c9fa9
Showing with 102 additions and 110 deletions.
  1. +1 −4 build.gradle
  2. +1 −1 gradle/wrapper/gradle-wrapper.properties
  3. +3 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserAboutDialog.kt
  4. +11 −12 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserFrame.kt
  5. +3 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserNodeTransferHandler.kt
  6. +4 −4 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserTab.kt
  7. +3 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/BrowserTreePane.kt
  8. +5 −5 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/Main.kt
  9. +1 −1 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/config/classpath/ClasspathBrowser.kt
  10. +3 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/config/classpath/ClasspathEntry.kt
  11. +3 −4 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/config/classpath/ClasspathSetupDialog.kt
  12. +1 −1 modules/browser/src/main/kotlin/org/gjt/jclasslib/browser/detail/TableDetailPane.kt
  13. +1 −1 ...browser/src/main/kotlin/org/gjt/jclasslib/browser/detail/attributes/document/AttributeDocument.kt
  14. +10 −10 modules/browser/src/main/kotlin/org/gjt/jclasslib/util/DnDTabbedPane.kt
  15. +3 −3 modules/browser/src/main/kotlin/org/gjt/jclasslib/util/HtmlDisplayTextArea.kt
  16. +3 −1 modules/data/data.gradle
  17. +3 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/bytecode/ImmediateByteInstruction.kt
  18. +1 −1 modules/data/src/main/kotlin/org/gjt/jclasslib/bytecode/LookupSwitchInstruction.kt
  19. +1 −1 modules/data/src/main/kotlin/org/gjt/jclasslib/bytecode/PaddedInstruction.kt
  20. +1 −1 modules/data/src/main/kotlin/org/gjt/jclasslib/bytecode/TableSwitchInstruction.kt
  21. +4 −4 modules/data/src/main/kotlin/org/gjt/jclasslib/io/Jimage.kt
  22. +4 −4 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/Lookup.kt
  23. +2 −2 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/TypeAnnotationTargetType.kt
  24. +3 −3 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/UnknownAttribute.kt
  25. +1 −1 modules/data/src/main/kotlin/org/gjt/jclasslib/structures/attributes/VerificationType.kt
  26. +2 −2 modules/idea/idea.gradle
  27. +8 −8 modules/idea/src/main/kotlin/org/gjt/jclasslib/idea/ClassFileLocation.kt
  28. +3 −3 modules/idea/src/main/kotlin/org/gjt/jclasslib/idea/KotlinClassNameProvider.kt
  29. +13 −18 modules/idea/src/main/kotlin/org/gjt/jclasslib/idea/ToolWindow.kt
View
@@ -7,10 +7,7 @@ buildDir = file('build/gradle')
ext.externalLibsDir = file("$buildDir/externalLibs")
buildscript {scriptHandler ->
ext.kotlinVersion = '1.1.4-2'
String[] kotlinVersionParts = kotlinVersion.split('-')
ext.kotlinVersionMain = kotlinVersionParts[0]
ext.kotlinVersionHotfix = kotlinVersionParts.length > 1 ? "-${kotlinVersionParts[1]}" : '-1'
ext.kotlinVersion = '1.1.50'
repositories {
flatDir {
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2-all.zip
@@ -56,10 +56,10 @@ class BrowserAboutDialog(parent: JFrame) : JDialog(parent) {
}
private fun getVersion(): String {
try {
return Variables.getCompilerVariable("sys.version")
return try {
Variables.getCompilerVariable("sys.version")
} catch (e: IOException) {
return "<unknown>"
"<unknown>"
}
}
}
@@ -160,7 +160,7 @@ class BrowserFrame : JFrame() {
}
val showHomepageAction = DefaultAction("jclasslib on the web", "Visit jclasslib on the web", "web_small.png", "web_large.png") {
GUIHelper.showURL(WEB_SITE_URL)
GUIHelper.showURL(webSiteUrl)
}
val showEjtAction = DefaultAction("ej-technologies on the web", "Visit ej-technologies on the web", "web_small.png") {
@@ -233,7 +233,7 @@ class BrowserFrame : JFrame() {
private val workspaceFileChooser: JFileChooser by lazy {
JFileChooser(workspaceChooserPath).apply {
dialogTitle = "Choose workspace file"
fileFilter = MultiFileFilter(WORKSPACE_FILE_SUFFIX, "jclasslib workspace files")
fileFilter = MultiFileFilter(workspaceFileSuffix, "jclasslib workspace files")
}
}
@@ -300,7 +300,7 @@ class BrowserFrame : JFrame() {
EventQueue.invokeLater {
val file = File(path)
if (file.exists()) {
if (path.toLowerCase().endsWith("." + WORKSPACE_FILE_SUFFIX)) {
if (path.toLowerCase().endsWith("." + workspaceFileSuffix)) {
openWorkspace(file)
} else if (path.toLowerCase().endsWith(".class")) {
try {
@@ -413,10 +413,10 @@ class BrowserFrame : JFrame() {
private fun updateTitle() {
val workspaceFile = this.workspaceFile
if (workspaceFile == null) {
title = APPLICATION_TITLE
title = applicationTitle
saveWorkspaceAsAction.isEnabled = false
} else {
title = APPLICATION_TITLE + " [" + workspaceFile.name + "]"
title = applicationTitle + " [" + workspaceFile.name + "]"
}
}
@@ -470,13 +470,12 @@ class BrowserFrame : JFrame() {
}
}
private fun getWorkspaceFile(selectedFile: File): File {
if (!selectedFile.name.toLowerCase().endsWith("." + WORKSPACE_FILE_SUFFIX)) {
return File(selectedFile.path + "." + WORKSPACE_FILE_SUFFIX)
} else {
return selectedFile
}
}
private fun getWorkspaceFile(selectedFile: File): File =
if (!selectedFile.name.toLowerCase().endsWith("." + workspaceFileSuffix)) {
File(selectedFile.path + "." + workspaceFileSuffix)
} else {
selectedFile
}
private fun saveWorkspaceToFile(file: File) {
try {
@@ -23,10 +23,10 @@ class BrowserNodeTransferHandler(private val services: BrowserServices) : Transf
}
val text = services.browserComponent.detailPane.currentDetailPane.clipboardText
if (text != null) {
return StringSelection(text)
return if (text != null) {
StringSelection(text)
} else {
return null
null
}
}
}
@@ -74,17 +74,17 @@ 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)
if (findResult != null) {
return findResult
return if (findResult != null) {
findResult
} else {
if (GUIHelper.showOptionDialog(parentFrame,
"The class $className could not be found.\nYou can check your classpath configuration and try again.",
arrayOf("Setup classpath", "Cancel"),
JOptionPane.WARNING_MESSAGE) != 0) {
return null
null
} else {
parentFrame.setupClasspathAction()
return findClass(className)
findClass(className)
}
}
}
@@ -78,10 +78,10 @@ class BrowserTreePane(private val services: BrowserServices) : JPanel() {
private fun getMethodDisplayPath(methodsPath: TreePath, method: MethodInfo, treeNode: BrowserTreeNode): TreePath {
val path = methodsPath.pathByAddingChild(treeNode)
val codeNode = findCodeNode(treeNode, method)
if (codeNode != null) {
return path.pathByAddingChild(codeNode)
return if (codeNode != null) {
path.pathByAddingChild(codeNode)
} else {
return path
path
}
}
@@ -20,14 +20,14 @@ import java.io.PrintStream
import java.util.*
import javax.swing.UIManager
val APPLICATION_TITLE = "Bytecode viewer"
val SYSTEM_PROPERTY_LAF_DEFAULT = "jclasslib.laf.default"
val WORKSPACE_FILE_SUFFIX = "jcw"
val WEB_SITE_URL = "http://www.ej-technologies.com/products/jclasslib/overview.html"
val applicationTitle = "Bytecode viewer"
val lafDefaultSystemProperty = "jclasslib.laf.default"
val workspaceFileSuffix = "jcw"
val webSiteUrl = "http://www.ej-technologies.com/products/jclasslib/overview.html"
fun main(args: Array<String>) {
if (!java.lang.Boolean.getBoolean(SYSTEM_PROPERTY_LAF_DEFAULT)) {
if (!java.lang.Boolean.getBoolean(lafDefaultSystemProperty)) {
val lookAndFeelClass = UIManager.getSystemLookAndFeelClassName()
try {
UIManager.setLookAndFeel(lookAndFeelClass)
@@ -114,7 +114,7 @@ class ClasspathBrowser(private val frame: BrowserFrame, title: String, private v
val selectionPaths = getSelectedTree().selectionPaths?.toList() ?: emptyList()
return selectionPaths.map {selectionPath ->
val buffer = StringBuilder()
for (i in 1..selectionPath.pathCount - 1) {
for (i in 1 until selectionPath.pathCount) {
if (buffer.isNotEmpty()) {
buffer.append('/')
}
@@ -102,11 +102,11 @@ abstract class ClasspathEntry(fileName : String) : ClasspathComponent {
}
fun addToClassPath(classpath: MutableList<ClasspathEntry>): Boolean {
if (!classpath.contains(this)) {
return if (!classpath.contains(this)) {
classpath.add(this)
return true
true
} else {
return false
false
}
}
@@ -38,11 +38,10 @@ class ClasspathSetupDialog(private val frame: BrowserFrame) : JDialog(frame) {
frame.classesChooserPath = fileChooser.currentDirectory.absolutePath
val files = fileChooser.selectedFiles
for (file in files) {
val entry: ClasspathEntry
if (file.isDirectory) {
entry = ClasspathDirectoryEntry(file.path)
val entry = if (file.isDirectory) {
ClasspathDirectoryEntry(file.path)
} else {
entry = ClasspathArchiveEntry(file.path)
ClasspathArchiveEntry(file.path)
}
if (!isInModel(entry)) {
@@ -140,7 +140,7 @@ abstract class TableDetailPane<T : AttributeInfo>(elementClass: Class<T>, servic
private fun updateRowHeights() {
for (row in 0 until table.rowCount) {
val rowHeight = (0..table.columnCount - 1).map { column ->
val rowHeight = (0 until table.columnCount).map { column ->
val c = table.prepareRenderer(table.getCellRenderer(row, column), row, column) as JComponent
c.size = c.preferredSize.apply {
width = table.columnModel.getColumn(column).width
@@ -95,7 +95,7 @@ abstract class AttributeDocument(protected val styles: StyleContext, protected v
protected fun getPaddedValue(number: Int, width: Int) = StringBuilder().apply {
val value = number.toString()
val valueLength = value.length
for (i in valueLength..width - 1) {
for (i in valueLength until width) {
append(' ')
}
append(value)
@@ -148,7 +148,7 @@ open class DnDTabbedPane : JTabbedPane() {
}
private fun getNextVisibleTabBound(index: Int): Rectangle? {
for (i in index + 1..tabCount - 1) {
for (i in index + 1 until tabCount) {
return getBoundsAt(i) ?: continue
}
return null
@@ -365,15 +365,15 @@ open class DnDTabbedPane : JTabbedPane() {
}
override fun drop(event: DropTargetDropEvent) {
if (isTabTransfer(event.transferable)) {
event.acceptDrop(event.dropAction)
convertTab(getTabTransferData(event), getTargetTabIndex(event.location))
event.dropComplete(true)
dropNotifier()
} else if (isDataFlavorSupported(event.transferable)) {
handleDrop(event)
} else {
event.dropComplete(false)
when {
isTabTransfer(event.transferable) -> {
event.acceptDrop(event.dropAction)
convertTab(getTabTransferData(event), getTargetTabIndex(event.location))
event.dropComplete(true)
dropNotifier()
}
isDataFlavorSupported(event.transferable) -> handleDrop(event)
else -> event.dropComplete(false)
}
glassPane.drawInsertionMarker = false
repaintGlassPanes()
@@ -124,11 +124,11 @@ open class HtmlDisplayTextArea(text: String? = null) : JEditorPane(), TextDispla
val index = if (name === HTML.Tag.HTML && view.viewCount > 1) 1 else 0
val correctedBounds = view.getChildAllocation(index, bounds) ?: return -1
val child = view.getView(index)
if (view is javax.swing.text.ParagraphView) {
return if (view is javax.swing.text.ParagraphView) {
val rect: Rectangle = correctedBounds as? Rectangle ?: correctedBounds.bounds
return rect.y + (rect.height * child.getAlignment(View.Y_AXIS)).toInt()
rect.y + (rect.height * child.getAlignment(View.Y_AXIS)).toInt()
} else {
return getBaseline(child, correctedBounds)
getBaseline(child, correctedBounds)
}
}
View
@@ -1,3 +1,5 @@
import org.jetbrains.dokka.gradle.DokkaTask
apply plugin: 'kotlin'
apply plugin: 'org.jetbrains.dokka'
@@ -18,7 +20,7 @@ dokka {
includes = ['packages.md']
}
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
task dokkaJavadoc(type: DokkaTask) {
outputFormat = 'javadoc'
outputDirectory = "$buildDir/javadoc"
}
@@ -25,10 +25,10 @@ constructor(opcode: Opcode, var isWide: Boolean, var immediateByte: Int = 0) : I
override fun read(input: ByteCodeInput) {
super.read(input)
if (isWide) {
immediateByte = input.readUnsignedShort()
immediateByte = if (isWide) {
input.readUnsignedShort()
} else {
immediateByte = input.readUnsignedByte()
input.readUnsignedByte()
}
}
@@ -40,7 +40,7 @@ class LookupSwitchInstruction(opcode: Opcode) : PaddedInstruction(opcode) {
defaultOffset = input.readInt()
val numberOfPairs = input.readInt()
for (i in 0..numberOfPairs - 1) {
for (i in 0 until numberOfPairs) {
val match = input.readInt()
val offset = input.readInt()
@@ -39,7 +39,7 @@ open class PaddedInstruction(opcode: Opcode) : Instruction(opcode) {
super.write(output)
val bytesToWrite = paddingBytes(output.bytesWritten)
for (i in 0..bytesToWrite - 1) {
for (i in 0 until bytesToWrite) {
output.writeByte(0)
}
}
@@ -48,7 +48,7 @@ class TableSwitchInstruction(opcode: Opcode) : PaddedInstruction(opcode) {
val numberOfOffsets = highByte - lowByte + 1
jumpOffsets = IntArray(numberOfOffsets)
for (i in 0..numberOfOffsets - 1) {
for (i in 0 until numberOfOffsets) {
jumpOffsets[i] = input.readInt()
}
@@ -16,7 +16,7 @@ import java.nio.file.Files
import java.nio.file.Path
private val modulesRootsCache = mutableMapOf<File, Path>()
private val CLASSFILE_SUFFIX = ".class"
private val classFileSuffix = ".class"
/**
* Get an input stream to a class file in the JRE.
@@ -33,15 +33,15 @@ fun getJrtInputStream(fileName: String, jreHome: File): InputStream {
* @param jreHome the home directory of the JRE
*/
fun findClassWithModuleNameInJrt(moduleNameAndClassName: String, jreHome: File): Path? {
return getModulesRoot(jreHome).resolve(moduleNameAndClassName + CLASSFILE_SUFFIX)
return getModulesRoot(jreHome).resolve(moduleNameAndClassName + classFileSuffix)
}
/**
* Find a class in the JRT (Java 9+)
* @param className the class name
* @param jreHome the home directory of the JRE
*/
fun findClassInJrt(className: String, jreHome: File): Path? {
val fileName = className.replace('.', '/') + CLASSFILE_SUFFIX
val fileName = className.replace('.', '/') + classFileSuffix
Files.newDirectoryStream(getModulesRoot(jreHome)).forEach { module ->
val path = module.resolve(fileName)
if (Files.exists(path)) {
@@ -58,7 +58,7 @@ fun findClassInJrt(className: String, jreHome: File): Path? {
*/
fun forEachClassInJrt(jreHome: File, block : (path : Path) -> Unit) {
Files.walk(getModulesRoot(jreHome)).forEach { path ->
if (path.nameCount > 2 && !Files.isDirectory(path) && path.toString().toLowerCase().endsWith(CLASSFILE_SUFFIX)) {
if (path.nameCount > 2 && !Files.isDirectory(path) && path.toString().toLowerCase().endsWith(classFileSuffix)) {
block(path)
}
}
@@ -15,11 +15,11 @@ package org.gjt.jclasslib.structures
*/
abstract class Lookup<T>(val enumClass: Class<T>, val name: String) where T : Enum<T>, T : ClassFileEnum {
private val LOOKUP = arrayOfNulls<Any?>(enumClass.enumConstants.maxBy { it.tag }!!.tag + 1)
private val lookup = arrayOfNulls<Any?>(enumClass.enumConstants.maxBy { it.tag }!!.tag + 1)
init {
for (constant in enumClass.enumConstants) {
LOOKUP[constant.tag] = constant
lookup[constant.tag] = constant
}
}
@@ -29,8 +29,8 @@ abstract class Lookup<T>(val enumClass: Class<T>, val name: String) where T : En
*/
@Throws(InvalidByteCodeException::class)
fun getFromTag(tag: Int): T {
if (tag < LOOKUP.size && tag >= 0) {
val constant = LOOKUP[tag]
if (tag < lookup.size && tag >= 0) {
val constant = lookup[tag]
if (constant != null) {
@Suppress("UNCHECKED_CAST")
return constant as T
@@ -44,8 +44,8 @@ enum class TypeAnnotationTargetType(override val tag: Int, private val targetInf
* Create an associated [TargetInfo] instance.
*/
fun createTargetInfo(): TargetInfo {
try {
return targetInfoClass.newInstance()
return try {
targetInfoClass.newInstance()
} catch (e: Exception) {
throw RuntimeException(e)
}
Oops, something went wrong.

0 comments on commit f1c069f

Please sign in to comment.