Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -80,7 +81,7 @@ public static void addExclusionPattern(String manifestPath, Project project) {

ApiSettingsState settings = ApiSettingsState.getInstance();
List<String> currentPatterns = parsePatterns(settings.manifestExclusionPatterns);

if (!currentPatterns.contains(relativePath)) {
currentPatterns.add(relativePath);
settings.manifestExclusionPatterns = String.join("\n", currentPatterns);
Expand All @@ -107,13 +108,13 @@ private static String getRelativePath(VirtualFile file, VirtualFile projectRoot)

private static List<String> parsePatterns(String patterns) {
if (patterns == null || patterns.trim().isEmpty()) {
return Collections.emptyList();
return new ArrayList<>();
}

return Arrays.stream(patterns.split("[\n\r]+"))
.map(String::trim)
.filter(pattern -> !pattern.isEmpty() && !pattern.startsWith("#"))
.collect(Collectors.toList());
.collect(Collectors.toCollection(ArrayList::new));
}

private static boolean matchesAnyPattern(String path, List<String> patterns) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
import java.nio.file.PathMatcher;
import java.nio.file.Paths;

import static org.junit.Assert.*;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

/**
* Simple tests for glob pattern matching behavior that don't require IntelliJ platform mocking.
Expand Down
Loading