From aed76e82064ed0d46772afdc12b52b117a5093ae Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 4 Nov 2013 14:28:31 +0100 Subject: [PATCH] hotswap's listener to consider under compile output roots only: IDEA-115853 plugin project hotswaps classes from sandbox when it shouldn't --- .../com/intellij/debugger/ui/HotSwapUIImpl.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 19f94cbe8658..56dc6a40243a 100644 --- a/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java +++ b/java/debugger/impl/src/com/intellij/debugger/ui/HotSwapUIImpl.java @@ -33,7 +33,9 @@ import com.intellij.openapi.compiler.CompilationStatusListener; import com.intellij.openapi.compiler.CompileContext; import com.intellij.openapi.compiler.CompilerManager; import com.intellij.openapi.compiler.CompilerTopics; +import com.intellij.openapi.compiler.ex.CompilerPathsEx; import com.intellij.openapi.components.ProjectComponent; +import com.intellij.openapi.module.ModuleManager; import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; @@ -48,8 +50,10 @@ import com.intellij.util.messages.MessageBus; import com.intellij.util.messages.MessageBusConnection; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jps.util.JpsPathUtil; import javax.swing.*; +import java.io.File; import java.util.*; import java.util.concurrent.atomic.AtomicReference; @@ -302,9 +306,17 @@ public class HotSwapUIImpl extends HotSwapUI implements ProjectComponent { private final AtomicReference>> myGeneratedPaths = new AtomicReference>>(new HashMap>()); + private final Set myOutputRoots; + + private MyCompilationStatusListener() { + myOutputRoots = new HashSet(); + for (final String path : CompilerPathsEx.getOutputPaths(ModuleManager.getInstance(myProject).getModules())) { + myOutputRoots.add(new File(path)); + } + } public void fileGenerated(String outputRoot, String relativePath) { - if (StringUtil.endsWith(relativePath, ".class")) { + if (StringUtil.endsWith(relativePath, ".class") && JpsPathUtil.isUnder(myOutputRoots, new File(outputRoot))) { // collect only classes final Map> map = myGeneratedPaths.get(); List paths = map.get(outputRoot);