• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FileNameMatcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.openapi.fileTypes.FileNameMatcher的典型用法代码示例。如果您正苦于以下问题:Java FileNameMatcher类的具体用法?Java FileNameMatcher怎么用?Java FileNameMatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FileNameMatcher类属于com.intellij.openapi.fileTypes包,在下文中一共展示了FileNameMatcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: removeAllAssociations

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
boolean removeAllAssociations(@NotNull T type) {
  boolean changed = removeAssociationsFromMap(myExtensionMappings, type, false);

  changed = removeAssociationsFromMap(myExactFileNameAnyCaseMappings, type, changed);
  changed = removeAssociationsFromMap(myExactFileNameMappings, type, changed);

  List<Pair<FileNameMatcher, T>> copy = new ArrayList<Pair<FileNameMatcher, T>>(myMatchingMappings);
  for (Pair<FileNameMatcher, T> assoc : copy) {
    if (assoc.getSecond() == type) {
      myMatchingMappings.remove(assoc);
      changed = true;
    }
  }

  return changed;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:FileTypeAssocTable.java


示例2: findAssociatedFileType

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
@Nullable
public T findAssociatedFileType(@NotNull FileNameMatcher matcher) {
  if (matcher instanceof ExtensionFileNameMatcher) {
    return myExtensionMappings.get(((ExtensionFileNameMatcher)matcher).getExtension());
  }

  if (matcher instanceof ExactFileNameMatcher) {
    final ExactFileNameMatcher exactFileNameMatcher = (ExactFileNameMatcher)matcher;

    Map<CharSequence, T> mapToUse = exactFileNameMatcher.isIgnoreCase() ? myExactFileNameAnyCaseMappings : myExactFileNameMappings;
    return mapToUse.get(exactFileNameMatcher.getFileName());
  }

  for (Pair<FileNameMatcher, T> mapping : myMatchingMappings) {
    if (matcher.equals(mapping.getFirst())) return mapping.getSecond();
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:FileTypeAssocTable.java


示例3: filenameMatchesPrefixOrType

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:FilePathCompletionContributor.java


示例4: getState

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
@Override
public Element getState() {
  Element state = new Element("x");
  for (final Language language : TemplateDataLanguageMappings.getTemplateableLanguages()) {
    final List<FileNameMatcher> matchers = myAssocTable.getAssociations(language);
    if (!matchers.isEmpty()) {
      final Element child = new Element("pattern");
      state.addContent(child);
      child.setAttribute("value", StringUtil.join(matchers, new Function<FileNameMatcher, String>() {
        @Override
        public String fun(FileNameMatcher fileNameMatcher) {
          return fileNameMatcher.getPresentableString();
        }
      }, SEPARATOR));
      child.setAttribute("lang", language.getID());
    }
  }
  return state;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TemplateDataLanguagePatterns.java


示例5: findPyFileInDir

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
@Nullable
private static PsiFile findPyFileInDir(PsiDirectory dir, String referencedName) {
  PsiFile file = dir.findFile(referencedName + PyNames.DOT_PY);
  if (file == null) {
    final List<FileNameMatcher> associations = FileTypeManager.getInstance().getAssociations(PythonFileType.INSTANCE);
    for (FileNameMatcher association : associations) {
      if (association instanceof ExtensionFileNameMatcher) {
        file = dir.findFile(referencedName + "." + ((ExtensionFileNameMatcher)association).getExtension());
        if (file != null) break;
      }
    }
  }
  if (file != null && FileUtil.getNameWithoutExtension(file.getName()).equals(referencedName)) {
    return file;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ResolveImportUtil.java


示例6: FileTypeAssocTable

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
private FileTypeAssocTable(Map<String, T> extensionMappings, Map<String, T> exactFileNameMappings, Map<String, T> exactFileNameAnyCaseMappings, List<Pair<FileNameMatcher, T>> matchingMappings) {
  myExtensionMappings = new THashMap<String, T>(extensionMappings);
  myExactFileNameMappings = new THashMap<String, T>(exactFileNameMappings);
  myExactFileNameAnyCaseMappings = new THashMap<String, T>(exactFileNameAnyCaseMappings, CaseInsensitiveStringHashingStrategy.INSTANCE) {
    @Override
    public T remove(Object key) {
      T removed = super.remove(key);
      myHasAnyCaseExactMappings = size() > 0;
      return removed;
    }

    @Override
    public T put(String key, T value) {
      T result = super.put(key, value);
      myHasAnyCaseExactMappings = true;
      return result;
    }
  };
  myMatchingMappings = new ArrayList<Pair<FileNameMatcher, T>>(matchingMappings);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:FileTypeAssocTable.java


示例7: addAssociation

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
public void addAssociation(FileNameMatcher matcher, T type) {
  if (matcher instanceof ExtensionFileNameMatcher) {
    myExtensionMappings.put(((ExtensionFileNameMatcher)matcher).getExtension(), type);
  }
  else if (matcher instanceof ExactFileNameMatcher) {
    final ExactFileNameMatcher exactFileNameMatcher = (ExactFileNameMatcher)matcher;

    if (exactFileNameMatcher.isIgnoreCase()) {
      myExactFileNameAnyCaseMappings.put(exactFileNameMatcher.getFileName(), type);
    } else {
      myExactFileNameMappings.put(exactFileNameMatcher.getFileName(), type);
    }
  } else {
    myMatchingMappings.add(new Pair<FileNameMatcher, T>(matcher, type));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:FileTypeAssocTable.java


示例8: removeAllAssociations

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
public boolean removeAllAssociations(T type) {
  boolean changed = removeAssociationsFromMap(myExtensionMappings, type, false);

  changed = removeAssociationsFromMap(myExactFileNameAnyCaseMappings, type, changed);
  changed = removeAssociationsFromMap(myExactFileNameMappings, type, changed);

  List<Pair<FileNameMatcher, T>> copy = new ArrayList<Pair<FileNameMatcher, T>>(myMatchingMappings);
  for (Pair<FileNameMatcher, T> assoc : copy) {
    if (assoc.getSecond() == type) {
      myMatchingMappings.remove(assoc);
      changed = true;
    }
  }

  return changed;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:FileTypeAssocTable.java


示例9: findAssociatedFileType

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
@Nullable
public T findAssociatedFileType(@NotNull @NonNls String fileName) {
  T t = myExactFileNameMappings.get(fileName);
  if (t != null) return t;

  if (myHasAnyCaseExactMappings) {   // even hash lookup with case insensitive hasher is costly for isIgnored checks during compile
    t = myExactFileNameAnyCaseMappings.get(fileName);
    if (t != null) return t;
  }

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, n = myMatchingMappings.size(); i < n; i++) {
    final Pair<FileNameMatcher, T> mapping = myMatchingMappings.get(i);
    if (mapping.getFirst().accept(fileName)) return mapping.getSecond();
  }

  return myExtensionMappings.get(StringUtil.toLowerCase(FileUtilRt.getExtension(fileName)));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:FileTypeAssocTable.java


示例10: filenameMatchesPrefixOrType

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
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) {
      final List<FileNameMatcher> matchers = FileTypeManager.getInstance().getAssociations(fileType);
      for (final FileNameMatcher matcher : matchers) {
        if (matcher.accept(fileName)) return true;
      }
    }
  }

  return false;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:FilePathCompletionContributor.java


示例11: FileTypeAssocTable

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
private FileTypeAssocTable(Map<CharSequence, T> extensionMappings, Map<CharSequence, T> exactFileNameMappings, Map<CharSequence, T> exactFileNameAnyCaseMappings, List<Pair<FileNameMatcher, T>> matchingMappings) {
  myExtensionMappings = new THashMap<CharSequence, T>(extensionMappings, CharSequenceHashingStrategy.CASE_INSENSITIVE);

  myExactFileNameMappings = new THashMap<CharSequence, T>(exactFileNameMappings, CharSequenceHashingStrategy.CASE_SENSITIVE);

  myExactFileNameAnyCaseMappings = new THashMap<CharSequence, T>(exactFileNameAnyCaseMappings, CharSequenceHashingStrategy.CASE_INSENSITIVE) {
    @Override
    public T remove(Object key) {
      T removed = super.remove(key);
      myHasAnyCaseExactMappings = size() > 0;
      return removed;
    }

    @Override
    public T put(CharSequence key, T value) {
      T result = super.put(key, value);
      myHasAnyCaseExactMappings = true;
      return result;
    }
  };
  myMatchingMappings = new ArrayList<Pair<FileNameMatcher, T>>(matchingMappings);
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:FileTypeAssocTable.java


示例12: findAssociatedFileType

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
@Nullable
public T findAssociatedFileType(@Nonnull @NonNls CharSequence fileName) {
  T t = myExactFileNameMappings.get(fileName);
  if (t != null) return t;

  if (myHasAnyCaseExactMappings) {   // even hash lookup with case insensitive hasher is costly for isIgnored checks during compile
    t = myExactFileNameAnyCaseMappings.get(fileName);
    if (t != null) return t;
  }

  //noinspection ForLoopReplaceableByForEach
  for (int i = 0, n = myMatchingMappings.size(); i < n; i++) {
    final Pair<FileNameMatcher, T> mapping = myMatchingMappings.get(i);
    if (mapping.getFirst().accept(fileName)) return mapping.getSecond();
  }

  return myExtensionMappings.get(FileUtilRt.getExtension(fileName));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:19,代码来源:FileTypeAssocTable.java


示例13: filenameMatchesPrefixOrType

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
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 (matcher.accept(fileName)) return true;
      }
    }
  }

  return false;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:FilePathCompletionContributor.java


示例14: createFileTypes

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
@Override
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
	fileTypeConsumer.consume(EmojiResourceFileType.INSTANCE, new FileNameMatcher() {
		@Override
		public boolean accept(@NotNull String s) {
			return s.equals(".emojirc");
		}

		@NotNull
		@Override
		public String getPresentableString() {
			return ".emojirc";
		}
	});
}
 
开发者ID:syuchan1005,项目名称:EmojiPrefix,代码行数:16,代码来源:EmojiResourceFileTypeFactory.java


示例15: createFileTypes

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
    super.createFileTypes(fileTypeConsumer);
    fileTypeConsumer.consume(CloudSlangFileType.INSTANCE, new FileNameMatcher() {
        @Override
        public boolean accept(@NonNls @NotNull String s) {
            return CloudSlangFileUtils.isCloudSlangFile(s);
        }

        @NotNull
        @Override
        public String getPresentableString() {
            return "sl;sl.yaml;sl.yml;prop.sl";
        }
    });
}
 
开发者ID:CloudSlang,项目名称:cs-intellij-plugin,代码行数:16,代码来源:CloudSlangFileTypeFactory.java


示例16: parse

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
@NotNull
private List<FileNameMatcher> parse(@Nullable String semicolonDelimited) {
    if (semicolonDelimited == null) {
        return Collections.emptyList();
    }

    StringTokenizer tokenizer = new StringTokenizer(semicolonDelimited, FileTypeConsumer.EXTENSION_DELIMITER, false);
    ArrayList<FileNameMatcher> list = new ArrayList<>();
    while (tokenizer.hasMoreTokens()) {
        list.add(new ExtensionFileNameMatcher(tokenizer.nextToken().trim()));
    }
    return list;
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:14,代码来源:ProtostuffPluginController.java


示例17: match

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
boolean match(String filename) {
    for (FileNameMatcher matcher : matchers) {
        if (matcher.accept(filename)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:9,代码来源:ProtostuffPluginController.java


示例18: createMatcher

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
@NotNull
public FileNameMatcher createMatcher(@NotNull String pattern) {
  if (pattern.startsWith("*.") &&
      pattern.indexOf('*', 2) < 0 &&
      pattern.indexOf('.', 2) < 0 &&
      pattern.indexOf('?', 2) < 0) {
    return new ExtensionFileNameMatcher(pattern.substring(2).toLowerCase());
  }

  if (pattern.contains("*") || pattern.contains("?")) {
    return new WildcardFileNameMatcher(pattern);
  }

  return new ExactFileNameMatcher(pattern);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:FileNameMatcherFactoryImpl.java


示例19: FileTypeAssocTable

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
private FileTypeAssocTable(@NotNull Map<CharSequence, T> extensionMappings,
                           @NotNull Map<CharSequence, T> exactFileNameMappings,
                           @NotNull Map<CharSequence, T> exactFileNameAnyCaseMappings,
                           @NotNull List<Pair<FileNameMatcher, T>> matchingMappings) {
  myExtensionMappings = new THashMap<CharSequence, T>(Math.max(10, extensionMappings.size()), 0.5f, CharSequenceHashingStrategy.CASE_INSENSITIVE);
  myExtensionMappings.putAll(extensionMappings);
  myExactFileNameMappings = new THashMap<CharSequence, T>(Math.max(10, exactFileNameMappings.size()), 0.5f, CharSequenceHashingStrategy.CASE_SENSITIVE);
  myExactFileNameMappings.putAll(exactFileNameMappings);
  myExactFileNameAnyCaseMappings = new THashMap<CharSequence, T>(Math.max(10, exactFileNameAnyCaseMappings.size()), 0.5f, CharSequenceHashingStrategy.CASE_INSENSITIVE);
  myExactFileNameAnyCaseMappings.putAll(exactFileNameAnyCaseMappings);

  myMatchingMappings = new ArrayList<Pair<FileNameMatcher, T>>(matchingMappings);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:FileTypeAssocTable.java


示例20: isAssociatedWith

import com.intellij.openapi.fileTypes.FileNameMatcher; //导入依赖的package包/类
public boolean isAssociatedWith(@NotNull T type, @NotNull FileNameMatcher matcher) {
  if (matcher instanceof ExtensionFileNameMatcher || matcher instanceof ExactFileNameMatcher) {
    return findAssociatedFileType(matcher) == type;
  }

  for (Pair<FileNameMatcher, T> mapping : myMatchingMappings) {
    if (matcher.equals(mapping.getFirst()) && type == mapping.getSecond()) return true;
  }

  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:FileTypeAssocTable.java



注:本文中的com.intellij.openapi.fileTypes.FileNameMatcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HadoopYarnProtoRPC类代码示例发布时间:2022-05-22
下一篇:
Java Grammar类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap