Java 类com.intellij.openapi.components.ExportableApplicationComponent 实例源码

项目:tools-idea    文件:ExportSettingsAction.java   
public static Map<File, Set<ExportableComponent>> getRegisteredComponentsAndFiles(List<ExportableComponent> exportableComponents) {
  Map<File,Set<ExportableComponent>> fileToComponents = new HashMap<File, Set<ExportableComponent>>();

  final List<ExportableComponent> components = new ArrayList<ExportableComponent>(Arrays.asList(ApplicationManager.getApplication().getComponents(ExportableApplicationComponent.class)));

  components.addAll(ServiceBean.loadServicesFromBeans(ExportableComponent.EXTENSION_POINT, ExportableComponent.class));

  for (ExportableComponent component : components) {
    exportableComponents.add(component);
    final File[] exportFiles = component.getExportFiles();
    for (File exportFile : exportFiles) {
      Set<ExportableComponent> componentsTied = fileToComponents.get(exportFile);
      if (componentsTied == null) {
        componentsTied = new HashSet<ExportableComponent>();
        fileToComponents.put(exportFile, componentsTied);
      }
      componentsTied.add(component);
    }
  }
  return fileToComponents;
}