hotswap's listener to consider under compile output roots only: IDEA-115853 plugin project hotswaps classes from sandbox when it shouldn't

This commit is contained in:
Eugene Zhuravlev
2013-11-04 14:57:24 +01:00
parent 8507ff378e
commit aed76e8206
@@ -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<Map<String, List<String>>>
myGeneratedPaths = new AtomicReference<Map<String, List<String>>>(new HashMap<String, List<String>>());
private final Set<File> myOutputRoots;
private MyCompilationStatusListener() {
myOutputRoots = new HashSet<File>();
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<String, List<String>> map = myGeneratedPaths.get();
List<String> paths = map.get(outputRoot);