Search in sources :

Example 1 with JpsModuleSourceRootPropertiesSerializer

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;
}
Also used : JpsModelSerializerExtension(org.jetbrains.jps.model.serialization.JpsModelSerializerExtension) List(java.util.List) JpsModuleSourceRootDummyPropertiesSerializer(org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootDummyPropertiesSerializer) ContainerUtil(com.intellij.util.containers.ContainerUtil) NotNull(org.jetbrains.annotations.NotNull) Perl5SettingsConfigurableExtension(com.perl5.lang.perl.idea.configuration.settings.sdk.Perl5SettingsConfigurableExtension) JpsModuleSourceRootPropertiesSerializer(org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer) JpsModuleSourceRootDummyPropertiesSerializer(org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootDummyPropertiesSerializer) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with JpsModuleSourceRootPropertiesSerializer

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());
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JpsModuleSourceRootPropertiesSerializer(org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer) Element(org.jdom.Element) PathMacroManager(com.intellij.openapi.components.PathMacroManager) ModulePathMacroManager(com.intellij.openapi.components.impl.ModulePathMacroManager) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 3 with JpsModuleSourceRootPropertiesSerializer

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) JpsModuleSourceRootPropertiesSerializer(org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer) Element(org.jdom.Element) PathMacroManager(com.intellij.openapi.components.PathMacroManager) ModulePathMacroManager(com.intellij.openapi.components.impl.ModulePathMacroManager) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

JpsModuleSourceRootPropertiesSerializer (org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootPropertiesSerializer)3 PathMacroManager (com.intellij.openapi.components.PathMacroManager)2 ModulePathMacroManager (com.intellij.openapi.components.impl.ModulePathMacroManager)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Element (org.jdom.Element)2 ContainerUtil (com.intellij.util.containers.ContainerUtil)1 Perl5SettingsConfigurableExtension (com.perl5.lang.perl.idea.configuration.settings.sdk.Perl5SettingsConfigurableExtension)1 File (java.io.File)1 List (java.util.List)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1 JpsModelSerializerExtension (org.jetbrains.jps.model.serialization.JpsModelSerializerExtension)1 JpsModuleSourceRootDummyPropertiesSerializer (org.jetbrains.jps.model.serialization.module.JpsModuleSourceRootDummyPropertiesSerializer)1