/** * Creates pattern with "/" as a directory separator. * * @see #create(String, String) */ public static WildcardPattern create(String pattern) { return create(pattern, "/"); }
PathPattern(String pattern) { this.pattern = WildcardPattern.create(pattern); }
/** * Creates array of patterns with "/" as a directory separator. * * @see #create(String, String) */ public static WildcardPattern[] create(@Nullable String[] patterns) { if (patterns == null) { return new WildcardPattern[0]; } WildcardPattern[] exclusionPAtterns = new WildcardPattern[patterns.length]; for (int i = 0; i < patterns.length; i++) { exclusionPAtterns[i] = create(patterns[i]); } return exclusionPAtterns; }
@Test public void testToString() { assertThat(WildcardPattern.create("foo*").toString()).isEqualTo("foo*"); } }
@Test public void multiplePatterns() { WildcardPattern[] patterns = WildcardPattern.create(new String[] {"Foo", "Bar"}); assertThat(WildcardPattern.match(patterns, "Foo")).isTrue(); assertThat(WildcardPattern.match(patterns, "Bar")).isTrue(); assertThat(WildcardPattern.match(patterns, "Other")).isFalse(); assertThat(WildcardPattern.create((String[]) null)).isEmpty(); }
/** * Creates pattern with "/" as a directory separator. * * @see #create(String, String) */ public static WildcardPattern create(String pattern) { return create(pattern, "/"); }
public PatternFilter(File workDir, String pattern) { String absolutePathPattern = workDir.getAbsolutePath() + "/" + pattern; absolutePathPattern = convertSlash(absolutePathPattern); this.pattern = WildcardPattern.create(absolutePathPattern); }
public static WildcardPattern[] createPatterns(String patterns) { String[] p = StringUtils.split(patterns, ','); WildcardPattern[] result = new WildcardPattern[p.length]; for (int i = 0; i < result.length; i++) { result[i] = WildcardPattern.create(StringUtils.trim(p[i]), "."); } return result; }
public PatternFilter(File workDir, String pattern) { String absolutePathPattern = workDir.getAbsolutePath(); if (!absolutePathPattern.endsWith("\\")) { // only if workDir is not // a folder on another drive (on windows systems) absolutePathPattern += "/"; } absolutePathPattern += pattern; absolutePathPattern = convertSlash(absolutePathPattern); this.pattern = WildcardPattern.create(absolutePathPattern); }
public static WildcardPattern[] createPatterns(String patterns) { String[] p = StringUtils.split(patterns, ','); WildcardPattern[] result = new WildcardPattern[p.length]; for (int i = 0; i < result.length; i++) { result[i] = WildcardPattern.create(StringUtils.trim(p[i]), "."); } return result; }
public static WildcardPattern[] createPatterns(String patterns) { String[] p = StringUtils.split(patterns, ','); WildcardPattern[] result = new WildcardPattern[p.length]; for (int i = 0; i < result.length; i++) { result[i] = WildcardPattern.create(StringUtils.trim(StringUtils.replace(p[i], ".", "/"))); } return result; }
@VisibleForTesting final void initPatterns() { Builder<WildcardPattern> builder = ImmutableList.builder(); for (String pattern : settings.getStringArray(CoreProperties.PROJECT_COVERAGE_EXCLUSIONS_PROPERTY)) { builder.add(WildcardPattern.create(pattern)); } resourcePatterns = builder.build(); log("Excluded sources for coverage: ", resourcePatterns); }
@Override public boolean matchFilePattern(String antPattern) { WildcardPattern matcher = WildcardPattern.create(antPattern, "/"); return matcher.match(getKey()); }
/** * {@inheritDoc} * * @see Resource#matchFilePattern(String) */ @Override public boolean matchFilePattern(String antPattern) { WildcardPattern matcher = WildcardPattern.create(antPattern, Directory.SEPARATOR); return matcher.match(getKey()); }
@Override public boolean accept(InputFile inputFile) { if (!TypeScriptLanguage.KEY.equals(inputFile.language())) { return true; } String[] excludedPatterns = this.configuration.getStringArray(TypeScriptPlugin.TS_EXCLUSIONS_KEY); String relativePath = inputFile.uri().toString(); return !WildcardPattern.match(WildcardPattern.create(excludedPatterns), relativePath); } }
/** * @param antPattern * @return */ @Override public boolean matchFilePattern(String antPattern) { String patternWithoutFileSuffix = StringUtils.substringBeforeLast( antPattern, "."); WildcardPattern matcher = WildcardPattern.create(patternWithoutFileSuffix, "."); return matcher.match(getKey()); }
/** * @param antPattern * @return */ @Override public boolean matchFilePattern(String antPattern) { String patternWithoutFileSuffix = StringUtils.substringBeforeLast( antPattern, "."); WildcardPattern matcher = WildcardPattern.create(patternWithoutFileSuffix, "."); return matcher.match(getKey()); }
/** * Check with ant style filepattern if the file is included. */ protected boolean isFileIncluded(String filePattern) { if (filePattern != null) { String fileName = getWebSourceCode().getSonarFile().getKey(); WildcardPattern matcher = WildcardPattern.create(filePattern); return matcher.match(fileName); } else { return true; } }