public static PathPattern[] create(String[] s) { PathPattern[] result = new PathPattern[s.length]; for (int i = 0; i < s.length; i++) { result[i] = create(s[i]); } return result; }
@Test public void match_absolute_path_and_insensitive_file_extension() throws Exception { PathPattern pattern = PathPattern.create("file:**/src/main/**Foo.java"); assertThat(pattern.toString()).isEqualTo("file:**/src/main/**Foo.java"); IndexedFile indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/MyFoo.JAVA", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()), false)).isTrue(); indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/Other.JAVA", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()), false)).isFalse(); }
public boolean isIncluded(Path absolutePath, Path relativePath, InputFile.Type type) { PathPattern[] inclusionPatterns = InputFile.Type.MAIN == type ? mainInclusionsPattern : testInclusionsPattern; if (inclusionPatterns.length == 0) { return true; } for (PathPattern pattern : inclusionPatterns) { if (pattern.match(absolutePath, relativePath)) { return true; } } return false; }
@Override public boolean match(InputFile inputFile, boolean caseSensitiveFileExtension) { String path = inputFile.absolutePath(); if (!caseSensitiveFileExtension) { String extension = super.sanitizeExtension(FilenameUtils.getExtension(inputFile.file().getName())); if (StringUtils.isNotBlank(extension)) { path = StringUtils.removeEndIgnoreCase(path, extension); path = path + extension; } } return pattern.match(path); }
public boolean isExcluded(Path absolutePath, Path relativePath, InputFile.Type type) { PathPattern[] exclusionPatterns = InputFile.Type.MAIN == type ? mainExclusionsPattern : testExclusionsPattern; if (exclusionPatterns.length == 0) { return false; } for (PathPattern pattern : exclusionPatterns) { if (pattern.match(absolutePath, relativePath)) { return true; } } return false; } }
@Override public boolean match(InputFile inputFile, boolean caseSensitiveFileExtension) { String path = inputFile.relativePath(); if (!caseSensitiveFileExtension) { String extension = super.sanitizeExtension(FilenameUtils.getExtension(inputFile.file().getName())); if (StringUtils.isNotBlank(extension)) { path = StringUtils.removeEndIgnoreCase(path, extension); path = path + extension; } } return path != null && pattern.match(path); }
private static PathPattern[] prepareMainInclusions(String[] sourceInclusions) { if (sourceInclusions.length > 0) { // User defined params return PathPattern.create(sourceInclusions); } return new PathPattern[0]; }
@Test public void match_relative_path_and_insensitive_file_extension() throws Exception { PathPattern pattern = PathPattern.create("**/*Foo.java"); IndexedFile indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/MyFoo.JAVA", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()), false)).isTrue(); indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/Other.java", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()), false)).isFalse(); }
private boolean isCandidateForLanguage(Path absolutePath, Path relativePath, String languageKey) { PathPattern[] patterns = patternsByLanguage.get(languageKey); if (patterns != null) { for (PathPattern pathPattern : patterns) { if (pathPattern.match(absolutePath, relativePath, false)) { return true; } } } return false; }
private static PathPattern[] prepareTestInclusions(String[] testInclusions) { return PathPattern.create(testInclusions); }
@Test public void match_relative_path() { PathPattern pattern = PathPattern.create("**/*Foo.java"); assertThat(pattern.toString()).isEqualTo("**/*Foo.java"); IndexedFile indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/MyFoo.java", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()))).isTrue(); // case sensitive by default indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/MyFoo.JAVA", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()))).isFalse(); indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/Other.java", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()))).isFalse(); }
@Override public boolean apply(InputFile f) { return pattern.match(f.path(), Paths.get(f.relativePath())); }
private static PathPattern[] prepareTestExclusions(String[] testExclusions) { return PathPattern.create(testExclusions); }
@Test public void match_absolute_path() throws Exception { PathPattern pattern = PathPattern.create("file:**/src/main/**Foo.java"); assertThat(pattern.toString()).isEqualTo("file:**/src/main/**Foo.java"); IndexedFile indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/MyFoo.java", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()))).isTrue(); // case sensitive by default indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/MyFoo.JAVA", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()))).isFalse(); indexedFile = new DefaultIndexedFile("ABCDE", baseDir, "src/main/java/org/Other.java", null); assertThat(pattern.match(indexedFile.path(), Paths.get(indexedFile.relativePath()))).isFalse(); }
public boolean isIncluded(Path absolutePath, Path relativePath, InputFile.Type type) { PathPattern[] inclusionPatterns = InputFile.Type.MAIN == type ? mainInclusionsPattern : testInclusionsPattern; if (inclusionPatterns.length == 0) { return true; } for (PathPattern pattern : inclusionPatterns) { if (pattern.match(absolutePath, relativePath)) { return true; } } return false; }
static PathPattern[] prepareMainExclusions(String[] sourceExclusions, String[] testInclusions) { String[] patterns = (String[]) ArrayUtils.addAll( sourceExclusions, testInclusions); return PathPattern.create(patterns); }
public boolean isExcluded(Path absolutePath, Path relativePath, InputFile.Type type) { PathPattern[] exclusionPatterns = InputFile.Type.MAIN == type ? mainExclusionsPattern : testExclusionsPattern; if (exclusionPatterns.length == 0) { return false; } for (PathPattern pattern : exclusionPatterns) { if (pattern.match(absolutePath, relativePath)) { return true; } } return false; } }
@Override public FilePredicate matchesPathPattern(String inclusionPattern) { return new PathPatternPredicate(PathPattern.create(inclusionPattern)); }
@Override public boolean apply(InputFile f) { return pattern.match(f); }
@Override public FilePredicate matchesPathPatterns(String[] inclusionPatterns) { if (inclusionPatterns.length == 0) { return TruePredicate.TRUE; } FilePredicate[] predicates = new FilePredicate[inclusionPatterns.length]; for (int i = 0; i < inclusionPatterns.length; i++) { predicates[i] = new PathPatternPredicate(PathPattern.create(inclusionPatterns[i])); } return or(predicates); }