From 3bafdf240b19a4da0add29b3dfc31719920c28eb Mon Sep 17 00:00:00 2001 From: Tagir Valeev Date: Mon, 17 Jul 2023 15:42:48 +0200 Subject: [PATCH] [java-decompiler] Check cancelled inside StrongConnectivityHelper Should improve IDEA-289496 Intellij editor freezes randomly during decompilation GitOrigin-RevId: 0f30240c4e873044cd102b8fb0df926eeb1eaf71 --- .../modules/decompiler/StrongConnectivityHelper.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/StrongConnectivityHelper.java b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/StrongConnectivityHelper.java index 05607fc630d0..ffd5e56fb027 100644 --- a/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/StrongConnectivityHelper.java +++ b/plugins/java-decompiler/engine/src/org/jetbrains/java/decompiler/modules/decompiler/StrongConnectivityHelper.java @@ -1,7 +1,9 @@ -// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// 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.modules.decompiler; import org.jetbrains.annotations.NotNull; +import org.jetbrains.java.decompiler.main.CancellationManager; +import org.jetbrains.java.decompiler.main.DecompilerContext; import org.jetbrains.java.decompiler.modules.decompiler.StatEdge.EdgeDirection; import org.jetbrains.java.decompiler.modules.decompiler.StatEdge.EdgeType; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; @@ -54,6 +56,8 @@ public class StrongConnectivityHelper { } private void visit(@NotNull Statement statement) { + CancellationManager cancellationManager = DecompilerContext.getCancellationManager(); + cancellationManager.checkCanceled(); component.push(statement); indices.put(statement, nextIndex); lowIndices.put(statement, nextIndex); @@ -92,7 +96,7 @@ public class StrongConnectivityHelper { for (Statement statement : component) { statements.remove(statement); } - return statements.size() == 0; + return statements.isEmpty(); } public @NotNull List getExitReps() {