当前位置: 首页>>代码示例>>Java>>正文


Java FileNameMatcher类代码示例

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


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


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