Search in sources :

Example 36 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class RootVisitorHost method visitOrderEntryRoots.

private static boolean visitOrderEntryRoots(RootVisitor visitor, OrderEntry entry) {
    Set<VirtualFile> allRoots = new LinkedHashSet<>();
    Collections.addAll(allRoots, entry.getFiles(OrderRootType.SOURCES));
    Collections.addAll(allRoots, entry.getFiles(OrderRootType.CLASSES));
    Module module = entry instanceof ModuleOrderEntry ? ((ModuleOrderEntry) entry).getModule() : null;
    Sdk sdk = entry instanceof JdkOrderEntry ? ((JdkOrderEntry) entry).getJdk() : null;
    for (VirtualFile root : allRoots) {
        if (!visitor.visitRoot(root, module, sdk, false)) {
            return false;
        }
    }
    return true;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) VirtualFile(com.intellij.openapi.vfs.VirtualFile) Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module)

Example 37 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class ResolveImportUtil method getPathCache.

@Nullable
static PythonPathCache getPathCache(PsiElement foothold) {
    PythonPathCache cache = null;
    final Module module = ModuleUtilCore.findModuleForPsiElement(foothold);
    if (module != null) {
        cache = PythonModulePathCache.getInstance(module);
    } else {
        final Sdk sdk = PyBuiltinCache.findSdkForFile(foothold.getContainingFile());
        if (sdk != null) {
            cache = PythonSdkPathCache.getInstance(foothold.getProject(), sdk);
        }
    }
    return cache;
}
Also used : Sdk(com.intellij.openapi.projectRoots.Sdk) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 38 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class ModuleContextProvider method getModules.

public static Module[] getModules(@Nullable PsiFile context) {
    if (context == null)
        return Module.EMPTY_ARRAY;
    final Set<Module> modules = new HashSet<>();
    for (ModuleContextProvider moduleContextProvider : Extensions.getExtensions(EP_NAME)) {
        ContainerUtil.addAllNotNull(modules, moduleContextProvider.getContextModules(context));
    }
    Module module = ModuleUtilCore.findModuleForPsiElement(context);
    if (module != null)
        modules.add(module);
    return modules.toArray(new Module[modules.size()]);
}
Also used : Module(com.intellij.openapi.module.Module) HashSet(com.intellij.util.containers.HashSet)

Example 39 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class AbstractConvertContext method getConvertContextModules.

@NotNull
private Module[] getConvertContextModules() {
    Module[] modules = ModuleContextProvider.getModules(getFile());
    if (modules.length > 0)
        return modules;
    final Module module = getModule();
    if (module != null)
        return new Module[] { module };
    return Module.EMPTY_ARRAY;
}
Also used : Module(com.intellij.openapi.module.Module) NotNull(org.jetbrains.annotations.NotNull)

Example 40 with Module

use of com.intellij.openapi.module.Module in project intellij-community by JetBrains.

the class AbstractConvertContext method getSearchScope.

@Override
@Nullable
public GlobalSearchScope getSearchScope() {
    GlobalSearchScope scope = null;
    Module[] modules = getConvertContextModules();
    if (modules.length != 0) {
        PsiFile file = getFile();
        file = file.getOriginalFile();
        VirtualFile virtualFile = file.getVirtualFile();
        if (virtualFile != null) {
            boolean tests = TestSourcesFilter.isTestSources(virtualFile, file.getProject());
            for (Module module : modules) {
                if (scope == null) {
                    scope = module.getModuleRuntimeScope(tests);
                } else {
                    scope = scope.union(module.getModuleRuntimeScope(tests));
                }
            }
        }
    }
    // ??? scope == null ? GlobalSearchScope.allScope(getProject()) : scope; ???
    return scope;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

Module (com.intellij.openapi.module.Module)1911 VirtualFile (com.intellij.openapi.vfs.VirtualFile)585 Project (com.intellij.openapi.project.Project)381 NotNull (org.jetbrains.annotations.NotNull)331 Nullable (org.jetbrains.annotations.Nullable)268 File (java.io.File)185 PsiFile (com.intellij.psi.PsiFile)147 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)134 ArrayList (java.util.ArrayList)118 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)112 Sdk (com.intellij.openapi.projectRoots.Sdk)95 PsiElement (com.intellij.psi.PsiElement)89 PsiDirectory (com.intellij.psi.PsiDirectory)77 ModuleManager (com.intellij.openapi.module.ModuleManager)65 PsiClass (com.intellij.psi.PsiClass)65 IOException (java.io.IOException)61 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)57 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)57 List (java.util.List)57 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)51