mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJ-CR-108265 [java-decompiler] IDEA-198397 add cancelled checks for java-decompiler. Add some limits
GitOrigin-RevId: c2ebda314570d885d50cd6c523e990d238ac4491
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3c2f371c32
commit
b26d7c9740
@@ -174,7 +174,12 @@ public class MarkerType {
|
||||
.elementsConsumer((methods, navigator) -> {
|
||||
if (!methods.isEmpty()) {
|
||||
boolean showMethodNames = !PsiUtil.allMethodsHaveSameSignature(methods.toArray(PsiMethod.EMPTY_ARRAY));
|
||||
navigator.presentationProvider(element -> GotoTargetHandler.computePresentation(element, showMethodNames));
|
||||
navigator.presentationProvider(element -> {
|
||||
if (element instanceof PsiCompiledElement) {
|
||||
((PsiCompiledElement)element).getMirror(); // load decompiler in background thread
|
||||
}
|
||||
return GotoTargetHandler.computePresentation(element, showMethodNames);
|
||||
});
|
||||
}
|
||||
})
|
||||
.navigate(e, DaemonBundle.message("navigation.title.super.method", method.getName()), method.getProject());
|
||||
|
||||
+4
@@ -37,6 +37,8 @@ public interface IFernflowerPreferences {
|
||||
|
||||
String LOG_LEVEL = "log";
|
||||
String MAX_PROCESSING_METHOD = "mpm";
|
||||
String MAX_BYTES_CLASS_NOT_UNDER_PROGRESS = "mbcnup";
|
||||
String MAX_BYTES_CLASS = "mbc";
|
||||
String RENAME_ENTITIES = "ren";
|
||||
String USER_RENAMER_CLASS = "urc";
|
||||
String NEW_LINE_SEPARATOR = "nls";
|
||||
@@ -83,6 +85,8 @@ public interface IFernflowerPreferences {
|
||||
|
||||
defaults.put(LOG_LEVEL, IFernflowerLogger.Severity.INFO.name());
|
||||
defaults.put(MAX_PROCESSING_METHOD, "0");
|
||||
defaults.put(MAX_BYTES_CLASS_NOT_UNDER_PROGRESS, "0");
|
||||
defaults.put(MAX_BYTES_CLASS, "0");
|
||||
defaults.put(RENAME_ENTITIES, "0");
|
||||
defaults.put(NEW_LINE_SEPARATOR, (InterpreterUtil.IS_WINDOWS ? "0" : "1"));
|
||||
defaults.put(INDENT_STRING, " ");
|
||||
|
||||
+34
-10
@@ -27,6 +27,7 @@ import com.intellij.psi.compiled.ClassFileDecompilers
|
||||
import com.intellij.psi.impl.compiled.ClsFileImpl
|
||||
import com.intellij.ui.components.LegalNoticeDialog
|
||||
import com.intellij.util.FileContentUtilCore
|
||||
import com.intellij.util.ui.EDT
|
||||
import org.jetbrains.java.decompiler.main.CancellationManager
|
||||
import org.jetbrains.java.decompiler.main.decompiler.BaseDecompiler
|
||||
import org.jetbrains.java.decompiler.main.extern.ClassFormatException
|
||||
@@ -61,6 +62,8 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
|
||||
IFernflowerPreferences.NEW_LINE_SEPARATOR to "1",
|
||||
IFernflowerPreferences.BANNER to BANNER,
|
||||
IFernflowerPreferences.MAX_PROCESSING_METHOD to 60,
|
||||
IFernflowerPreferences.MAX_BYTES_CLASS_NOT_UNDER_PROGRESS to 20_000, //approximately 2_000 lines
|
||||
IFernflowerPreferences.MAX_BYTES_CLASS to 80_000, //approximately 8_000 lines
|
||||
IFernflowerPreferences.INDENT_STRING to indent,
|
||||
IFernflowerPreferences.IGNORE_INVALID_BYTECODE to "1",
|
||||
IFernflowerPreferences.VERIFY_ANONYMOUS_CLASSES to "1",
|
||||
@@ -122,9 +125,30 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
|
||||
|
||||
override fun accepts(file: VirtualFile): Boolean = true
|
||||
|
||||
override fun getText(file: VirtualFile): CharSequence =
|
||||
if (canWork()) TASK_KEY.pop(file)?.get() ?: decompile(file)
|
||||
else ClsFileImpl.decompile(file)
|
||||
override fun getText(file: VirtualFile): CharSequence {
|
||||
if (canWork()) {
|
||||
val previous = TASK_KEY.pop(file)?.get()
|
||||
if (previous != null) {
|
||||
return previous
|
||||
}
|
||||
else {
|
||||
val maxBytesNotUnderProgress = myOptions.value[IFernflowerPreferences.MAX_BYTES_CLASS_NOT_UNDER_PROGRESS]?.toString()?.toIntOrNull() ?: 0
|
||||
val maxBytes = myOptions.value[IFernflowerPreferences.MAX_BYTES_CLASS]?.toString()?.toIntOrNull() ?: 0
|
||||
return if (!ApplicationManager.getApplication().isUnitTestMode &&
|
||||
(maxBytesNotUnderProgress > 0 && EDT.isCurrentThreadEdt() && file.length > maxBytesNotUnderProgress) ||
|
||||
(maxBytes > 0 && file.length > maxBytes)
|
||||
) {
|
||||
ClsFileImpl.decompile(file)
|
||||
}
|
||||
else {
|
||||
decompile(file)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
return ClsFileImpl.decompile(file)
|
||||
}
|
||||
}
|
||||
|
||||
private fun decompile(file: VirtualFile): CharSequence {
|
||||
val indicator = ProgressManager.getInstance().progressIndicator
|
||||
@@ -202,19 +226,19 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun saveFolder(path: String) { }
|
||||
override fun saveFolder(path: String) {}
|
||||
|
||||
override fun copyFile(source: String, path: String, entryName: String) { }
|
||||
override fun copyFile(source: String, path: String, entryName: String) {}
|
||||
|
||||
override fun createArchive(path: String, archiveName: String, manifest: Manifest) { }
|
||||
override fun createArchive(path: String, archiveName: String, manifest: Manifest) {}
|
||||
|
||||
override fun saveDirEntry(path: String, archiveName: String, entryName: String) { }
|
||||
override fun saveDirEntry(path: String, archiveName: String, entryName: 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 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 closeArchive(path: String, archiveName: String) { }
|
||||
override fun closeArchive(path: String, archiveName: String) {}
|
||||
}
|
||||
|
||||
private fun <T> Key<T>.pop(holder: UserDataHolder): T? {
|
||||
|
||||
Reference in New Issue
Block a user