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

项目:intellij-ce-playground    文件:FileTypeAssocTable.java   
@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;
}
项目:tools-idea    文件:FileTypeAssocTable.java   
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));
  }
}
项目:tools-idea    文件:FileTypeAssocTable.java   
@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;
}
项目:idea-gitignore    文件:IgnoreManager.java   
/**
 * Associates given file with proper {@link IgnoreFileType}.
 *
 * @param fileName to associate
 * @param fileType file type to bind with pattern
 */
public static void associateFileType(@NotNull final String fileName, @NotNull final IgnoreFileType fileType) {
    final Application application = ApplicationManager.getApplication();
    if (application.isDispatchThread()) {
        final FileTypeManager fileTypeManager = FileTypeManager.getInstance();
        application.invokeLater(new Runnable() {
            @Override
            public void run() {
                application.runWriteAction(new Runnable() {
                    @Override
                    public void run() {
                        fileTypeManager.associate(fileType, new ExactFileNameMatcher(fileName));
                        FILE_TYPES_ASSOCIATION_QUEUE.remove(fileName);
                    }
                });
            }
        }, ModalityState.NON_MODAL);
    } else if (!FILE_TYPES_ASSOCIATION_QUEUE.containsKey(fileName)) {
        FILE_TYPES_ASSOCIATION_QUEUE.put(fileName, fileType);
    }
}
项目:consulo    文件:FileTypeAssocTable.java   
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));
  }
}
项目:consulo    文件:FileTypeAssocTable.java   
@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;
}
项目:intellij-ce-playground    文件:FileNameMatcherFactoryImpl.java   
@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);
}
项目:intellij-ce-playground    文件:FileTypeAssocTable.java   
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;
}
项目:intellij-ce-playground    文件:FileTypeAssocTable.java   
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));
  }
}
项目:intellij-ce-playground    文件:FileTypeAssocTable.java   
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;
}
项目:tools-idea    文件:FileNameMatcherFactoryImpl.java   
@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);
}
项目:tools-idea    文件:FileTypeAssocTable.java   
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;
}
项目:tools-idea    文件:FileTypeAssocTable.java   
public boolean removeAssociation(FileNameMatcher matcher, 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;
    final Map<String, T> mapToUse;
    String fileName = exactFileNameMatcher.getFileName();

    if (exactFileNameMatcher.isIgnoreCase()) {
      mapToUse = myExactFileNameAnyCaseMappings;
    } else {
      mapToUse = 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;
}
项目:consulo    文件:FileTypeAssocTable.java   
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;
}
项目:consulo    文件:FileTypeAssocTable.java   
public boolean removeAssociation(FileNameMatcher matcher, 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;
    final Map<CharSequence, T> mapToUse;
    String fileName = exactFileNameMatcher.getFileName();

    if (exactFileNameMatcher.isIgnoreCase()) {
      mapToUse = myExactFileNameAnyCaseMappings;
    } else {
      mapToUse = 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;
}
项目:intellij-plugin    文件:CoffigYamlFileTypeFactory.java   
@Override
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
    fileTypeConsumer.consume(CoffigYamlFileType.INSTANCE, new ExactFileNameMatcher("application.yaml"), new ExactFileNameMatcher("application.yml"));
}
项目:stylint-plugin    文件:StylintConfigFileTypeFactory.java   
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
    consumer.consume(StylintConfigFileType.INSTANCE, new ExactFileNameMatcher(StylintConfigFileType.STYLINTRC));
}
项目:intellij-ce-playground    文件:BuildoutCfgFileTypeFactory.java   
public void createFileTypes(final @NotNull FileTypeConsumer consumer) {
  consumer.consume(BuildoutCfgFileType.INSTANCE, new ExactFileNameMatcher(BuildoutFacet.BUILDOUT_CFG, true));
}
项目:intellij-ce-playground    文件:GitFileTypeFactory.java   
/**
 * {@inheritDoc}
 */
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
  consumer.consume(PlainTextFileType.INSTANCE, new ExactFileNameMatcher(".gitignore"), new ExactFileNameMatcher(".gitmodules"));
}
项目:intellij-ce-playground    文件:DGMFileTypeFactory.java   
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
  ExactFileNameMatcher matcher = new ExactFileNameMatcher(GroovyExtensionProvider.ORG_CODEHAUS_GROOVY_RUNTIME_EXTENSION_MODULE,
                                                          !SystemInfo.isFileSystemCaseSensitive);
  consumer.consume(PropertiesFileType.INSTANCE, matcher);
}
项目:intellij    文件:BazelBuildSystemProvider.java   
@Override
public ImmutableList<FileNameMatcher> buildLanguageFileTypeMatchers() {
  return ImmutableList.of(
      new ExactFileNameMatcher("BUILD"), new ExactFileNameMatcher("BUILD.bazel"),
      new ExtensionFileNameMatcher("bzl"), new ExactFileNameMatcher("WORKSPACE"));
}
项目:coffee-lint-plugin    文件:CoffeeLintConfigFileTypeFactory.java   
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
    consumer.consume(CoffeeLintConfigFileType.INSTANCE, new ExactFileNameMatcher(CoffeeLintConfigFileType.COFFEE_LINT_CONFIG));
}
项目:eslint-plugin    文件:ESLintConfigFileTypeFactory.java   
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
        consumer.consume(ESLintConfigFileType.INSTANCE, new ExactFileNameMatcher(ESLintConfigFileType.ESLINTRC));
//                new ExtensionFileNameMatcher(ESLintConfigFileType.ESLINTRC), new ExactFileNameMatcher("eslint.json"));
    }
项目:tools-idea    文件:GitFileTypeFactory.java   
/**
 * {@inheritDoc}
 */
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
  consumer.consume(PlainTextFileType.INSTANCE, new ExactFileNameMatcher(".gitignore"), new ExactFileNameMatcher(".gitmodules"));
}
项目:tools-idea    文件:DGMFileTypeFactory.java   
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
  ExactFileNameMatcher matcher = new ExactFileNameMatcher(GroovyExtensionProvider.ORG_CODEHAUS_GROOVY_RUNTIME_EXTENSION_MODULE,
                                                          !SystemInfo.isFileSystemCaseSensitive);
  consumer.consume(PropertiesFileType.INSTANCE, matcher);
}
项目:lombok-intellij-plugin    文件:LombokConfigFileTypeFactory.java   
@Override
public void createFileTypes(@NotNull FileTypeConsumer fileTypeConsumer) {
  fileTypeConsumer.consume(LombokConfigFileType.INSTANCE, new ExactFileNameMatcher("lombok.config"));
}
项目:idea-gitignore    文件:IgnoreFileTypeFactory.java   
/**
 * Shorthand for consuming ignore file types.
 *
 * @param consumer file types consumer
 * @param fileType file type to consume
 */
private void consume(@NotNull FileTypeConsumer consumer, @NotNull IgnoreFileType fileType) {
    consumer.consume(fileType, new ExactFileNameMatcher(fileType.getIgnoreLanguage().getFilename()));
    consumer.consume(fileType, fileType.getIgnoreLanguage().getExtension());
}