Search in sources :

Example 1 with JavaSourceRootType

use of org.jetbrains.jps.model.java.JavaSourceRootType in project intellij-community by JetBrains.

the class MavenSourceFoldersModuleExtension method commit.

@Override
public void commit() {
    if (!isJpsSourceFoldersChanged)
        return;
    for (ContentEntry eachEntry : myRootModel.getContentEntries()) {
        for (SourceFolder eachFolder : eachEntry.getSourceFolders()) {
            boolean found = false;
            for (JpsSourceFolder jpsSourceFolder : myJpsSourceFolders) {
                if (StringUtil.equals(jpsSourceFolder.getUrl(), eachFolder.getUrl()) && eachFolder.getRootType().equals(jpsSourceFolder.getRootType())) {
                    found = true;
                    if (eachFolder.getRootType() instanceof JavaSourceRootType) {
                        final JavaSourceRootProperties jpsJavaSourceRootProperties = jpsSourceFolder.getJpsElement().getProperties((JavaSourceRootType) eachFolder.getRootType());
                        final JavaSourceRootProperties javaSourceRootProperties = eachFolder.getJpsElement().getProperties((JavaSourceRootType) eachFolder.getRootType());
                        if (javaSourceRootProperties != null && jpsJavaSourceRootProperties != null) {
                            javaSourceRootProperties.applyChanges(jpsJavaSourceRootProperties);
                        }
                    }
                    myJpsSourceFolders.remove(jpsSourceFolder);
                    Disposer.dispose(jpsSourceFolder);
                    break;
                }
            }
            if (!found) {
                eachEntry.removeSourceFolder(eachFolder);
            }
        }
    }
    for (JpsSourceFolder jpsSourceFolder : myJpsSourceFolders) {
        Url url = new Url(jpsSourceFolder.getUrl());
        ContentEntry e = getContentRootFor(url);
        if (e == null)
            continue;
        //noinspection unchecked
        JpsModuleSourceRootType<JpsElement> sourceRootType = (JpsModuleSourceRootType<JpsElement>) jpsSourceFolder.getRootType();
        final JpsElementBase properties = (JpsElementBase) jpsSourceFolder.getSourceRoot().getProperties();
        //noinspection unchecked
        properties.setParent(null);
        e.addSourceFolder(url.getUrl(), sourceRootType, properties);
    }
    isJpsSourceFoldersChanged = false;
}
Also used : JpsSourceFolder(com.intellij.project.model.impl.module.content.JpsSourceFolder) JpsElement(org.jetbrains.jps.model.JpsElement) JpsModuleSourceRootType(org.jetbrains.jps.model.module.JpsModuleSourceRootType) JpsContentEntry(com.intellij.project.model.impl.module.content.JpsContentEntry) JpsElementBase(org.jetbrains.jps.model.ex.JpsElementBase) JpsSourceFolder(com.intellij.project.model.impl.module.content.JpsSourceFolder) JavaSourceRootType(org.jetbrains.jps.model.java.JavaSourceRootType) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties) Url(org.jetbrains.idea.maven.utils.Url)

Example 2 with JavaSourceRootType

use of org.jetbrains.jps.model.java.JavaSourceRootType in project intellij-community by JetBrains.

the class ModuleCompilerUtil method isDummy.

private static boolean isDummy(ModuleSourceSet set, ModulesProvider modulesProvider) {
    JavaSourceRootType type = set.getType() == ModuleSourceSet.Type.PRODUCTION ? JavaSourceRootType.SOURCE : JavaSourceRootType.TEST_SOURCE;
    ModuleRootModel rootModel = modulesProvider.getRootModel(set.getModule());
    for (ContentEntry entry : rootModel.getContentEntries()) {
        if (!entry.getSourceFolders(type).isEmpty()) {
            return false;
        }
    }
    return true;
}
Also used : JavaSourceRootType(org.jetbrains.jps.model.java.JavaSourceRootType)

Example 3 with JavaSourceRootType

use of org.jetbrains.jps.model.java.JavaSourceRootType in project intellij-plugins by JetBrains.

the class FlexResourceBuildTarget method computeRootDescriptors.

@NotNull
@Override
public List<BuildRootDescriptor> computeRootDescriptors(final JpsModel model, final ModuleExcludeIndex index, final IgnoredFileIndex ignoredFileIndex, final BuildDataPaths dataPaths) {
    final List<BuildRootDescriptor> result = new ArrayList<>();
    final JavaSourceRootType rootType = getTargetType() == FlexResourceBuildTargetType.PRODUCTION ? JavaSourceRootType.SOURCE : JavaSourceRootType.TEST_SOURCE;
    for (JpsModuleSourceRoot sourceRoot : getModule().getSourceRoots(rootType)) {
        final File root = JpsPathUtil.urlToFile(sourceRoot.getUrl());
        result.add(new FlexSourceRootDescriptor(this, root));
    }
    return result;
}
Also used : JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) File(java.io.File) JavaSourceRootType(org.jetbrains.jps.model.java.JavaSourceRootType) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with JavaSourceRootType

use of org.jetbrains.jps.model.java.JavaSourceRootType in project intellij-elixir by KronicDeth.

the class ElixirTarget method computeRootDescriptors.

@NotNull
@Override
public List<ElixirSourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
    List<ElixirSourceRootDescriptor> result = new ArrayList<ElixirSourceRootDescriptor>();
    JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
    for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> root : myModule.getSourceRoots(type)) {
        result.add(new ElixirSourceRootDescriptor(root.getFile(), this));
    }
    return result;
}
Also used : JavaSourceRootType(org.jetbrains.jps.model.java.JavaSourceRootType) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with JavaSourceRootType

use of org.jetbrains.jps.model.java.JavaSourceRootType in project intellij-elixir by KronicDeth.

the class Target method computeRootDescriptors.

@NotNull
@Override
public List<SourceRootDescriptor> computeRootDescriptors(JpsModel model, ModuleExcludeIndex index, IgnoredFileIndex ignoredFileIndex, BuildDataPaths dataPaths) {
    List<SourceRootDescriptor> result = new ArrayList<SourceRootDescriptor>();
    JavaSourceRootType type = isTests() ? JavaSourceRootType.TEST_SOURCE : JavaSourceRootType.SOURCE;
    for (JpsTypedModuleSourceRoot<JavaSourceRootProperties> root : myModule.getSourceRoots(type)) {
        result.add(new SourceRootDescriptor(root.getFile(), this));
    }
    return result;
}
Also used : SourceRootDescriptor(org.elixir_lang.jps.builder.SourceRootDescriptor) JavaSourceRootType(org.jetbrains.jps.model.java.JavaSourceRootType) JavaSourceRootProperties(org.jetbrains.jps.model.java.JavaSourceRootProperties) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

JavaSourceRootType (org.jetbrains.jps.model.java.JavaSourceRootType)6 JavaSourceRootProperties (org.jetbrains.jps.model.java.JavaSourceRootProperties)4 NotNull (org.jetbrains.annotations.NotNull)3 JpsContentEntry (com.intellij.project.model.impl.module.content.JpsContentEntry)1 JpsSourceFolder (com.intellij.project.model.impl.module.content.JpsSourceFolder)1 File (java.io.File)1 SourceRootDescriptor (org.elixir_lang.jps.builder.SourceRootDescriptor)1 Url (org.jetbrains.idea.maven.utils.Url)1 JpsElement (org.jetbrains.jps.model.JpsElement)1 JpsElementBase (org.jetbrains.jps.model.ex.JpsElementBase)1 JpsModuleSourceRoot (org.jetbrains.jps.model.module.JpsModuleSourceRoot)1 JpsModuleSourceRootType (org.jetbrains.jps.model.module.JpsModuleSourceRootType)1