Search in sources :

Example 81 with Module

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

the class MavenDomUtil method findContainingMavenizedModule.

@Nullable
public static Module findContainingMavenizedModule(@NotNull PsiFile psiFile) {
    VirtualFile file = psiFile.getVirtualFile();
    if (file == null)
        return null;
    Project project = psiFile.getProject();
    MavenProjectsManager manager = MavenProjectsManager.getInstance(project);
    if (!manager.isMavenizedProject())
        return null;
    ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
    Module module = index.getModuleForFile(file);
    if (module == null || !manager.isMavenizedModule(module))
        return null;
    return module;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) Project(com.intellij.openapi.project.Project) MavenProject(org.jetbrains.idea.maven.project.MavenProject) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 82 with Module

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

the class AbstractTestNGSuiteConfigurationProducer method setupConfigurationFromContext.

@Override
protected boolean setupConfigurationFromContext(TestNGConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
    final PsiElement element = context.getPsiLocation();
    final PsiFile containingFile = element != null ? element.getContainingFile() : null;
    if (containingFile == null)
        return false;
    final VirtualFile virtualFile = containingFile.getVirtualFile();
    if (virtualFile == null || !virtualFile.isValid())
        return false;
    if (!TestNGUtil.isTestngXML(virtualFile))
        return false;
    RunnerAndConfigurationSettings settings = cloneTemplateConfiguration(context);
    setupConfigurationModule(context, configuration);
    final Module originalModule = configuration.getConfigurationModule().getModule();
    configuration.getPersistantData().SUITE_NAME = virtualFile.getPath();
    configuration.getPersistantData().TEST_OBJECT = TestType.SUITE.getType();
    configuration.restoreOriginalModule(originalModule);
    configuration.setGeneratedName();
    settings.setName(configuration.getName());
    sourceElement.set(containingFile);
    return true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module) PsiElement(com.intellij.psi.PsiElement)

Example 83 with Module

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

the class XsltRunConfiguration method getEffectiveJDK.

@Nullable
public Sdk getEffectiveJDK() {
    if (!XsltRunSettingsEditor.ALLOW_CHOOSING_SDK) {
        return getDefaultSdk();
    }
    if (myJdkChoice == JdkChoice.JDK) {
        return myJdk != null ? ProjectJdkTable.getInstance().findJdk(myJdk) : null;
    }
    Sdk jdk = null;
    final Module module = getEffectiveModule();
    if (module != null) {
        jdk = ModuleRootManager.getInstance(module).getSdk();
    }
    if (jdk == null) {
        jdk = ProjectRootManager.getInstance(getProject()).getProjectSdk();
    }
    // EA-33419
    if (jdk == null || !(jdk.getSdkType() instanceof JavaSdkType)) {
        return getDefaultSdk();
    }
    return jdk;
}
Also used : Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 84 with Module

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

the class FindByXPathAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    final Module module = LangDataKeys.MODULE.getData(e.getDataContext());
    if (project != null) {
        executeSearch(project, module);
    }
}
Also used : Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module)

Example 85 with Module

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

the class SearchScope method iterateContent.

public void iterateContent(@NotNull final Project project, final Processor<VirtualFile> processor) {
    switch(getScopeType()) {
        case PROJECT:
            //noinspection unchecked
            ProjectRootManager.getInstance(project).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
            break;
        case MODULE:
            final Module module = ModuleManager.getInstance(project).findModuleByName(getModuleName());
            assert module != null;
            ModuleRootManager.getInstance(module).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
            break;
        case DIRECTORY:
            final String dirName = getPath();
            assert dirName != null;
            final VirtualFile virtualFile = findFile(dirName);
            if (virtualFile != null) {
                iterateRecursively(virtualFile, processor, isRecursive());
            }
            break;
        case CUSTOM:
            assert myCustomScope != null;
            final ContentIterator iterator;
            if (myCustomScope instanceof GlobalSearchScope) {
                final GlobalSearchScope searchScope = (GlobalSearchScope) myCustomScope;
                iterator = new MyFileIterator(processor, virtualFile13 -> searchScope.contains(virtualFile13));
                if (searchScope.isSearchInLibraries()) {
                    final OrderEnumerator enumerator = OrderEnumerator.orderEntries(project).withoutModuleSourceEntries().withoutDepModules();
                    final Collection<VirtualFile> libraryFiles = new THashSet<>();
                    Collections.addAll(libraryFiles, enumerator.getClassesRoots());
                    Collections.addAll(libraryFiles, enumerator.getSourceRoots());
                    final Processor<VirtualFile> adapter = virtualFile1 -> iterator.processFile(virtualFile1);
                    for (final VirtualFile file : libraryFiles) {
                        iterateRecursively(file, adapter, true);
                    }
                }
            } else {
                final PsiManager manager = PsiManager.getInstance(project);
                iterator = new MyFileIterator(processor, virtualFile12 -> {
                    final PsiFile element = manager.findFile(virtualFile12);
                    return element != null && PsiSearchScopeUtil.isInScope(myCustomScope, element);
                });
            }
            ProjectRootManager.getInstance(project).getFileIndex().iterateContent(iterator);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) OrderEnumerator(com.intellij.openapi.roots.OrderEnumerator) Tag(com.intellij.util.xmlb.annotations.Tag) ModuleManager(com.intellij.openapi.module.ModuleManager) VirtualFile(com.intellij.openapi.vfs.VirtualFile) THashSet(gnu.trove.THashSet) PsiManager(com.intellij.psi.PsiManager) Comparing(com.intellij.openapi.util.Comparing) Project(com.intellij.openapi.project.Project) PsiFile(com.intellij.psi.PsiFile) Conditions(com.intellij.openapi.util.Conditions) Module(com.intellij.openapi.module.Module) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager) VfsUtilCore(com.intellij.openapi.vfs.VfsUtilCore) ContentIterator(com.intellij.openapi.roots.ContentIterator) Collection(java.util.Collection) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) Nullable(org.jetbrains.annotations.Nullable) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) PsiSearchScopeUtil(com.intellij.psi.search.PsiSearchScopeUtil) Processor(com.intellij.util.Processor) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor) Attribute(com.intellij.util.xmlb.annotations.Attribute) NotNull(org.jetbrains.annotations.NotNull) Collections(java.util.Collections) Condition(com.intellij.openapi.util.Condition) ContentIterator(com.intellij.openapi.roots.ContentIterator) PsiManager(com.intellij.psi.PsiManager) THashSet(gnu.trove.THashSet) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) OrderEnumerator(com.intellij.openapi.roots.OrderEnumerator) PsiFile(com.intellij.psi.PsiFile) Module(com.intellij.openapi.module.Module)

Aggregations

Module (com.intellij.openapi.module.Module)1893 VirtualFile (com.intellij.openapi.vfs.VirtualFile)585 Project (com.intellij.openapi.project.Project)379 NotNull (org.jetbrains.annotations.NotNull)330 Nullable (org.jetbrains.annotations.Nullable)267 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