mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
IJ-CR-108265 [java-decompiler] IDEA-198397 add cancelled checks for java-decompiler
GitOrigin-RevId: 845695f0775b844c27343e9216bbc5c12d0c13cc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
47d79a54d7
commit
b90082abea
@@ -0,0 +1,22 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.java.decompiler;
|
||||
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.java.decompiler.main.CancellationManager;
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public class IdeaCancellationManager extends CancellationManager.SimpleWithTimeoutCancellationManager {
|
||||
|
||||
@Override
|
||||
public void checkCanceled() throws CanceledException, TimeExceedException {
|
||||
try {
|
||||
ProgressManager.checkCanceled();
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
throw new CanceledException(e);
|
||||
}
|
||||
super.checkCanceled();
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,8 @@ class IdeaDecompiler : ClassFileDecompilers.Light() {
|
||||
val provider = MyBytecodeProvider(files)
|
||||
val saver = MyResultSaver()
|
||||
|
||||
val decompiler = BaseDecompiler(provider, saver, options, myLogger.value, SimpleCancellationManager())
|
||||
val decompiler = BaseDecompiler(provider, saver, options, myLogger.value,
|
||||
IdeaCancellationManager())
|
||||
files.forEach { decompiler.addSource(File(it.path)) }
|
||||
try {
|
||||
decompiler.decompileContext()
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.java.decompiler;
|
||||
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.java.decompiler.main.CancellationManager;
|
||||
|
||||
@ApiStatus.Experimental
|
||||
public class SimpleCancellationManager implements CancellationManager {
|
||||
|
||||
private volatile ProcessCanceledException exception = null;
|
||||
|
||||
@Override
|
||||
public void checkCanceled() throws CanceledException {
|
||||
try {
|
||||
ProgressManager.checkCanceled();
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
exception = e;
|
||||
throw new CanceledException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveCancelled() {
|
||||
if (exception != null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
checkCanceled();
|
||||
}
|
||||
catch (CanceledException e) {
|
||||
if (e.getCause() instanceof ProcessCanceledException) {
|
||||
exception = (ProcessCanceledException)e.getCause();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkSavedCancelled() throws CanceledException {
|
||||
ProcessCanceledException currentException = exception;
|
||||
if (currentException != null) {
|
||||
throw new CanceledException(currentException);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user