use of org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer in project Perl5-IDEA by Camelcade.
the class PerlSourceTypesSerializationExtension method getModuleSourceRootPropertiesSerializers.
@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;
}
use of org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer in project Perl5-IDEA by Camelcade.
the class PerlModuleExtension method loadState.
@Override
public void loadState(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());
}
}
}
use of org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer in project Perl5-IDEA by Camelcade.
the class PerlModuleExtension method getState.
@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;
}
Aggregations