Minor: reformat and fix warnings in internal package
This commit is contained in:
@@ -54,8 +54,7 @@ sealed class BytecodeGenerationResult {
|
||||
}
|
||||
|
||||
class KotlinBytecodeToolWindow(private val myProject: Project, private val toolWindow: ToolWindow) : JPanel(BorderLayout()), Disposable {
|
||||
private val LOG = Logger.getInstance(KotlinBytecodeToolWindow::class.java)
|
||||
|
||||
@Suppress("JoinDeclarationAndAssignment")
|
||||
private val myEditor: Editor
|
||||
private val enableInline: JCheckBox
|
||||
private val enableOptimization: JCheckBox
|
||||
@@ -166,7 +165,6 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW
|
||||
}
|
||||
|
||||
init {
|
||||
|
||||
myEditor = EditorFactory.getInstance().createEditor(
|
||||
EditorFactory.getInstance().createDocument(""), myProject, JavaFileType.INSTANCE, true
|
||||
)
|
||||
@@ -223,9 +221,10 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val LOG = Logger.getInstance(KotlinBytecodeToolWindow::class.java)
|
||||
|
||||
private val UPDATE_DELAY = 1000
|
||||
private val DEFAULT_TEXT = "/*\n" +
|
||||
private const val UPDATE_DELAY = 1000
|
||||
private const val DEFAULT_TEXT = "/*\n" +
|
||||
"Generated bytecode for Kotlin source file.\n" +
|
||||
"No Kotlin source file is opened.\n" +
|
||||
"*/"
|
||||
@@ -283,7 +282,7 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW
|
||||
)
|
||||
|
||||
val generateClassFilter = object : GenerationState.GenerateClassFilter() {
|
||||
override fun shouldGeneratePackagePart(file: KtFile): Boolean {
|
||||
override fun shouldGeneratePackagePart(@Suppress("PARAMETER_NAME_CHANGED_ON_OVERRIDE") file: KtFile): Boolean {
|
||||
return file === ktFile
|
||||
}
|
||||
|
||||
@@ -319,6 +318,7 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW
|
||||
}
|
||||
|
||||
private fun mapLines(text: String, startLine: Int, endLine: Int): Pair<Int, Int> {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
var startLine = startLine
|
||||
var byteCodeLine = 0
|
||||
var byteCodeStartLine = -1
|
||||
@@ -331,7 +331,7 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW
|
||||
lines.add(ktLineNum)
|
||||
}
|
||||
}
|
||||
Collections.sort(lines)
|
||||
lines.sort()
|
||||
|
||||
for (line in lines) {
|
||||
if (line >= startLine) {
|
||||
|
||||
+14
-17
@@ -35,7 +35,6 @@ import java.util.jar.Manifest
|
||||
|
||||
class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
override fun decompile(file: KtFile): String? {
|
||||
|
||||
try {
|
||||
val bytecodeMap = when {
|
||||
file.canBeDecompiledToJava() -> bytecodeMapForExistingClassfile(file.virtualFile)
|
||||
@@ -44,11 +43,10 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
}
|
||||
val resultSaver = KotlinResultSaver()
|
||||
val options = hashMapOf<String, Any>(
|
||||
IFernflowerPreferences.REMOVE_BRIDGE to "0"
|
||||
IFernflowerPreferences.REMOVE_BRIDGE to "0"
|
||||
)
|
||||
|
||||
val bytecodeProvider = IBytecodeProvider {
|
||||
externalPath, _ ->
|
||||
val bytecodeProvider = IBytecodeProvider { externalPath, _ ->
|
||||
val path = File(FileUtil.toSystemIndependentName(externalPath))
|
||||
bytecodeMap[path]?.invoke()
|
||||
}
|
||||
@@ -59,8 +57,7 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
}
|
||||
decompiler.decompileContext()
|
||||
return resultSaver.resultText
|
||||
}
|
||||
catch (ex: IdeaLogger.InternalException) {
|
||||
} catch (ex: IdeaLogger.InternalException) {
|
||||
throw DecompileFailedException(ex.message ?: "Unknown error", ex)
|
||||
}
|
||||
}
|
||||
@@ -68,10 +65,10 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
private fun bytecodeMapForExistingClassfile(file: VirtualFile): Map<File, () -> ByteArray> {
|
||||
val mask = "${file.nameWithoutExtension}$"
|
||||
val files =
|
||||
mapOf(file.path to file) +
|
||||
file.parent.children.filter {
|
||||
it.nameWithoutExtension.startsWith(mask) && it.fileType === StdFileTypes.CLASS
|
||||
}.map { it.path to it }
|
||||
mapOf(file.path to file) +
|
||||
file.parent.children.filter {
|
||||
it.nameWithoutExtension.startsWith(mask) && it.fileType === StdFileTypes.CLASS
|
||||
}.map { it.path to it }
|
||||
|
||||
return files.entries.associate {
|
||||
Pair(File(it.key), { it.value.contentsToByteArray(false) })
|
||||
@@ -105,13 +102,13 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveFolder(path: String?) { }
|
||||
override fun saveFolder(path: String?) {}
|
||||
|
||||
override fun closeArchive(path: String?, archiveName: String?) { }
|
||||
override fun closeArchive(path: String?, archiveName: String?) {}
|
||||
|
||||
override fun copyEntry(source: String?, path: String?, archiveName: String?, entry: String?) { }
|
||||
override fun copyEntry(source: String?, path: String?, archiveName: String?, entry: String?) {}
|
||||
|
||||
override fun createArchive(path: String?, archiveName: String?, manifest: Manifest?) { }
|
||||
override fun createArchive(path: String?, archiveName: String?, manifest: Manifest?) {}
|
||||
|
||||
override fun saveClassFile(path: String?, qualifiedName: String?, entryName: String?, content: String?, mapping: IntArray?) {
|
||||
if (entryName != null && content != null) {
|
||||
@@ -119,11 +116,11 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
}
|
||||
}
|
||||
|
||||
override fun copyFile(source: String?, path: String?, entryName: String?) { }
|
||||
override fun copyFile(source: String?, path: String?, entryName: String?) {}
|
||||
|
||||
override fun saveClassEntry(path: String?, archiveName: String?, qualifiedName: String?, entryName: String?, content: String?) { }
|
||||
override fun saveClassEntry(path: String?, archiveName: String?, qualifiedName: String?, entryName: String?, content: String?) {}
|
||||
|
||||
override fun saveDirEntry(path: String?, archiveName: String?, entryName: String?) { }
|
||||
override fun saveDirEntry(path: String?, archiveName: String?, entryName: String?) {}
|
||||
|
||||
}
|
||||
}
|
||||
+14
-17
@@ -35,7 +35,6 @@ import java.util.jar.Manifest
|
||||
|
||||
class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
override fun decompile(file: KtFile): String? {
|
||||
|
||||
try {
|
||||
val bytecodeMap = when {
|
||||
file.canBeDecompiledToJava() -> bytecodeMapForExistingClassfile(file.virtualFile)
|
||||
@@ -44,11 +43,10 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
}
|
||||
val resultSaver = KotlinResultSaver()
|
||||
val options = hashMapOf<String, Any>(
|
||||
IFernflowerPreferences.REMOVE_BRIDGE to "0"
|
||||
IFernflowerPreferences.REMOVE_BRIDGE to "0"
|
||||
)
|
||||
|
||||
val bytecodeProvider = IBytecodeProvider {
|
||||
externalPath, _ ->
|
||||
val bytecodeProvider = IBytecodeProvider { externalPath, _ ->
|
||||
val path = File(FileUtil.toSystemIndependentName(externalPath))
|
||||
bytecodeMap[path]?.invoke()
|
||||
}
|
||||
@@ -59,8 +57,7 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
}
|
||||
decompiler.decompileContext()
|
||||
return resultSaver.resultText
|
||||
}
|
||||
catch (ex: IdeaLogger.InternalException) {
|
||||
} catch (ex: IdeaLogger.InternalException) {
|
||||
throw DecompileFailedException(ex.message ?: "Unknown error", ex)
|
||||
}
|
||||
}
|
||||
@@ -68,10 +65,10 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
private fun bytecodeMapForExistingClassfile(file: VirtualFile): Map<File, () -> ByteArray> {
|
||||
val mask = "${file.nameWithoutExtension}$"
|
||||
val files =
|
||||
mapOf(file.path to file) +
|
||||
file.parent.children.filter {
|
||||
it.nameWithoutExtension.startsWith(mask) && it.fileType === StdFileTypes.CLASS
|
||||
}.map { it.path to it }
|
||||
mapOf(file.path to file) +
|
||||
file.parent.children.filter {
|
||||
it.nameWithoutExtension.startsWith(mask) && it.fileType === StdFileTypes.CLASS
|
||||
}.map { it.path to it }
|
||||
|
||||
return files.entries.associate {
|
||||
Pair(File(it.key), { it.value.contentsToByteArray(false) })
|
||||
@@ -105,13 +102,13 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveFolder(path: String?) { }
|
||||
override fun saveFolder(path: String?) {}
|
||||
|
||||
override fun closeArchive(path: String?, archiveName: String?) { }
|
||||
override fun closeArchive(path: String?, archiveName: String?) {}
|
||||
|
||||
override fun copyEntry(source: String?, path: String?, archiveName: String?, entry: String?) { }
|
||||
override fun copyEntry(source: String?, path: String?, archiveName: String?, entry: String?) {}
|
||||
|
||||
override fun createArchive(path: String?, archiveName: String?, manifest: Manifest?) { }
|
||||
override fun createArchive(path: String?, archiveName: String?, manifest: Manifest?) {}
|
||||
|
||||
override fun saveClassFile(path: String?, qualifiedName: String?, entryName: String?, content: String?, mapping: IntArray?) {
|
||||
if (entryName != null && content != null) {
|
||||
@@ -119,11 +116,11 @@ class KotlinDecompilerServiceImpl : KotlinDecompilerService {
|
||||
}
|
||||
}
|
||||
|
||||
override fun copyFile(source: String?, path: String?, entryName: String?) { }
|
||||
override fun copyFile(source: String?, path: String?, entryName: String?) {}
|
||||
|
||||
override fun saveClassEntry(path: String?, archiveName: String?, qualifiedName: String?, entryName: String?, content: String?) { }
|
||||
override fun saveClassEntry(path: String?, archiveName: String?, qualifiedName: String?, entryName: String?, content: String?) {}
|
||||
|
||||
override fun saveDirEntry(path: String?, archiveName: String?, entryName: String?) { }
|
||||
override fun saveDirEntry(path: String?, archiveName: String?, entryName: String?) {}
|
||||
|
||||
}
|
||||
}
|
||||
+43
-36
@@ -39,15 +39,15 @@ import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
class CreateIncrementalCompilationBackup: AnAction("Create backup for debugging Kotlin incremental compilation") {
|
||||
class CreateIncrementalCompilationBackup : AnAction("Create backup for debugging Kotlin incremental compilation") {
|
||||
companion object {
|
||||
val BACKUP_DIR_NAME = ".backup"
|
||||
val PATCHES_TO_CREATE = 5
|
||||
const val BACKUP_DIR_NAME = ".backup"
|
||||
const val PATCHES_TO_CREATE = 5
|
||||
|
||||
val PATCHES_FRACTION = .25
|
||||
val LOGS_FRACTION = .05
|
||||
val PROJECT_SYSTEM_FRACTION = .05
|
||||
val ZIP_FRACTION = 1.0 - PATCHES_FRACTION - LOGS_FRACTION - PROJECT_SYSTEM_FRACTION
|
||||
const val PATCHES_FRACTION = .25
|
||||
const val LOGS_FRACTION = .05
|
||||
const val PROJECT_SYSTEM_FRACTION = .05
|
||||
const val ZIP_FRACTION = 1.0 - PATCHES_FRACTION - LOGS_FRACTION - PROJECT_SYSTEM_FRACTION
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
@@ -56,15 +56,15 @@ class CreateIncrementalCompilationBackup: AnAction("Create backup for debugging
|
||||
val backupDir = File(FileUtil.createTempDirectory("makeBackup", null), BACKUP_DIR_NAME)
|
||||
|
||||
ProgressManager.getInstance().run(
|
||||
object : Task.Backgroundable(project, "Creating backup for debugging Kotlin incremental compilation", true) {
|
||||
override fun run(indicator: ProgressIndicator) {
|
||||
createPatches(backupDir, project, indicator)
|
||||
copyLogs(backupDir, indicator)
|
||||
copyProjectSystemDir(backupDir, project, indicator)
|
||||
object : Task.Backgroundable(project, "Creating backup for debugging Kotlin incremental compilation", true) {
|
||||
override fun run(indicator: ProgressIndicator) {
|
||||
createPatches(backupDir, project, indicator)
|
||||
copyLogs(backupDir, indicator)
|
||||
copyProjectSystemDir(backupDir, project, indicator)
|
||||
|
||||
zipProjectDir(backupDir, project, projectBaseDir, indicator)
|
||||
}
|
||||
zipProjectDir(backupDir, project, projectBaseDir, indicator)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,13 @@ class CreateIncrementalCompilationBackup: AnAction("Create backup for debugging
|
||||
val gateway = localHistoryImpl.gateway!!
|
||||
val localHistoryFacade = localHistoryImpl.facade
|
||||
|
||||
val revisionsCollector = RevisionsCollector(localHistoryFacade, gateway.createTransientRootEntry(), project.baseDir!!.path, project.locationHash, null)
|
||||
val revisionsCollector = RevisionsCollector(
|
||||
localHistoryFacade,
|
||||
gateway.createTransientRootEntry(),
|
||||
project.baseDir!!.path,
|
||||
project.locationHash,
|
||||
null
|
||||
)
|
||||
|
||||
var patchesCreated = 0
|
||||
|
||||
@@ -91,8 +97,7 @@ class CreateIncrementalCompilationBackup: AnAction("Create backup for debugging
|
||||
indicator.fraction = PATCHES_FRACTION * patchesCreated / PATCHES_TO_CREATE
|
||||
|
||||
val differences = revisions[0].getDifferencesWith(rev)!!
|
||||
val changes = differences.map {
|
||||
d ->
|
||||
val changes = differences.map { d ->
|
||||
Change(d.getLeftContentRevision(gateway), d.getRightContentRevision(gateway))
|
||||
}
|
||||
|
||||
@@ -134,24 +139,24 @@ class CreateIncrementalCompilationBackup: AnAction("Create backup for debugging
|
||||
|
||||
for (dir in listOf(projectDir, backupDir.parentFile!!)) {
|
||||
FileUtil.processFilesRecursively(
|
||||
dir,
|
||||
/*processor*/ {
|
||||
if (it!!.isFile
|
||||
&& !it.name.endsWith(".hprof")
|
||||
&& !(it.name.startsWith("make_backup_") && it.name.endsWith(".zip"))
|
||||
) {
|
||||
dir,
|
||||
/*processor*/ {
|
||||
if (it!!.isFile
|
||||
&& !it.name.endsWith(".hprof")
|
||||
&& !(it.name.startsWith("make_backup_") && it.name.endsWith(".zip"))
|
||||
) {
|
||||
|
||||
indicator.text = "Scanning project dir: $it"
|
||||
indicator.text = "Scanning project dir: $it"
|
||||
|
||||
files.add(Pair(it, FileUtil.getRelativePath(dir, it)!!))
|
||||
totalBytes += it.length()
|
||||
}
|
||||
true
|
||||
},
|
||||
/*directoryFilter*/ {
|
||||
val name = it!!.name
|
||||
name != ".git" && name != "out"
|
||||
files.add(Pair(it, FileUtil.getRelativePath(dir, it)!!))
|
||||
totalBytes += it.length()
|
||||
}
|
||||
true
|
||||
},
|
||||
/*directoryFilter*/ {
|
||||
val name = it!!.name
|
||||
name != ".git" && name != "out"
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -176,14 +181,16 @@ class CreateIncrementalCompilationBackup: AnAction("Create backup for debugging
|
||||
|
||||
FileUtil.delete(backupDir)
|
||||
|
||||
WaitForProgressToShow.runOrInvokeLaterAboveProgress({
|
||||
ShowFilePathAction.showDialog(
|
||||
WaitForProgressToShow.runOrInvokeLaterAboveProgress(
|
||||
{
|
||||
ShowFilePathAction.showDialog(
|
||||
project,
|
||||
"Successfully created backup " + backupFile.absolutePath,
|
||||
"Created backup",
|
||||
backupFile,
|
||||
null
|
||||
)
|
||||
}, null, project)
|
||||
)
|
||||
}, null, project
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -26,7 +26,7 @@ val random = Random()
|
||||
|
||||
val HISTORY_LABEL_KEY = Key.create<String>("history label")
|
||||
|
||||
class MakeBackupCompileTask: CompileTask {
|
||||
class MakeBackupCompileTask : CompileTask {
|
||||
override fun execute(context: CompileContext?): Boolean {
|
||||
val project = context!!.project!!
|
||||
|
||||
@@ -38,5 +38,4 @@ class MakeBackupCompileTask: CompileTask {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.internal.makeBackup
|
||||
|
||||
val HISTORY_LABEL_PREFIX = "build started "
|
||||
const val HISTORY_LABEL_PREFIX = "build started "
|
||||
|
||||
Reference in New Issue
Block a user