diff --git a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java index d6e26a4f2ade..b73e1fdbe71f 100644 --- a/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java +++ b/java/debugger/impl/src/com/intellij/debugger/impl/HotSwapManager.java @@ -8,6 +8,7 @@ import com.intellij.ide.actions.ActionsCollector; import com.intellij.openapi.application.ReadAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.OrderEnumerator; +import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; @@ -19,8 +20,6 @@ import org.jetbrains.annotations.Nullable; import java.io.File; import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class HotSwapManager { private final Map myTimeStamps = new HashMap<>(); @@ -52,14 +51,14 @@ public class HotSwapManager { } public Map scanForModifiedClasses(@NotNull DebuggerSession session, - @Nullable Stream outputPaths, + @Nullable NotNullLazyValue> outputPaths, @NotNull HotSwapProgress progress) { DebuggerManagerThreadImpl.assertIsManagerThread(); final long timeStamp = getTimeStamp(session); final Map modifiedClasses = new HashMap<>(); - List paths = outputPaths != null ? outputPaths.collect(Collectors.toList()) : + List paths = outputPaths != null ? outputPaths.getValue() : ReadAction.compute(() -> JBIterable.of(OrderEnumerator.orderEntries(myProject).classes().getRoots()) .filterMap(o -> o.isDirectory() && !o.getFileSystem().isReadOnly() ? o.getPath() : null) .toList() @@ -146,7 +145,7 @@ public class HotSwapManager { @NotNull public static Map> scanForModifiedClasses(@NotNull List sessions, - @Nullable Stream outputPaths, + @Nullable NotNullLazyValue> outputPaths, @NotNull HotSwapProgress swapProgress) { final Map> modifiedClasses = new THashMap<>(); final MultiProcessCommand scanClassesCommand = new MultiProcessCommand(); diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java index dedfcb5f69db..59b9c42a63d9 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java @@ -21,6 +21,7 @@ import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Disposer; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.KeyWithDefaultValue; +import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; @@ -38,7 +39,6 @@ import org.jetbrains.jps.util.JpsPathUtil; import java.io.File; import java.util.*; import java.util.stream.Collectors; -import java.util.stream.Stream; public class HotSwapUIImpl extends HotSwapUI { /** @@ -108,7 +108,7 @@ public class HotSwapUIImpl extends HotSwapUI { private void hotSwapSessions(@NotNull final List sessions, @Nullable final Map> generatedPaths, - @Nullable final Stream outputPaths, + @Nullable final NotNullLazyValue> outputPaths, @Nullable final HotSwapStatusListener callback) { final boolean shouldAskBeforeHotswap = myAskBeforeHotswap; myAskBeforeHotswap = true; @@ -283,7 +283,7 @@ public class HotSwapUIImpl extends HotSwapUI { @NotNull private static Map> scanForModifiedClassesWithProgress(@NotNull List sessions, - @Nullable Stream outputPaths, + @Nullable NotNullLazyValue> outputPaths, @NotNull HotSwapProgressImpl progress) { return ProgressManager.getInstance().runProcess(() -> { try { @@ -399,8 +399,9 @@ public class HotSwapUIImpl extends HotSwapUI { } HotSwapStatusListener callback = context.getUserData(HOT_SWAP_CALLBACK_KEY); - Stream dirtyOutputRoots = context.getDirtyOutputPaths().orElse(null); - hotSwapSessions(sessions, generatedPaths, dirtyOutputRoots, callback); + NotNullLazyValue> outputRoots = context.getDirtyOutputPaths() + .map(stream -> NotNullLazyValue.createValue(() -> stream.collect(Collectors.toCollection(SmartList::new)))).orElse(null); + hotSwapSessions(sessions, generatedPaths, outputRoots, callback); } } }