Search in sources :

Example 1 with Module

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

the class GroovyHotSwapper method patchJavaParameters.

@Override
public void patchJavaParameters(Executor executor, RunProfile configuration, JavaParameters javaParameters) {
    ApplicationManager.getApplication().assertReadAccessAllowed();
    if (!executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID)) {
        return;
    }
    if (!GroovyDebuggerSettings.getInstance().ENABLE_GROOVY_HOTSWAP) {
        return;
    }
    if (hasSpringLoadedReloader(javaParameters)) {
        return;
    }
    if (!(configuration instanceof RunConfiguration)) {
        return;
    }
    final Project project = ((RunConfiguration) configuration).getProject();
    if (project == null) {
        return;
    }
    if (!LanguageLevelProjectExtension.getInstance(project).getLanguageLevel().isAtLeast(LanguageLevel.JDK_1_5)) {
        return;
    }
    if (configuration instanceof ModuleBasedConfiguration) {
        final Module module = ((ModuleBasedConfiguration) configuration).getConfigurationModule().getModule();
        if (module != null) {
            final LanguageLevel level = LanguageLevelModuleExtensionImpl.getInstance(module).getLanguageLevel();
            if (level != null && !level.isAtLeast(LanguageLevel.JDK_1_5)) {
                return;
            }
        }
    }
    Sdk jdk = javaParameters.getJdk();
    if (jdk != null) {
        String vendor = JdkUtil.getJdkMainAttribute(jdk, Attributes.Name.IMPLEMENTATION_VENDOR);
        if (vendor != null && vendor.contains("IBM")) {
            LOG.info("Due to IBM JDK peculiarities (IDEA-59070) we don't add Groovy agent when running applications under it");
            return;
        }
    }
    if (!project.isDefault() && containsGroovyClasses(project)) {
        final String agentPath = handleSpacesInPath(getAgentJarPath());
        if (agentPath != null) {
            javaParameters.getVMParametersList().add("-javaagent:" + agentPath);
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) LanguageLevel(com.intellij.pom.java.LanguageLevel) Sdk(com.intellij.openapi.projectRoots.Sdk) ModuleBasedConfiguration(com.intellij.execution.configurations.ModuleBasedConfiguration) Module(com.intellij.openapi.module.Module)

Example 2 with Module

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

the class GroovyAntCustomCompilerProvider method hasCustomCompile.

/**
   * {@inheritDoc}
   */
@Override
public boolean hasCustomCompile(ModuleChunk chunk) {
    for (Module m : chunk.getModules()) {
        if (LibrariesUtil.hasGroovySdk(m)) {
            final Set<String> scriptExtensions = GroovyFileTypeLoader.getCustomGroovyScriptExtensions();
            final ContentIterator groovyFileSearcher = new ContentIterator() {

                @Override
                public boolean processFile(VirtualFile fileOrDir) {
                    ProgressManager.checkCanceled();
                    if (isCompilableGroovyFile(fileOrDir, scriptExtensions)) {
                        return false;
                    }
                    return true;
                }
            };
            final ModuleRootManager rootManager = ModuleRootManager.getInstance(m);
            final ModuleFileIndex fileIndex = rootManager.getFileIndex();
            for (VirtualFile file : rootManager.getSourceRoots(JavaModuleSourceRootTypes.SOURCES)) {
                if (!fileIndex.iterateContentUnderDirectory(file, groovyFileSearcher)) {
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ContentIterator(com.intellij.openapi.roots.ContentIterator) ModuleRootManager(com.intellij.openapi.roots.ModuleRootManager) ModuleFileIndex(com.intellij.openapi.roots.ModuleFileIndex) Module(com.intellij.openapi.module.Module)

Example 3 with Module

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

the class GroovyConsoleStateService method loadState.

@Override
public void loadState(MyState state) {
    synchronized (myFileModuleMap) {
        myFileModuleMap.clear();
        for (Entry entry : state.list) {
            final VirtualFile file = myFileManager.findFileByUrl(entry.url);
            final Module module = myModuleManager.findModuleByName(entry.moduleName);
            if (file != null) {
                myFileModuleMap.put(file, Pair.create(module, entry.title));
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Module(com.intellij.openapi.module.Module)

Example 4 with Module

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

the class GrNewConsoleAction method getModule.

@Nullable
protected Module getModule(AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null)
        return null;
    final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
    if (file != null) {
        final Module moduleForFile = ModuleUtilCore.findModuleForFile(file, project);
        if (moduleForFile != null)
            return moduleForFile;
    }
    final List<Module> modules = ModuleChooserUtil.filterGroovyCompatibleModules(Arrays.asList(ModuleManager.getInstance(project).getModules()), APPLICABLE_MODULE);
    return modules.isEmpty() ? null : modules.get(0);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with Module

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

the class GrNewConsoleAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    final Project project = e.getProject();
    final Module module = getModule(e);
    if (project == null || module == null)
        return;
    final VirtualFile contentFile = ConsoleHistoryController.getContentFile(GroovyConsoleRootType.getInstance(), GroovyConsoleRootType.CONTENT_ID, ScratchFileService.Option.create_new_always);
    assert contentFile != null;
    GroovyConsole.createConsole(project, contentFile, module);
    FileEditorManager.getInstance(project).openFile(contentFile, true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Module(com.intellij.openapi.module.Module)

Aggregations

Module (com.intellij.openapi.module.Module)1913 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