本文整理汇总了Java中com.intellij.openapi.fileTypes.ExtensionFileNameMatcher类的典型用法代码示例。如果您正苦于以下问题:Java ExtensionFileNameMatcher类的具体用法?Java ExtensionFileNameMatcher怎么用?Java ExtensionFileNameMatcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExtensionFileNameMatcher类属于com.intellij.openapi.fileTypes包,在下文中一共展示了ExtensionFileNameMatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAssociatedFileType
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的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;
}
示例2: findPyFileInDir
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的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;
}
示例3: addAssociation
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的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));
}
}
示例4: findAssociatedFileType
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的package包/类
@Nullable
public T findAssociatedFileType(final FileNameMatcher matcher) {
if (matcher instanceof ExtensionFileNameMatcher) {
return myExtensionMappings.get(((ExtensionFileNameMatcher)matcher).getExtension());
}
if (matcher instanceof ExactFileNameMatcher) {
final ExactFileNameMatcher exactFileNameMatcher = (ExactFileNameMatcher)matcher;
if (exactFileNameMatcher.isIgnoreCase()) {
return myExactFileNameAnyCaseMappings.get(exactFileNameMatcher.getFileName());
} else {
return myExactFileNameMappings.get(exactFileNameMatcher.getFileName());
}
}
for (Pair<FileNameMatcher, T> mapping : myMatchingMappings) {
if (matcher.equals(mapping.getFirst())) return mapping.getSecond();
}
return null;
}
示例5: accept
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的package包/类
@Override
public boolean accept(VirtualFile file)
{
if(file.isDirectory())
{
return true;
}
for(ExtensionFileNameMatcher matcher : LuaFileType.EXTENSION_FILE_NAME_MATCHERS)
{
if(matcher.accept(file.getName()))
{
return true;
}
}
return false;
}
示例6: parse
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的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;
}
示例7: createMatcher
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的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);
}
示例8: isAssociatedWith
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的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;
}
示例9: addAssociation
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的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;
Map<CharSequence, T> mapToUse = exactFileNameMatcher.isIgnoreCase() ? myExactFileNameAnyCaseMappings : myExactFileNameMappings;
mapToUse.put(exactFileNameMatcher.getFileName(), type);
}
else {
myMatchingMappings.add(Pair.create(matcher, type));
}
}
示例10: removeAssociation
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的package包/类
boolean removeAssociation(@NotNull FileNameMatcher matcher, @NotNull T type) {
if (matcher instanceof ExtensionFileNameMatcher) {
String extension = ((ExtensionFileNameMatcher)matcher).getExtension();
if (myExtensionMappings.get(extension) == type) {
myExtensionMappings.remove(extension);
return true;
}
return false;
}
if (matcher instanceof ExactFileNameMatcher) {
final ExactFileNameMatcher exactFileNameMatcher = (ExactFileNameMatcher)matcher;
String fileName = exactFileNameMatcher.getFileName();
final Map<CharSequence, T> mapToUse = exactFileNameMatcher.isIgnoreCase() ? myExactFileNameAnyCaseMappings : myExactFileNameMappings;
if(mapToUse.get(fileName) == type) {
mapToUse.remove(fileName);
return true;
}
return false;
}
List<Pair<FileNameMatcher, T>> copy = new ArrayList<Pair<FileNameMatcher, T>>(myMatchingMappings);
for (Pair<FileNameMatcher, T> assoc : copy) {
if (matcher.equals(assoc.getFirst())) {
myMatchingMappings.remove(assoc);
return true;
}
}
return false;
}
示例11: fileNameMatchers
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的package包/类
public static FileNameMatcher[] fileNameMatchers() {
return new FileNameMatcher[] {
new ExtensionFileNameMatcher(CODE_EXTENSION),
new ExtensionFileNameMatcher(FS_CODE_EXTENSION),
new ExtensionFileNameMatcher(HEADER_EXTENSION),
};
}
示例12: createFileTypes
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的package包/类
@Override
public void createFileTypes(@NotNull final FileTypeConsumer consumer) {
FileNameMatcher[] matchers =
ProjectViewStorageManager.VALID_EXTENSIONS
.stream()
.map(ExtensionFileNameMatcher::new)
.toArray(ExtensionFileNameMatcher[]::new);
consumer.consume(ProjectViewFileType.INSTANCE, matchers);
}
示例13: consume
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的package包/类
/**
* Consumes the file type with only the specified extensions.
*
* @param fileType The file type.
* @param extensions The file extensions, without a leading '.'.
*/
public void consume(final FileType fileType, @NonNls final String... extensions) {
Preconditions.checkNotNull(fileType);
Preconditions.checkNotNull(extensions);
final FileNameMatcher[] matchers = new FileNameMatcher[extensions.length];
for (int i = 0; i < extensions.length; i++) {
matchers[i] = new ExtensionFileNameMatcher(extensions[i]);
}
consume(fileType, matchers);
}
示例14: register
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的package包/类
/**
* Registers the given file type with IntelliJ IDEA.
*
* @param fileType The file type to register.
*/
public static void register(final IMetaborgFileType fileType) {
FileTypeManagerEx.getInstanceEx().registerFileType(fileType);
// Associate the file type with its file extensions.
final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
for (final String ext : fileType.getExtensions()) {
final FileNameMatcher matcher = new ExtensionFileNameMatcher(ext);
fileTypeManager.associate(fileType, matcher);
}
}
示例15: isAssociatedWith
import com.intellij.openapi.fileTypes.ExtensionFileNameMatcher; //导入依赖的package包/类
public boolean isAssociatedWith(T type, 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;
}