Search in sources :

Example 1 with JpsModuleSourceRoot

use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.

the class MavenSourceFoldersModuleExtension method init.

public void init(@NotNull Module module, @NotNull ModifiableRootModel modifiableRootModel) {
    myRootModel = modifiableRootModel;
    myDummyJpsModule = JpsElementFactory.getInstance().createModule(module.getName(), JpsJavaModuleType.INSTANCE, JpsElementFactory.getInstance().createDummyElement());
    myDummyJpsRootModel = new JpsRootModel(module, myDummyJpsModule);
    for (JpsSourceFolder folder : myJpsSourceFolders) {
        Disposer.dispose(folder);
    }
    myJpsSourceFolders.clear();
    for (ContentEntry eachEntry : modifiableRootModel.getContentEntries()) {
        for (SourceFolder eachFolder : eachEntry.getSourceFolders()) {
            //noinspection unchecked
            final JpsModuleSourceRoot jpsModuleSourceRoot = JpsElementFactory.getInstance().createModuleSourceRoot(eachFolder.getUrl(), (JpsModuleSourceRootType<JpsElement>) eachFolder.getRootType(), eachFolder.getJpsElement().getProperties().getBulkModificationSupport().createCopy());
            addJspSourceFolder(jpsModuleSourceRoot, eachFolder.getUrl());
        }
    }
}
Also used : JpsRootModel(com.intellij.project.model.impl.module.JpsRootModel) JpsSourceFolder(com.intellij.project.model.impl.module.content.JpsSourceFolder) JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) JpsElement(org.jetbrains.jps.model.JpsElement) JpsContentEntry(com.intellij.project.model.impl.module.content.JpsContentEntry) JpsSourceFolder(com.intellij.project.model.impl.module.content.JpsSourceFolder)

Example 2 with JpsModuleSourceRoot

use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.

the class JpsContentEntry method addSourceFolder.

@NotNull
public <P extends JpsElement> SourceFolder addSourceFolder(@NotNull String url, @NotNull JpsModuleSourceRootType<P> type, @NotNull P properties) {
    final JpsModuleSourceRoot sourceRoot = myModule.addSourceRoot(url, type, properties);
    final JpsSourceFolder sourceFolder = new JpsSourceFolder(sourceRoot, this);
    mySourceFolders.add(sourceFolder);
    return sourceFolder;
}
Also used : JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with JpsModuleSourceRoot

use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.

the class JpsContentEntry method clearSourceFolders.

@Override
public void clearSourceFolders() {
    List<JpsModuleSourceRoot> toRemove = new ArrayList<>();
    for (JpsSourceFolder folder : mySourceFolders) {
        toRemove.add(folder.getSourceRoot());
        Disposer.dispose(folder);
    }
    mySourceFolders.clear();
    for (JpsModuleSourceRoot root : toRemove) {
        myModule.removeSourceRoot(root.getUrl(), root.getRootType());
    }
}
Also used : JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) ArrayList(java.util.ArrayList)

Example 4 with JpsModuleSourceRoot

use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.

the class JpsContentEntry method addSourceFolder.

@NotNull
@Override
public <P extends JpsElement> SourceFolder addSourceFolder(@NotNull VirtualFile file, @NotNull JpsModuleSourceRootType<P> type, @NotNull P properties) {
    final JpsModuleSourceRoot sourceRoot = myModule.addSourceRoot(file.getUrl(), type, properties);
    final JpsSourceFolder sourceFolder = new JpsSourceFolder(sourceRoot, this);
    mySourceFolders.add(sourceFolder);
    return sourceFolder;
}
Also used : JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with JpsModuleSourceRoot

use of org.jetbrains.jps.model.module.JpsModuleSourceRoot in project intellij-community by JetBrains.

the class JpsIdeaSpecificSettings method readContentEntry.

@Override
public void readContentEntry(Element root, String contentUrl, JpsModule model) {
    for (Object o : root.getChildren(IdeaXml.TEST_FOLDER_TAG)) {
        final String url = ((Element) o).getAttributeValue(IdeaXml.URL_ATTR);
        JpsModuleSourceRoot folderToBeTest = null;
        for (JpsModuleSourceRoot folder : model.getSourceRoots()) {
            if (Comparing.strEqual(folder.getUrl(), url)) {
                folderToBeTest = folder;
                break;
            }
        }
        if (folderToBeTest != null) {
            model.removeSourceRoot(folderToBeTest.getUrl(), JavaSourceRootType.SOURCE);
        }
        model.addSourceRoot(url, JavaSourceRootType.TEST_SOURCE);
    }
    for (Object o : root.getChildren(IdeaXml.EXCLUDE_FOLDER_TAG)) {
        final String excludeUrl = ((Element) o).getAttributeValue(IdeaXml.URL_ATTR);
        if (FileUtil.isAncestor(new File(contentUrl), new File(excludeUrl), false)) {
            model.getExcludeRootsList().addUrl(excludeUrl);
        }
    }
    for (Object o : root.getChildren(IdeaXml.PACKAGE_PREFIX_TAG)) {
        Element ppElement = (Element) o;
        final String prefix = ppElement.getAttributeValue(IdeaXml.PACKAGE_PREFIX_VALUE_ATTR);
        final String url = ppElement.getAttributeValue(IdeaXml.URL_ATTR);
        for (JpsModuleSourceRoot sourceRoot : model.getSourceRoots()) {
            if (Comparing.strEqual(sourceRoot.getUrl(), url)) {
                JpsElement properties = sourceRoot.getProperties();
                if (properties instanceof JavaSourceRootProperties) {
                    ((JavaSourceRootProperties) properties).setPackagePrefix(prefix);
                }
                break;
            }
        }
    }
}
Also used : JpsModuleSourceRoot(org.jetbrains.jps.model.module.JpsModuleSourceRoot) JpsElement(org.jetbrains.jps.model.JpsElement) JpsElement(org.jetbrains.jps.model.JpsElement) Element(org.jdom.Element) File(java.io.File)

Aggregations

JpsModuleSourceRoot (org.jetbrains.jps.model.module.JpsModuleSourceRoot)24 File (java.io.File)10 NotNull (org.jetbrains.annotations.NotNull)8 JpsElement (org.jetbrains.jps.model.JpsElement)5 JavaSourceRootProperties (org.jetbrains.jps.model.java.JavaSourceRootProperties)5 SourceFolder (com.intellij.openapi.roots.SourceFolder)4 JpsModule (org.jetbrains.jps.model.module.JpsModule)4 ArrayList (java.util.ArrayList)3 JpsSourceFolder (com.intellij.project.model.impl.module.content.JpsSourceFolder)2 THashSet (gnu.trove.THashSet)2 Element (org.jdom.Element)2 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)2 ApplicationStarter (com.intellij.openapi.application.ApplicationStarter)1 PathManager (com.intellij.openapi.application.PathManager)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 com.intellij.openapi.projectRoots (com.intellij.openapi.projectRoots)1 JavaDependentSdkType (com.intellij.openapi.projectRoots.impl.JavaDependentSdkType)1