Skip to content

Commit

Permalink
Fix: Ensure .projectview exclusion rules apply only to specified dire…
Browse files Browse the repository at this point in the history
…ctories (bazelbuild#6376)

closes bazelbuild#6374
  • Loading branch information
Tomasz Pasternak authored Apr 8, 2024
1 parent 9a8ea53 commit 54c67f9
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
import com.google.idea.blaze.base.bazel.BuildSystemProvider;
import com.google.idea.blaze.base.model.BlazeProjectData;
import com.google.idea.blaze.base.model.primitives.WorkspacePath;
import com.google.idea.blaze.base.model.primitives.WorkspaceRoot;
Expand Down Expand Up @@ -69,13 +70,17 @@ public static void createContentEntries(
modifiableRootModel.addContentEntry(UrlUtil.pathToUrl(rootFile.getPath()));

for (WorkspacePath exclude : excludesByRootDirectory.get(rootDirectory)) {
File excludeFolder = workspaceRoot.fileForPath(exclude);
contentEntry.addExcludeFolder(UrlUtil.fileToIdeaUrl(excludeFolder));
}

for (String dir : BuildSystemProvider.getBuildSystemProvider(Blaze.getBuildSystemName(project))
.buildArtifactDirectories(workspaceRoot)) {
var workspacePath = new WorkspacePath(dir);
if (projectViewSet.getScalarValue(UseExclusionPatternsSection.KEY).orElse(true)
&& !exclude.asPath().isAbsolute()
&& exclude.asPath().getNameCount() == 1) {
contentEntry.addExcludePattern(exclude.relativePath());
} else {
File excludeFolder = workspaceRoot.fileForPath(exclude);
contentEntry.addExcludeFolder(UrlUtil.fileToIdeaUrl(excludeFolder));
&& !workspacePath.asPath().isAbsolute()
&& workspacePath.asPath().getNameCount() == 1) {
contentEntry.addExcludePattern(workspacePath.relativePath());
}
}

Expand Down

0 comments on commit 54c67f9

Please sign in to comment.