private static boolean filenameMatchesPrefixOrType(final String fileName, final String prefix, final FileType[] suitableFileTypes, final int invocationCount) { final boolean prefixMatched = prefix.length() == 0 || StringUtil.startsWithIgnoreCase(fileName, prefix); if (prefixMatched && (suitableFileTypes.length == 0 || invocationCount > 2)) return true; if (prefixMatched) { final String extension = FileUtilRt.getExtension(fileName); if (extension.length() == 0) return false; for (final FileType fileType : suitableFileTypes) { for (final FileNameMatcher matcher : FileTypeManager.getInstance().getAssociations(fileType)) { if (FileNameMatcherEx.acceptsCharSequence(matcher, fileName)) return true; } } } return false; }
@Override public void createFileTypes(FileTypeConsumer fileTypeConsumer) { fileTypeConsumer.consume( BuckFileType.INSTANCE, new FileNameMatcherEx() { @Override public String getPresentableString() { return BuckFileUtil.getBuildFileName(); } @Override public boolean acceptsCharSequence(CharSequence fileName) { String buildFileName = BuckFileUtil.getBuildFileName(); return StringUtilRt.endsWithIgnoreCase(fileName, buildFileName) || Comparing.equal(fileName, buildFileName, true); } }); }