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


Java ExtensionFileNameMatcher类代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:FileTypeAssocTable.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ResolveImportUtil.java

示例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));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:FileTypeAssocTable.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:FileTypeAssocTable.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-lua,代码行数:19,代码来源:LuaFileUtil.java

示例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;
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:14,代码来源:ProtostuffPluginController.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:FileNameMatcherFactoryImpl.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:FileTypeAssocTable.java

示例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));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:FileTypeAssocTable.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:FileTypeAssocTable.java

示例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),
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:AndroidRenderscriptFileType.java

示例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);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:10,代码来源:ProjectViewFileTypeFactory.java

示例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);
}
 
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:17,代码来源:MetaborgFileTypeConsumer.java

示例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);
    }
}
 
开发者ID:metaborg,项目名称:spoofax-intellij,代码行数:16,代码来源:FileTypeUtils.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:FileTypeAssocTable.java


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