IDEA-76142: Gradle support - cannot update IDEA projects once one of build.gradle files changes

Don't process content roots that point to the unexisting files
This commit is contained in:
Denis.Zhdanov
2012-03-12 18:03:34 +04:00
parent 7121bfb851
commit 8a7a0109fc
2 changed files with 20 additions and 14 deletions
@@ -11,15 +11,11 @@ import com.intellij.openapi.roots.impl.libraries.ProjectLibraryTable;
import com.intellij.openapi.roots.libraries.LibraryTable;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.plugins.gradle.model.intellij.ModuleAwareContentRoot;
import org.jetbrains.plugins.gradle.util.GradleUtil;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.*;
/**
* @author Denis Zhdanov
@@ -52,12 +48,14 @@ public class PlatformFacadeImpl implements PlatformFacade {
if (entries == null) {
return Collections.emptyList();
}
return ContainerUtil.map(entries, new Function<ContentEntry, ModuleAwareContentRoot>() {
@Override
public ModuleAwareContentRoot fun(ContentEntry entry) {
return new ModuleAwareContentRoot(module, entry);
List<ModuleAwareContentRoot> result = new ArrayList<ModuleAwareContentRoot>();
for (ContentEntry entry : entries) {
final VirtualFile file = entry.getFile();
if (file != null) {
result.add(new ModuleAwareContentRoot(module, entry));
}
});
}
return result;
}
@NotNull
@@ -6,7 +6,6 @@ import com.intellij.openapi.roots.ExcludeFolder;
import com.intellij.openapi.roots.SourceFolder;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* @author Denis Zhdanov
@@ -16,10 +15,19 @@ public class ModuleAwareContentRoot implements ContentEntry {
@NotNull private final Module myModule;
@NotNull private final ContentEntry myDelegate;
@NotNull private final VirtualFile myFile;
public ModuleAwareContentRoot(@NotNull Module module, @NotNull ContentEntry delegate) {
public ModuleAwareContentRoot(@NotNull Module module, @NotNull ContentEntry delegate) throws IllegalArgumentException {
myDelegate = delegate;
myModule = module;
final VirtualFile file = delegate.getFile();
if (file == null) {
throw new IllegalArgumentException(String.format(
"Detected attempt to create ModuleAwareContentRoot object for content root that points to the un-existing file - %s, module: %s",
delegate, module
));
}
myFile = file;
}
@NotNull
@@ -27,10 +35,10 @@ public class ModuleAwareContentRoot implements ContentEntry {
return myModule;
}
@NotNull
@Override
@Nullable
public VirtualFile getFile() {
return myDelegate.getFile();
return myFile;
}
@Override