mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
project structure: allow marking directories under excluded roots as source folders in Project Structure dialog (IDEA-135096)
This commit is contained in:
+8
-5
@@ -39,6 +39,7 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.util.EventListener;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -303,16 +304,18 @@ public abstract class ContentEntryEditor implements ContentRootPanel.ActionCallb
|
||||
public static boolean isExcludedOrUnderExcludedDirectory(@Nullable Project project,
|
||||
@NotNull ContentEntry entry,
|
||||
@NotNull VirtualFile file) {
|
||||
List<VirtualFile> excludedFiles = ContainerUtil.newArrayList(entry.getExcludeFolderFiles());
|
||||
Set<VirtualFile> excludedFiles = ContainerUtil.newHashSet(entry.getExcludeFolderFiles());
|
||||
if (project != null) {
|
||||
for (DirectoryIndexExcludePolicy policy : DirectoryIndexExcludePolicy.getExtensions(project)) {
|
||||
ContainerUtil.addAllNotNull(excludedFiles, policy.getExcludeRootsForProject());
|
||||
}
|
||||
}
|
||||
for (VirtualFile excludedFile : excludedFiles) {
|
||||
if (VfsUtilCore.isAncestor(excludedFile, file, false)) {
|
||||
return true;
|
||||
}
|
||||
Set<VirtualFile> sourceRoots = ContainerUtil.set(entry.getSourceFolderFiles());
|
||||
VirtualFile parent = file;
|
||||
while (parent != null) {
|
||||
if (excludedFiles.contains(parent)) return true;
|
||||
if (sourceRoots.contains(parent)) return false;
|
||||
parent = parent.getParent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+2
-8
@@ -36,7 +36,6 @@ import com.intellij.ui.roots.IconActionComponent;
|
||||
import com.intellij.ui.roots.ResizingWrapper;
|
||||
import com.intellij.uiDesigner.core.GridConstraints;
|
||||
import com.intellij.uiDesigner.core.GridLayoutManager;
|
||||
import com.intellij.util.NotNullProducer;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -108,14 +107,9 @@ public abstract class ContentRootPanel extends JPanel {
|
||||
final SourceFolder[] sourceFolders = getContentEntry().getSourceFolders();
|
||||
MultiMap<JpsModuleSourceRootType<?>, SourceFolder> folderByType = new MultiMap<>();
|
||||
for (SourceFolder folder : sourceFolders) {
|
||||
if (folder.isSynthetic()) {
|
||||
continue;
|
||||
if (!folder.isSynthetic()) {
|
||||
folderByType.putValue(folder.getRootType(), folder);
|
||||
}
|
||||
final VirtualFile folderFile = folder.getFile();
|
||||
if (folderFile != null && isExcludedOrUnderExcludedDirectory(folderFile)) {
|
||||
continue;
|
||||
}
|
||||
folderByType.putValue(folder.getRootType(), folder);
|
||||
}
|
||||
|
||||
Insets insets = new Insets(0, 0, 10, 0);
|
||||
|
||||
Reference in New Issue
Block a user