Java Code Examples for com.intellij.openapi.module.Module

The following are top voted examples for showing how to use com.intellij.openapi.module.Module. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: intellij-spring-assistant   File: SuggestionIndexServiceImpl.java   View source code 6 votes vote down vote up
@Nullable
@Override
public MetadataNode findDeepestExactMatch(Project project, Module module,
    List<String> containerElements) {
  if (moduleNameToSanitisedRootSearchIndex.containsKey(module.getName())) {
    String[] pathSegments =
        containerElements.stream().flatMap(element -> stream(toPathSegments(element)))
            .toArray(String[]::new);
    MetadataNode searchStartNode = moduleNameToSanitisedRootSearchIndex.get(module.getName())
        .get(MetadataNode.sanitize(pathSegments[0]));
    if (searchStartNode != null) {
      if (pathSegments.length > 1) {
        return searchStartNode.findDeepestMatch(pathSegments, 1, true);
      }
      return searchStartNode;
    }
  }
  return null;
}
 
Example 2
Project: manifold-ij   File: ManProject.java   View source code 6 votes vote down vote up
public static Module getIjModule( PsiElement element )
{
  Module module = ModuleUtil.findModuleForPsiElement( element );
  if( module != null )
  {
    return module;
  }

  ManifoldPsiClass javaFacadePsiClass = element.getContainingFile().getUserData( ManifoldPsiClass.KEY_MANIFOLD_PSI_CLASS );
  if( javaFacadePsiClass != null )
  {
    return javaFacadePsiClass.getModule();
  }

  return null;
}
 
Example 3
Project: green-cat   File: Utils.java   View source code 6 votes vote down vote up
public static String getAndroidSdkPath(Project project) {
    ModuleManager manager = ModuleManager.getInstance(project);
    String androidSdkPath = null;

    for (Module module : manager.getModules()) {
        if (androidSdkPath != null) {
            break;
        }
        Sdk sdk = ModuleRootManager.getInstance(module).getSdk();

        if (sdk != null && sdk.getHomePath() != null) {
            File file = new File(sdk.getHomePath());
            String[] contents = file.list();

            if (contents != null) {
                for (String path : contents) {
                    if (path.equals("build-tools")) {
                        androidSdkPath = sdk.getHomePath();
                        break;
                    }
                }
            }
        }
    }
    return androidSdkPath;
}
 
Example 4
Project: manifold-ij   File: ManProject.java   View source code 6 votes vote down vote up
private static boolean dependencyChainContains( Module ijModule, String path, List<Module> visited )
{
  if( !visited.contains( ijModule ) )
  {
    visited.add( ijModule );

    ModuleRootManager rootManager = ModuleRootManager.getInstance( ijModule );
    for( Module dep : rootManager.getDependencies() )
    {
      if( getDirectClassPaths( dep ).contains( path ) || dependencyChainContains( dep, path, visited ) )
      {
        return true;
      }
    }
  }
  return false;
}
 
Example 5
Project: manifold-ij   File: ExtensionClassAnnotator.java   View source code 6 votes vote down vote up
private boolean isInterfaceMadeStructuralByExtension( PsiClass psiExtentionInterface )
{
  Module module = ManProject.getIjModule( psiExtentionInterface );
  if( module != null )
  {
    if( isInterfaceMadeStructuralByExtension( psiExtentionInterface, ManProject.getModule( module ) ) )
    {
      return true;
    }
  }
  else
  {
    ManProject manProject = ManProject.manProjectFrom( psiExtentionInterface.getProject() );
    for( ManModule manModule : manProject.getModules() )
    {
      if( isInterfaceMadeStructuralByExtension( psiExtentionInterface, manModule ) )
      {
        return true;
      }
    }
  }
  return false;
}
 
Example 6
Project: manifold-ij   File: ManProject.java   View source code 6 votes vote down vote up
public static List<IDirectory> getClassPaths( Module ijModule )
{
  List<String> paths = getDirectClassPaths( ijModule );
  for( Iterator<String> it = paths.iterator(); it.hasNext(); )
  {
    String url = it.next();
    if( dependencyChainContains( ijModule, url, new ArrayList<>() ) )
    {
      it.remove();
    }
  }
  List<IDirectory> dirs = new ArrayList<>();
  for( String path : paths )
  {
    dirs.add( manProjectFrom( ijModule ).getFileSystem().getIDirectory( new File( path ) ) );
  }
  return dirs;
}
 
Example 7
Project: hybris-integration-intellij-idea-plugin   File: DefaultModulesDependenciesConfigurator.java   View source code 6 votes vote down vote up
private void configureModuleDependencies(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final Module module,
    @NotNull final Collection<Module> allModules,
    @NotNull final Set<HybrisModuleDescriptor> extModules,
    final @NotNull IdeModifiableModelsProvider modifiableModelsProvider
) {
    final ModifiableRootModel rootModel = modifiableModelsProvider.getModifiableRootModel(module);

    for (HybrisModuleDescriptor dependency : moduleDescriptor.getDependenciesTree()) {
        if (moduleDescriptor instanceof OotbHybrisModuleDescriptor) {
            if (extModules.contains(dependency)) {
                continue;
            }
        }

        Optional<Module> targetDependencyModule = findModuleByNameIgnoreCase(allModules, dependency.getName());
        final ModuleOrderEntry moduleOrderEntry = targetDependencyModule.isPresent()
            ? rootModel.addModuleOrderEntry(targetDependencyModule.get())
            : rootModel.addInvalidModuleEntry(dependency.getName());

        moduleOrderEntry.setExported(true);
        moduleOrderEntry.setScope(DependencyScope.COMPILE);
    }
}
 
Example 8
Project: hybris-integration-intellij-idea-plugin   File: DefaultGradleConfigurator.java   View source code 6 votes vote down vote up
private void moveGradleModulesToGroup(
    final Project project,
    final List<Module> gradleModules,
    final String[] gradleGroup
) {
    final ModifiableModuleModel modifiableModuleModel = ModuleManager.getInstance(project).getModifiableModel();

    for (Module module : gradleModules) {
        if (module == null) {
            // https://youtrack.jetbrains.com/issue/IDEA-177512
            continue;
        }
        module.setOption(HybrisConstants.DESCRIPTOR_TYPE, HybrisModuleDescriptorType.GRADLE.name());
        modifiableModuleModel.setModuleGroupPath(module, gradleGroup);
    }
    AccessToken token = null;
    try {
        token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
        modifiableModuleModel.commit();
    } finally {
        if (token != null) {
            token.finish();
        }
    }
}
 
Example 9
Project: educational-plugin   File: EduKotlinKoansModuleBuilder.java   View source code 6 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  Project project = baseModule.getProject();
  EduProjectGenerator generator = new EduProjectGenerator();
  if (myCourse == null) {
    File courseRoot = StudyUtils.getBundledCourseRoot(DEFAULT_COURSE_NAME, EduKotlinKoansModuleBuilder.class);
    final Course course = generator.addLocalCourse(FileUtil.join(courseRoot.getPath(), DEFAULT_COURSE_NAME));
    if (course == null) {
      LOG.info("Failed to find course " + DEFAULT_COURSE_NAME);
      return baseModule;
    }
  }
  myCourse.setLanguage("kotlin");
  EduModuleBuilderUtils.createCourseFromCourseInfo(moduleModel, project, generator, myCourse, getModuleFileDirectory());
  return baseModule;
}
 
Example 10
Project: processing-idea   File: ProcessingImportBuilder.java   View source code 6 votes vote down vote up
@NotNull
public Parameters getParameters() {
    if (parameters == null) {
        parameters = new Parameters();
        parameters.existingModuleNames = new HashSet<>();
        if (isUpdate()) {
            Project project = getCurrentProject();
            if (project != null) {
                for (Module module : ModuleManager.getInstance(project).getModules()) {
                    parameters.existingModuleNames.add(module.getName());
                }
            }
        }
    }

    return parameters;
}
 
Example 11
Project: processing-idea   File: ProcessingImportBuilder.java   View source code 6 votes vote down vote up
@Nullable
@Override
public List<Module> commit(Project project,
                           ModifiableModuleModel modifiableModuleModel,
                           ModulesProvider modulesProvider,
                           ModifiableArtifactModel modifiableArtifactModel) {

    logger.debug("Initializing module builder instance.");
    ProcessingModuleBuilder processingModuleBuilder = new ProcessingModuleBuilder();
    processingModuleBuilder.setGenerateTemplateSketchClass(false);

    logger.debug("Creating modules for project '" + project + "' at path '" + getParameters().projectCreationRoot + "'.");

    List<Module> modules = processingModuleBuilder.commit(project, modifiableModuleModel, modulesProvider);

    Collection<VirtualFile> importablePdeFiles = new LinkedList<>(getParameters().importablePdeFiles);

    logger.info("Identified a total of " + importablePdeFiles.size() + " PDE files for import from '" + getParameters().root + "'.");

    ImportSketchClasses importSketchClasses = new ImportSketchClasses(this, project, modules, importablePdeFiles);
    DumbService.getInstance(project).smartInvokeLater(importSketchClasses);

    return modules;
}
 
Example 12
Project: hybris-integration-intellij-idea-plugin   File: ProjectRefreshAction.java   View source code 6 votes vote down vote up
private static void removeOldProjectData(@NotNull final Project project) {
    final ModifiableModuleModel moduleModel = ModuleManager.getInstance(project).getModifiableModel();

    for (Module module : moduleModel.getModules()) {
        moduleModel.disposeModule(module);
    }
    final LibraryTable.ModifiableModel libraryModel = ProjectLibraryTable.getInstance(project).getModifiableModel();

    for (Library library : libraryModel.getLibraries()) {
        libraryModel.removeLibrary(library);
    }
    ApplicationManager.getApplication().runWriteAction(() -> {
        moduleModel.commit();
        libraryModel.commit();
    });
    final GradleSupport gradleSupport = GradleSupport.getInstance();

    if (gradleSupport != null) {
        gradleSupport.clearLinkedProjectSettings(project);
    }
    final AntConfigurationBase antConfiguration = AntConfigurationBase.getInstance(project);

    for (AntBuildFile antBuildFile : antConfiguration.getBuildFiles()) {
        antConfiguration.removeBuildFile(antBuildFile);
    }
}
 
Example 13
Project: hybris-integration-intellij-idea-plugin   File: ModuleDepDiagramItem.java   View source code 6 votes vote down vote up
@Nullable
public static ModuleDepDiagramItem fromFQN(@NotNull final String fqn, @NotNull final Project project) {
    String moduleName = null;
    boolean customExtension = false;

    if (fqn.startsWith(MODULE_PREFIX)) {
        moduleName = fqn.substring(MODULE_PREFIX.length());
        customExtension = false;
    } else if (fqn.startsWith(CUSTOM_MODULE_PREFIX)) {
        moduleName = fqn.substring(CUSTOM_MODULE_PREFIX.length());
        customExtension = true;
    }
    if (moduleName == null) {
        return new ModuleDepDiagramItem(null, false);
    }
    final Module module = ModuleManager.getInstance(project).findModuleByName(moduleName);
    return module == null ? null : new ModuleDepDiagramItem(module, customExtension);
}
 
Example 14
Project: hybris-integration-intellij-idea-plugin   File: ModuleDepDiagramDataModel.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
@NotNull
private List<ModuleDepDiagramEdge> createAdaptedEdges(@NotNull final Collection<ModulesUmlEdge> edges) {
    final DiagramProvider provider = getBuilder().getProvider();

    return edges
        .stream()
        .map(modulesUmlEdge -> {
            final Module from = modulesUmlEdge.getSource().getIdentifyingElement().getModule();
            final ModuleDepDiagramItem fromItem = new ModuleDepDiagramItem(from, isCustomExtension(from));

            final Module to = modulesUmlEdge.getTarget().getIdentifyingElement().getModule();
            final ModuleDepDiagramItem toItem = new ModuleDepDiagramItem(to, isCustomExtension(to));

            return new ModuleDepDiagramEdge(
                new ModuleDepDiagramNode(fromItem, provider),
                new ModuleDepDiagramNode(toItem, provider),
                modulesUmlEdge.getRelationship()
            );
        }).collect(Collectors.toList());
}
 
Example 15
Project: hybris-integration-intellij-idea-plugin   File: TypeSystemValidationUtils.java   View source code 6 votes vote down vote up
public static boolean isCustomExtensionFile(@NotNull final VirtualFile file, @NotNull final Project project) {
    final Module module = ModuleUtilCore.findModuleForFile(file, project);

    if (null == module) {
        return false;
    }
    final String descriptorTypeName = module.getOptionValue(HybrisConstants.DESCRIPTOR_TYPE);

    if (descriptorTypeName == null) {
        if (shouldCheckFilesWithoutHybrisSettings(project)) {
            return estimateIsCustomExtension(file);
        }
        return false;
    }

    final HybrisModuleDescriptorType descriptorType = HybrisModuleDescriptorType.valueOf(descriptorTypeName);
    return descriptorType == HybrisModuleDescriptorType.CUSTOM;
}
 
Example 16
Project: educational-plugin   File: PyEduPluginConfigurator.java   View source code 6 votes vote down vote up
@Override
public void configureModule(@NotNull Module module) {
  final Project project = module.getProject();
  StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> {
    final VirtualFile baseDir = project.getBaseDir();
    final String testHelper = EduNames.TEST_HELPER;
    if (baseDir.findChild(testHelper) != null) return;
    final FileTemplate template = FileTemplateManager.getInstance(project).getInternalTemplate("test_helper");
    final PsiDirectory projectDir = PsiManager.getInstance(project).findDirectory(baseDir);
    if (projectDir == null) return;
    try {
      FileTemplateUtil.createFromTemplate(template, testHelper, null, projectDir);
    }
    catch (Exception exception) {
      LOG.error("Can't copy test_helper.py " + exception.getMessage());
    }
  });
}
 
Example 17
Project: educational-plugin   File: PyCCCreateProjectFromArchive.java   View source code 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getData(CommonDataKeys.PROJECT);
  final Module module = e.getData(LangDataKeys.MODULE);
  if (project == null || module == null) {
    return;
  }

  AbstractNewProjectDialog dialog = new AbstractNewProjectDialog() {
    @Override
    protected DefaultActionGroup createRootStep() {
      return new CreateFromArchiveProjectStep(project, module);
    }
  };
  dialog.show();
}
 
Example 18
Project: RIBs   File: GenerateAction.java   View source code 6 votes vote down vote up
@Nullable
private static SourceFolder suitableTestSourceFolders(Project project, Module module) {
  ContentEntry[] contentEntries = ModuleRootManager.getInstance(module).getContentEntries();
  for (ContentEntry contentEntry : contentEntries) {
    List<SourceFolder> testSourceFolders =
        contentEntry.getSourceFolders(JavaSourceRootType.TEST_SOURCE);
    for (SourceFolder testSourceFolder : testSourceFolders) {
      if (testSourceFolder.getFile() != null) {
        if (!JavaProjectRootsUtil.isInGeneratedCode(testSourceFolder.getFile(), project)) {
          return testSourceFolder;
        }
      }
    }
  }

  return null;
}
 
Example 19
Project: educational-plugin   File: EduRemoteCourseModuleBuilder.java   View source code 6 votes vote down vote up
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel)
  throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module baseModule = super.createModule(moduleModel);
  String languageName = myCourse.getLanguageID();
  Language language = Language.findLanguageByID(languageName);
  if (language != null) {
    EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(language);
    if (configurator != null) {
      Project project = baseModule.getProject();
      myGenerator.setSelectedCourse(myCourse);
      myGenerator.generateProject(project, project.getBaseDir());
      Course course = StudyTaskManager.getInstance(project).getCourse();
      if (course == null) {
        LOG.info("failed to generate course");
        return baseModule;
      }
      configurator.createCourseModuleContent(moduleModel, project, course, getModuleFileDirectory());
    }
  }
  return baseModule;
}
 
Example 20
Project: educational-plugin   File: CCUtils.java   View source code 6 votes vote down vote up
@Nullable
public static VirtualFile generateFolder(@NotNull Project project, @NotNull Module module, String name) {
  VirtualFile generatedRoot = getGeneratedFilesFolder(project, module);
  if (generatedRoot == null) {
    return null;
  }

  final Ref<VirtualFile> folder = new Ref<>(generatedRoot.findChild(name));
  //need to delete old folder
  ApplicationManager.getApplication().runWriteAction(() -> {
    try {
      if (folder.get() != null) {
        folder.get().delete(null);
      }
      folder.set(generatedRoot.createChildDirectory(null, name));
    }
    catch (IOException e) {
      LOG.info("Failed to generate folder " + name, e);
    }
  });
  return folder.get();
}
 
Example 21
Project: GravSupport   File: GravModuleBuilder.java   View source code 6 votes vote down vote up
@Override
    public void moduleCreated(@NotNull Module module) {
        StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
        String msg = String.format("Please wait while module for project %s is created", project.getName());
        settings = GravProjectSettings.getInstance(project);

        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder(msg, MessageType.WARNING, null)
                .setFadeoutTime(4000)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);

        VirtualFile[] roots1 = ModuleRootManager.getInstance(module).getContentRoots();
        if (roots1.length != 0) {
            final VirtualFile src = roots1[0];
            settings.withSrcDirectory = withSrcDirectory;
            settings.gravInstallationPath = getGravInstallPath().getPath();
//            settings.withSrcDirectory =
            GravProjectGeneratorUtil generatorUtil = new GravProjectGeneratorUtil();
            generatorUtil.generateProject(project, src, settings, module);
        }
    }
 
Example 22
Project: educational-plugin   File: EduPluginConfiguratorBase.java   View source code 6 votes vote down vote up
@Override
public PsiDirectory createLessonContent(@NotNull Project project, @NotNull Lesson lesson, @Nullable IdeView view, @NotNull PsiDirectory parentDirectory) {
  NewModuleAction newModuleAction = new NewModuleAction();
  String courseDirPath = parentDirectory.getVirtualFile().getPath();
  Module utilModule = ModuleManager.getInstance(project).findModuleByName(EduIntelliJNames.UTIL);
  if (utilModule == null) {
    return null;
  }
  newModuleAction.createModuleFromWizard(project, null, new AbstractProjectWizard("", project, "") {
    @Override
    public StepSequence getSequence() {
      return null;
    }

    @Override
    public ProjectBuilder getProjectBuilder() {
      return new EduLessonModuleBuilder(courseDirPath, lesson, utilModule);
    }
  });
  return parentDirectory.findSubdirectory(EduNames.LESSON + lesson.getIndex());
}
 
Example 23
Project: manifold-ij   File: ManProject.java   View source code 5 votes vote down vote up
public static ManModule getModule( PsiElement element )
{
  Module ijModule = getIjModule( element );
  if( ijModule != null )
  {
    return getModule( ijModule );
  }
  return null;
}
 
Example 24
Project: intellij-spring-assistant   File: SuggestionIndexServiceImpl.java   View source code 5 votes vote down vote up
@Override
public void reindex(Project project, Module[] modules) {
  if (indexingInProgress) {
    if (currentExecution != null) {
      currentExecution.cancel(false);
    }
  }
  //noinspection CodeBlock2Expr
  currentExecution = getApplication().executeOnPooledThread(() -> {
    getApplication().runReadAction(() -> {
      debug(() -> log.debug(
          "-> Indexing requested for a subset of modules of project " + project.getName()));
      indexingInProgress = true;
      StopWatch timer = new StopWatch();
      timer.start();
      try {
        for (Module module : modules) {
          debug(() -> log.debug("--> Indexing requested for module " + module.getName()));
          StopWatch moduleTimer = new StopWatch();
          moduleTimer.start();
          try {
            reindexModule(emptyList(), emptyList(), module);
          } finally {
            moduleTimer.stop();
            debug(() -> log.debug(
                "<-- Indexing took " + moduleTimer.toString() + " for module " + module
                    .getName()));
          }
        }
      } finally {
        indexingInProgress = false;
        timer.stop();
        debug(() -> log
            .debug("<- Indexing took " + timer.toString() + " for project " + project.getName()));
      }
    });
  });
}
 
Example 25
Project: idea-php-psr4-namespace-detector   File: PhpSourceDirectoryConfigurator.java   View source code 5 votes vote down vote up
public void configureProject(Project project, @NotNull VirtualFile baseDir, Ref<Module> moduleRef) {
    StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> {
        DumbService.getInstance(project).smartInvokeLater(() -> {
            Set<PhpNamespaceRootInfo> namespaces = new HashSet<PhpNamespaceRootInfo>();
            PhpPsr4NamespaceRootDetector.processNamespaces(project, namespaces);

            if(namespaces.size() > 0) {
                NotificationListener listener = new NotificationListener() {
                    public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
                        if("detect".equals(event.getDescription())) {
                            DumbService.getInstance(project).smartInvokeLater(() -> {
                                boolean detected = PhpPsr4NamespaceRootDetector.detectNamespaceRoots(project);
                                if(!detected) {
                                    PhpPsr4NamespaceNotifier.showNotificationByMessageId(
                                        project,
                                        "actions.detect.namespace.roots.no.roots.detected",
                                        (NotificationListener)null
                                    );
                                }

                                notification.expire();
                            });
                        } else {
                            ShowSettingsUtil.getInstance().showSettingsDialog(project, "Directories");
                        }

                    }
                };
                PhpPsr4NamespaceNotifier.showNotificationByMessageId(
                    project,
                    "actions.detect.namespace.roots.notification.message",
                    listener
                );
            }

        });
    });
}
 
Example 26
Project: manifold-ij   File: ManProject.java   View source code 5 votes vote down vote up
public static List<VirtualFile> getSourceRoots( Module ijModule )
{
  final ModuleRootManager moduleManager = ModuleRootManager.getInstance( ijModule );
  final List<VirtualFile> sourcePaths = new ArrayList<>();
  List<VirtualFile> excludeRoots = Arrays.asList( moduleManager.getExcludeRoots() );
  for( VirtualFile sourceRoot : moduleManager.getSourceRoots() )
  {
    if( !excludeRoots.contains( sourceRoot ) )
    {
      sourcePaths.add( sourceRoot );
    }
  }

  return sourcePaths;
}
 
Example 27
Project: manifold-ij   File: ManProject.java   View source code 5 votes vote down vote up
private ManModule defineModule( Module ijModule )
{
  List<VirtualFile> sourceFolders = getSourceRoots( ijModule );
  VirtualFile outputPath = CompilerPaths.getModuleOutputDirectory( ijModule, false );
  return createModule( ijModule, getClassPaths( ijModule ),
                       sourceFolders.stream().map( this::toDirectory ).collect( Collectors.toList() ),
                       outputPath == null ? null : getFileSystem().getIDirectory( outputPath ) );
}
 
Example 28
Project: intellij-spring-assistant   File: GradleReindexingProjectDataService.java   View source code 5 votes vote down vote up
@Override
public void onSuccessImport(@NotNull Collection<DataNode<ModuleData>> imported,
    @Nullable ProjectData projectData, @NotNull Project project,
    @NotNull IdeModelsProvider modelsProvider) {
  if (projectData != null) {
    debug(() -> log.debug(
        "Gradle dependencies are updated for project, will trigger indexing via dumbservice for project "
            + project.getName()));
    DumbService.getInstance(project).smartInvokeLater(() -> {
      log.debug("Will attempt to trigger indexing for project " + project.getName());
      SuggestionIndexService service =
          ServiceManager.getService(project, SuggestionIndexService.class);

      try {
        Module[] validModules = stream(modelsProvider.getModules()).filter(module -> {
          String externalRootProjectPath = getExternalRootProjectPath(module);
          return externalRootProjectPath != null && externalRootProjectPath
              .equals(projectData.getLinkedExternalProjectPath());
        }).toArray(Module[]::new);

        if (validModules.length > 0) {
          service.reindex(project, validModules);
        } else {
          debug(() -> log.debug(
              "None of the modules " + moduleNamesAsStrCommaDelimited(modelsProvider.getModules(),
                  true) + " are relevant for indexing, skipping for project " + project
                  .getName()));
        }
      } catch (Throwable e) {
        log.error("Error occurred while indexing project " + project.getName() + " & modules "
            + moduleNamesAsStrCommaDelimited(modelsProvider.getModules(), false), e);
      }
    });
  }
}
 
Example 29
Project: react-native-console   File: UpdageModuleAARAction.java   View source code 5 votes vote down vote up
protected void doAction(DataContext dataContext, Project project) {
    final Module module = LangDataKeys.MODULE.getData(dataContext);

    if (module != null) {
      RNUtil.runGradleCI(project, "assembleDebug","-PupdateAAR=true", "--configure-on-demand", "-p", module.getName());
    }

//    try {
////      ProjectTaskManager.getInstance(project).build(modules);
//    }
//    catch (Exception e) {
//      LOG.error(e);
//    }
  }
 
Example 30
Project: educational-plugin   File: EduKotlinPyCharmTaskChecker.java   View source code 5 votes vote down vote up
@Override
protected void setProcessParameters(Project project, ApplicationConfiguration configuration, Module module, @NotNull VirtualFile testsFile) {
  configuration.setMainClassName(EduIntelliJNames.TEST_RUNNER_CLASS);
  configuration.setModule(module);
  PsiFile psiFile = PsiManager.getInstance(project).findFile(testsFile);
  Collection<KtClass> ktClasses = PsiTreeUtil.findChildrenOfType(psiFile, KtClass.class);
  for (KtClass ktClass : ktClasses) {
    String name = ktClass.getName();
    configuration.setProgramParameters(name);
  }
}
 
Example 31
Project: educational-plugin   File: EduKotlinLibConfigurator.java   View source code 5 votes vote down vote up
private static boolean configureWithCollector(Project project, Class<?> confClass, KotlinProjectConfigurator configurator, String lib) {
    try {
        Method method = confClass.getDeclaredMethod("configureModuleWithLibrary", Module.class, String.class, String.class, NotificationMessageCollector.class);
        method.setAccessible(true);
        NotificationMessageCollector collector = NotificationMessageCollectorKt.createConfigureKotlinNotificationCollector(project);
        for (Module module : ModuleManager.getInstance(project).getModules()) {
            method.invoke(configurator, module, lib, null, collector);
        }
        return true;
    } catch (Exception e) {
        return false;
    }
}
 
Example 32
Project: manifold-ij   File: ManTypeFinder.java   View source code 5 votes vote down vote up
public static List<ManModule> findModules( GlobalSearchScope scope )
{
  if( scope instanceof ModuleWithDependenciesScope )
  {
    Module module = ((ModuleWithDependenciesScope)scope).getModule();
    return Collections.singletonList( ManProject.getModule( module ) );
  }

  ManProject manProject = ManProject.manProjectFrom( scope.getProject() );
  List<ManModule> modules = new ArrayList<>( manProject.getModules() );
  modules.removeIf( module -> !scope.isSearchInModuleContent( module.getIjModule() ) );
  return modules;
}
 
Example 33
Project: intellij-bpmn-editor   File: BPMNFileSchemaProvider.java   View source code 5 votes vote down vote up
private static XmlFile getReference(@NotNull @NonNls String url, @NotNull Module module) {
    if (url.equalsIgnoreCase("http://bpmn.sourceforge.net")) {
        return null;
    }
    final URL resource = BPMNFileSchemaProvider.class.getResource(BPMNModelConstants.BPMN_SCHEMA_BASEURI + BPMNModelConstants.BPMN_SYSTEM_ID);
    final VirtualFile fileByURL = VfsUtil.findFileByURL(resource);
    if (fileByURL == null) {
        return null;
    }

    PsiFile psiFile = PsiManager.getInstance(module.getProject()).findFile(fileByURL);
    return (XmlFile) psiFile.copy();
}
 
Example 34
Project: manifold-ij   File: ModuleClasspathListener.java   View source code 5 votes vote down vote up
private FP64 computeIJDependencyFingerprint( Project project )
{
  List<String> strings = new ArrayList<>();
  Module[] ijModules = ModuleManager.getInstance( project ).getModules();
  for( Module ijModule : ijModules )
  {
    String s = ijModule.getName() + ARROW;
    for( Module child : ModuleRootManager.getInstance( ijModule ).getDependencies() )
    {
      s += child.getName() + (ManProject.isExported( ijModule, child ) ? EXPORT : NOT_EXPORT);
    }
    strings.add( s );
  }
  return computeOrderIndependentFingerprint( strings );
}
 
Example 35
Project: processing-idea   File: ProcessingRunConfigurationEditor.java   View source code 5 votes vote down vote up
private void refreshSketchSelector(Module [] moduleSearchScope) {
    ApplicationManager.getApplication().runWriteAction(() -> {
        Query<PsiClass> classQuery =
                AllClassesSearch.search(ProcessingPluginUtil.INSTANCE.sketchesInModuleScope(moduleSearchScope), project);
        Collection<PsiClass> classesInModule = classQuery.findAll();

        for (PsiClass classInModule : classesInModule) {
            if (SketchClassFilter.isSketchClass(classInModule)) {
                sketchSelector.addItem(new SketchSelectorComboItem(classInModule));
            }
        }
    });
}
 
Example 36
Project: hybris-integration-intellij-idea-plugin   File: ImportProjectProgressModalWindow.java   View source code 5 votes vote down vote up
public ImportProjectProgressModalWindow(
    final Project project,
    final ModifiableModuleModel model,
    final ConfiguratorFactory configuratorFactory,
    final HybrisProjectDescriptor hybrisProjectDescriptor,
    final List<Module> modules
) {
    super(project, HybrisI18NBundleUtils.message("hybris.project.import.commit"), false);
    this.project = project;
    this.model = model;
    this.modifiableModelsProvider = new IdeModifiableModelsProviderImpl(project);
    this.configuratorFactory = configuratorFactory;
    this.hybrisProjectDescriptor = hybrisProjectDescriptor;
    this.modules = modules;
}
 
Example 37
Project: processing-idea   File: ProcessingRunConfigurationEditor.java   View source code 5 votes vote down vote up
private void refreshSketchSelectorFromSelectedModule() {
    if (moduleSelector.getSelectedModule() == null) {
        return;
    }

    sketchSelector.removeAllItems();

    Module[] searchScopeModules = new Module[1];
    searchScopeModules[0] = moduleSelector.getSelectedModule();

    refreshSketchSelector(searchScopeModules);
}
 
Example 38
Project: manifold-ij   File: ModuleClasspathListener.java   View source code 5 votes vote down vote up
private void processClasspathChange( ManModule manModule, Module ijModule )
{
  List<IDirectory> ijClasspath = manModule.getJavaClassPath();
  List<IDirectory> ijSources = manModule.getSourcePath();
  List<IDirectory> gosuClasspath = manModule.getJavaClassPath();
  if( areDifferentIgnoringOrder( ijClasspath, gosuClasspath ) )
  {
    changeClasspath( manModule, ijClasspath, ijSources );
  }
}
 
Example 39
Project: manifold-ij   File: AbstractManifoldCodeInsightTest.java   View source code 5 votes vote down vote up
@Override
protected Module createModule( @NotNull Project project, @NotNull String moduleFilePath )
{
  Module module = super.createModule( project, moduleFilePath );
  for( String jarFileName : getLibs() )
  {
    PsiTestUtil.addLibrary( module, getPath_LibRoot() + File.separatorChar + jarFileName );
  }
  PsiTestUtil.addLibrary( module, findToolsJar() );
  return module;
}
 
Example 40
Project: hybris-integration-intellij-idea-plugin   File: WebFacetConfigurator.java   View source code 5 votes vote down vote up
@Override
public void configure(
    @NotNull final ModifiableFacetModel modifiableFacetModel,
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final Module javaModule,
    @NotNull final ModifiableRootModel modifiableRootModel
) {
    final File webRoot = moduleDescriptor.getWebRoot();
    if (null == webRoot) {
        return;
    }

    WebFacet webFacet = modifiableFacetModel.getFacetByType(WebFacet.ID);

    if (webFacet == null) {
        final FacetType<WebFacet, FacetConfiguration> webFacetType = FacetTypeRegistry.getInstance().findFacetType(
            WebFacet.ID
        );

        if (!webFacetType.isSuitableModuleType(ModuleType.get(javaModule))) {
            return;
        }

        webFacet = FacetManager.getInstance(javaModule).createFacet(
            webFacetType, webFacetType.getDefaultFacetName(), null
        );

        modifiableFacetModel.addFacet(webFacet);

    } else {
        webFacet.removeAllWebRoots();
        webFacet.getDescriptorsContainer().getConfiguration().removeConfigFiles(
            DeploymentDescriptorsConstants.WEB_XML_META_DATA
        );
    }

    webFacet.setWebSourceRoots(modifiableRootModel.getSourceRootUrls(false));
    webFacet.addWebRootNoFire(VfsUtil.pathToUrl(FileUtil.toSystemIndependentName(webRoot.getAbsolutePath())), "/");
    this.setupFacetDeploymentDescriptor(webFacet, moduleDescriptor);
}