@NotNull @Override public List<? extends JpsModuleSourceRootPropertiesSerializer<?>> getModuleSourceRootPropertiesSerializers() { return Collections.singletonList(new JpsModuleSourceRootDummyPropertiesSerializer(DLanguageIncludeSourceRootType.INSTANCE, "dlanguage-include")); }
@Override public void loadState(@NotNull Element state) { state = state.getChild(PERL_CONFIG); myRoots.clear(); if (state == null) { return; } PathMacroManager macroManager = ModulePathMacroManager.getInstance(myModule); for (Element pathElement : state.getChildren(ELEMENT_PATH)) { JpsModuleSourceRootPropertiesSerializer serializer = SERIALIZER_BY_ID_MAP.get(pathElement.getAttributeValue(ATTRIBUTE_TYPE)); if (serializer == null) { continue; } String expandedPath = macroManager.expandPath(pathElement.getAttributeValue(ATTRIBUTE_VALUE)); VirtualFile libRoot = VfsUtil.findFileByIoFile(new File(expandedPath), true); if (libRoot != null && libRoot.isValid() && libRoot.isDirectory()) { myRoots.put(libRoot, (PerlSourceRootType)serializer.getType()); } } }
@Nullable @Override public Element getState() { Element perlConfig = new Element(PERL_CONFIG); PathMacroManager macroManager = ModulePathMacroManager.getInstance(myModule); for (VirtualFile root : myRoots.keySet()) { if (!root.isValid() || !root.isDirectory()) { continue; } JpsModuleSourceRootPropertiesSerializer serializer = SERIALIZER_BY_TYPE_MAP.get(myRoots.get(root)); if (serializer == null) { continue; } String collapsedPath = macroManager.collapsePath(root.getCanonicalPath()); if (StringUtil.isEmpty(collapsedPath)) { continue; } Element pathElement = new Element(ELEMENT_PATH); pathElement.setAttribute(ATTRIBUTE_VALUE, collapsedPath); pathElement.setAttribute(ATTRIBUTE_TYPE, serializer.getTypeId()); perlConfig.addContent(pathElement); } Element root = new Element("root"); if (!perlConfig.getChildren().isEmpty()) { root.addContent(perlConfig); } return root; }
@NotNull @Override public List<? extends JpsModuleSourceRootPropertiesSerializer<?>> getModuleSourceRootPropertiesSerializers() { List<JpsModuleSourceRootDummyPropertiesSerializer> result = ContainerUtil.newArrayList(); Perl5SettingsConfigurableExtension.forEach(extension -> extension.getSourceRootTypes().forEach( type -> result.add(new JpsModuleSourceRootDummyPropertiesSerializer(type, type.getSerializationKey())) )); return result; } }