mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
filter project files
This commit is contained in:
+14
-13
@@ -1406,9 +1406,8 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
if (parent != null) {
|
||||
final String oldName = (String)event.getOldValue();
|
||||
final String root = parent.getPath() + "/" + oldName;
|
||||
final Set<String> toMark;
|
||||
final Set<File> toMark = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
if (eventFile.isDirectory()) {
|
||||
toMark = new HashSet<String>();
|
||||
VfsUtilCore.visitChildrenRecursively(eventFile, new VirtualFileVisitor() {
|
||||
private StringBuilder filePath = new StringBuilder(root);
|
||||
|
||||
@@ -1421,8 +1420,10 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
else {
|
||||
String childPath = filePath.toString();
|
||||
if (child != eventFile) childPath += "/" + child.getName();
|
||||
toMark.add(childPath);
|
||||
if (child != eventFile) {
|
||||
childPath += "/" + child.getName();
|
||||
}
|
||||
toMark.add(new File(childPath));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1436,7 +1437,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
});
|
||||
}
|
||||
else {
|
||||
toMark = Collections.singleton(root);
|
||||
toMark.add(new File(root));
|
||||
}
|
||||
notifyFilesDeleted(toMark);
|
||||
}
|
||||
@@ -1470,14 +1471,14 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
final Set<String> pathsToMark = new HashSet<String>();
|
||||
final Set<File> pathsToMark = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
|
||||
processRecursively(eventFile, true, new FileProcessor() {
|
||||
private final TIntArrayList myAssociatedProjectIds = new TIntArrayList();
|
||||
|
||||
public void execute(final VirtualFile file) {
|
||||
final String filePath = file.getPath();
|
||||
pathsToMark.add(filePath);
|
||||
pathsToMark.add(new File(filePath));
|
||||
myAssociatedProjectIds.clear();
|
||||
try {
|
||||
final OutputFileInfo outputInfo = loadOutputInfo(file);
|
||||
@@ -1562,10 +1563,10 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
private void markDirtyIfSource(final VirtualFile file, final boolean fromMove) {
|
||||
final Set<String> pathsToMark = new HashSet<String>();
|
||||
final Set<File> pathsToMark = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
|
||||
processRecursively(file, false, new FileProcessor() {
|
||||
public void execute(final VirtualFile file) {
|
||||
pathsToMark.add(file.getPath());
|
||||
pathsToMark.add(new File(file.getPath()));
|
||||
final SourceFileInfo srcInfo = file.isValid()? loadSourceInfo(file) : null;
|
||||
if (srcInfo != null) {
|
||||
for (int projectId : srcInfo.getProjectIds().toArray()) {
|
||||
@@ -1600,7 +1601,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
|
||||
private void processNewFile(final VirtualFile file, final boolean notifyServer) {
|
||||
final Set<String> pathsToMark = notifyServer ? new HashSet<String>() : Collections.<String>emptySet();
|
||||
final Set<File> pathsToMark = notifyServer ? new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY) : Collections.<File>emptySet();
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
// need read action to ensure that the project was not disposed during the iteration over the project list
|
||||
public void run() {
|
||||
@@ -1616,7 +1617,7 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
processRecursively(file, false, new FileProcessor() {
|
||||
public void execute(final VirtualFile file) {
|
||||
if (notifyServer) {
|
||||
pathsToMark.add(file.getPath());
|
||||
pathsToMark.add(new File(file.getPath()));
|
||||
}
|
||||
if (!projectSuspended && isCompilable(file)) {
|
||||
loadInfoAndAddSourceForRecompilation(projectId, file);
|
||||
@@ -1651,13 +1652,13 @@ public class TranslatingCompilerFilesMonitor implements ApplicationComponent {
|
||||
}
|
||||
}
|
||||
|
||||
private static void notifyFilesChanged(Collection<String> paths) {
|
||||
private static void notifyFilesChanged(Collection<File> paths) {
|
||||
if (!paths.isEmpty()) {
|
||||
BuildManager.getInstance().notifyFilesChanged(paths);
|
||||
}
|
||||
}
|
||||
|
||||
private static void notifyFilesDeleted(Collection<String> paths) {
|
||||
private static void notifyFilesDeleted(Collection<File> paths) {
|
||||
if (!paths.isEmpty()) {
|
||||
BuildManager.getInstance().notifyFilesDeleted(paths);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.concurrency.SequentialTaskExecutor;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.net.NetUtils;
|
||||
@@ -111,6 +112,23 @@ public class BuildManager implements ApplicationComponent{
|
||||
private static final String DEFAULT_LOGGER_CONFIG = "defaultLogConfig.xml";
|
||||
private static final int MAKE_TRIGGER_DELAY = 3 * 1000 /*3 seconds*/;
|
||||
private final boolean IS_UNIT_TEST_MODE;
|
||||
private static final String IWS_EXTENSION = ".iws";
|
||||
private static final String IPR_EXTENSION = ".ipr";
|
||||
private static final String IDEA_PROJECT_DIR_PATTERN = "/.idea/";
|
||||
private static final Function<String, Boolean> PATH_FILTER =
|
||||
SystemInfo.isFileSystemCaseSensitive?
|
||||
new Function<String, Boolean>() {
|
||||
@Override
|
||||
public Boolean fun(String s) {
|
||||
return !(s.contains(IDEA_PROJECT_DIR_PATTERN) || s.endsWith(IWS_EXTENSION) || s.endsWith(IPR_EXTENSION));
|
||||
}
|
||||
} :
|
||||
new Function<String, Boolean>() {
|
||||
@Override
|
||||
public Boolean fun(String s) {
|
||||
return !(StringUtil.endsWithIgnoreCase(s, IWS_EXTENSION) || StringUtil.endsWithIgnoreCase(s, IPR_EXTENSION) || StringUtil.containsIgnoreCase(s, IDEA_PROJECT_DIR_PATTERN));
|
||||
}
|
||||
};
|
||||
|
||||
private final File mySystemDirectory;
|
||||
private final ProjectManager myProjectManager;
|
||||
@@ -217,35 +235,46 @@ public class BuildManager implements ApplicationComponent{
|
||||
return ApplicationManager.getApplication().getComponent(BuildManager.class);
|
||||
}
|
||||
|
||||
public void notifyFilesChanged(final Collection<String> paths) {
|
||||
public void notifyFilesChanged(final Collection<File> paths) {
|
||||
doNotify(paths, false);
|
||||
}
|
||||
|
||||
public void notifyFilesDeleted(Collection<String> paths) {
|
||||
public void notifyFilesDeleted(Collection<File> paths) {
|
||||
doNotify(paths, true);
|
||||
}
|
||||
|
||||
private void doNotify(final Collection<String> paths, final boolean notifyDeletion) {
|
||||
private void doNotify(final Collection<File> paths, final boolean notifyDeletion) {
|
||||
// ensure events processed in the order they arrived
|
||||
myRequestsProcessor.submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final List<String> filtered = new ArrayList<String>(paths.size());
|
||||
for (File file : paths) {
|
||||
final String path = FileUtil.toSystemIndependentName(file.getPath());
|
||||
if (PATH_FILTER.fun(path)) {
|
||||
filtered.add(path);
|
||||
}
|
||||
}
|
||||
if (filtered.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
synchronized (myProjectDataMap) {
|
||||
if (IS_UNIT_TEST_MODE) {
|
||||
if (notifyDeletion) {
|
||||
LOG.info("Registering deleted paths: " + paths);
|
||||
LOG.info("Registering deleted paths: " + filtered);
|
||||
}
|
||||
else {
|
||||
LOG.info("Registering changed paths: " + paths);
|
||||
LOG.info("Registering changed paths: " + filtered);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, ProjectData> entry : myProjectDataMap.entrySet()) {
|
||||
final ProjectData data = entry.getValue();
|
||||
if (notifyDeletion) {
|
||||
data.addDeleted(paths);
|
||||
data.addDeleted(filtered);
|
||||
}
|
||||
else {
|
||||
data.addChanged(paths);
|
||||
data.addChanged(filtered);
|
||||
}
|
||||
final RequestFuture future = myBuildsInProgress.get(entry.getKey());
|
||||
if (future != null && !future.isCancelled() && !future.isDone()) {
|
||||
|
||||
Reference in New Issue
Block a user