Search in sources :

Example 1 with ExactFileNameMatcher

use of com.intellij.openapi.fileTypes.ExactFileNameMatcher in project intellij-community by JetBrains.

the class DGMFileTypeFactory method createFileTypes.

@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
    ExactFileNameMatcher matcher = new ExactFileNameMatcher(DGMUtil.ORG_CODEHAUS_GROOVY_RUNTIME_EXTENSION_MODULE, !SystemInfo.isFileSystemCaseSensitive);
    consumer.consume(PropertiesFileType.INSTANCE, matcher);
}
Also used : ExactFileNameMatcher(com.intellij.openapi.fileTypes.ExactFileNameMatcher)

Example 2 with ExactFileNameMatcher

use of com.intellij.openapi.fileTypes.ExactFileNameMatcher in project intellij-community by JetBrains.

the class FileTypeAssocTable method findAssociatedFileType.

@Nullable
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;
}
Also used : ExactFileNameMatcher(com.intellij.openapi.fileTypes.ExactFileNameMatcher) ExtensionFileNameMatcher(com.intellij.openapi.fileTypes.ExtensionFileNameMatcher) FileNameMatcher(com.intellij.openapi.fileTypes.FileNameMatcher) ExtensionFileNameMatcher(com.intellij.openapi.fileTypes.ExtensionFileNameMatcher) ExactFileNameMatcher(com.intellij.openapi.fileTypes.ExactFileNameMatcher) Nullable(org.jetbrains.annotations.Nullable)

Example 3 with ExactFileNameMatcher

use of com.intellij.openapi.fileTypes.ExactFileNameMatcher in project intellij-community by JetBrains.

the class FileTypeAssocTable method removeAssociation.

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<>(myMatchingMappings);
    for (Pair<FileNameMatcher, T> assoc : copy) {
        if (matcher.equals(assoc.getFirst())) {
            myMatchingMappings.remove(assoc);
            return true;
        }
    }
    return false;
}
Also used : ExactFileNameMatcher(com.intellij.openapi.fileTypes.ExactFileNameMatcher) ExtensionFileNameMatcher(com.intellij.openapi.fileTypes.ExtensionFileNameMatcher) FileNameMatcher(com.intellij.openapi.fileTypes.FileNameMatcher) ExtensionFileNameMatcher(com.intellij.openapi.fileTypes.ExtensionFileNameMatcher) ExactFileNameMatcher(com.intellij.openapi.fileTypes.ExactFileNameMatcher) Pair(com.intellij.openapi.util.Pair)

Aggregations

ExactFileNameMatcher (com.intellij.openapi.fileTypes.ExactFileNameMatcher)3 ExtensionFileNameMatcher (com.intellij.openapi.fileTypes.ExtensionFileNameMatcher)2 FileNameMatcher (com.intellij.openapi.fileTypes.FileNameMatcher)2 Pair (com.intellij.openapi.util.Pair)1 Nullable (org.jetbrains.annotations.Nullable)1