Java 类com.intellij.openapi.fileTypes.FileNameMatcherEx 实例源码

项目:intellij-ce-playground    文件:FilePathCompletionContributor.java   
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;
}
项目:Buck-IntelliJ-Plugin    文件:BuckFileTypeFactory.java   
@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);
        }
      });
}
项目:buck    文件:BuckFileTypeFactory.java   
@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);
        }
      });
}