@RequiredReadAction @Nullable @Override public EditorNotificationPanel createNotificationPanel(@Nonnull VirtualFile file, @Nonnull FileEditor fileEditor) { if (file.getFileType() != PlainTextFileType.INSTANCE && !(file.getFileType() instanceof AbstractFileType)) return null; final String extension = file.getExtension(); if (extension == null) { return null; } if (myEnabledExtensions.contains(extension) || UnknownFeaturesCollector.getInstance(myProject).isIgnored(createFileFeatureForIgnoring(file))) return null; UnknownExtension fileFeatureForChecking = new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), file.getName()); List<IdeaPluginDescriptor> allPlugins = PluginsAdvertiserHolder.getLoadedPluginDescriptors(); Set<IdeaPluginDescriptor> byFeature = PluginsAdvertiser.findByFeature(allPlugins, fileFeatureForChecking); if (!byFeature.isEmpty()) { return createPanel(file, byFeature, allPlugins); } return null; }
private static boolean isMyFeature(String value, UnknownExtension feature) { if (feature.getExtensionKey().equals(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName())) { FileNameMatcher matcher = FileNameMatcherFactory.getInstance().createMatcher(value); return matcher.accept(feature.getValue()); } else { return value.equals(feature.getValue()); } }
private static UnknownFeature createExtensionFeature(String extension) { return new UnknownFeature(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), "File Type", extension); }
@Nonnull private static UnknownExtension createFileFeatureForIgnoring(VirtualFile virtualFile) { return new UnknownExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP.getName(), "*." + virtualFile.getExtension()); }