Search in sources :

Example 16 with ContentEntry

use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.

the class NonAndroidModuleNode method getNonEmptySourceTypes.

private static Set<NonAndroidSourceType> getNonEmptySourceTypes(Module module) {
    ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
    Set<NonAndroidSourceType> sourceTypes = Sets.newHashSetWithExpectedSize(NonAndroidSourceType.values().length);
    ContentEntry[] contentEntries = rootManager.getContentEntries();
    for (ContentEntry entry : contentEntries) {
        for (NonAndroidSourceType type : NonAndroidSourceType.values()) {
            for (SourceFolder sourceFolder : entry.getSourceFolders(type.rootType)) {
                if (sourceFolder.getFile() != null) {
                    sourceTypes.add(type);
                    break;
                }
            }
        }
    }
    return sourceTypes;
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) ContentEntry(com.intellij.openapi.roots.ContentEntry) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager)

Example 17 with ContentEntry

use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.

the class ExcludedRoots method addFolderPathsFromExcludedModules.

private void addFolderPathsFromExcludedModules() {
    for (Module module : myExcludedModules) {
        ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
        for (ContentEntry entry : rootManager.getContentEntries()) {
            for (SourceFolder sourceFolder : entry.getSourceFolders()) {
                myExcludedRoots.add(urlToFilePath(sourceFolder.getUrl()));
            }
            CompilerModuleExtension compiler = rootManager.getModuleExtension(CompilerModuleExtension.class);
            String url = compiler.getCompilerOutputUrl();
            if (isNotEmpty(url)) {
                myExcludedRoots.add(urlToFilePath(url));
            }
        }
        AndroidModuleModel androidModuleModel = AndroidModuleModel.get(module);
        if (androidModuleModel != null) {
            myExcludedRoots.add(androidModuleModel.getMainArtifact().getJavaResourcesFolder());
        }
    }
}
Also used : SourceFolder(com.intellij.openapi.roots.SourceFolder) ContentEntry(com.intellij.openapi.roots.ContentEntry) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) Module(com.intellij.openapi.module.Module) CompilerModuleExtension(com.intellij.openapi.roots.CompilerModuleExtension)

Example 18 with ContentEntry

use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.

the class ContentRootsModuleSetupStep method findContentEntries.

@NotNull
private static List<ContentEntry> findContentEntries(@NotNull ModifiableRootModel moduleModel, @NotNull JavaModuleModel javaModuleModel) {
    removeExistingContentEntries(moduleModel);
    List<ContentEntry> contentEntries = new ArrayList<>();
    for (JavaModuleContentRoot contentRoot : javaModuleModel.getContentRoots()) {
        File rootDirPath = contentRoot.getRootDirPath();
        ContentEntry contentEntry = moduleModel.addContentEntry(pathToIdeaUrl(rootDirPath));
        contentEntries.add(contentEntry);
    }
    return contentEntries;
}
Also used : ContentEntry(com.intellij.openapi.roots.ContentEntry) ArrayList(java.util.ArrayList) JavaModuleContentRoot(com.android.tools.idea.gradle.model.java.JavaModuleContentRoot) File(java.io.File) NotNull(org.jetbrains.annotations.NotNull)

Example 19 with ContentEntry

use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.

the class ContentRootsModuleSetupStep method doSetUpModule.

@Override
protected void doSetUpModule(@NotNull Module module, @NotNull IdeModifiableModelsProvider ideModelsProvider, @NotNull JavaModuleModel javaModuleModel, @Nullable SyncAction.ModuleModels gradleModels, @Nullable ProgressIndicator indicator) {
    ModifiableRootModel moduleModel = ideModelsProvider.getModifiableRootModel(module);
    JavaContentEntriesSetup setup = new JavaContentEntriesSetup(javaModuleModel, moduleModel);
    List<ContentEntry> contentEntries = findContentEntries(moduleModel, javaModuleModel);
    setup.execute(contentEntries);
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) ContentEntry(com.intellij.openapi.roots.ContentEntry)

Example 20 with ContentEntry

use of com.intellij.openapi.roots.ContentEntry in project android by JetBrains.

the class ContentRootModuleSetupStep method findContentEntries.

@NotNull
private static List<ContentEntry> findContentEntries(@NotNull ModifiableRootModel moduleModel, @NotNull NdkModuleModel ndkModuleModel) {
    removeExistingContentEntries(moduleModel);
    ContentEntry contentEntry = moduleModel.addContentEntry(pathToIdeaUrl(ndkModuleModel.getRootDirPath()));
    return Collections.singletonList(contentEntry);
}
Also used : ContentEntry(com.intellij.openapi.roots.ContentEntry) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ContentEntry (com.intellij.openapi.roots.ContentEntry)60 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)27 VirtualFile (com.intellij.openapi.vfs.VirtualFile)27 Module (com.intellij.openapi.module.Module)17 File (java.io.File)16 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)11 SourceFolder (com.intellij.openapi.roots.SourceFolder)7 NotNull (org.jetbrains.annotations.NotNull)7 FilePaths.findParentContentEntry (com.android.tools.idea.gradle.util.FilePaths.findParentContentEntry)4 IOException (java.io.IOException)4 Nullable (org.jetbrains.annotations.Nullable)4 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)3 Project (com.intellij.openapi.project.Project)3 JavaModuleContentRoot (com.android.tools.idea.gradle.model.java.JavaModuleContentRoot)2 NodeDescriptor (com.intellij.ide.util.treeView.NodeDescriptor)2 ModifiableFlexBuildConfiguration (com.intellij.lang.javascript.flex.projectStructure.model.ModifiableFlexBuildConfiguration)2 Sdk (com.intellij.openapi.projectRoots.Sdk)2 PsiFile (com.intellij.psi.PsiFile)2 ArrayList (java.util.ArrayList)2 SyncIssue (com.android.builder.model.SyncIssue)1