Package com.intellij.openapi.roots

Examples of com.intellij.openapi.roots.ModuleRootManager


    sourceDir[0] = projectDir.findChild("src");
    if (sourceDir[0] == null) {
      sourceDir[0] = projectDir;
    }
    VirtualFile ext_src = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(testDir + "/ext_src"));
    final ModuleRootManager rootManager = ModuleRootManager.getInstance(myModule);
    final ModifiableRootModel rootModel = rootManager.getModifiableModel();
    rootModel.clear();
    // configure source and output path
    final ContentEntry contentEntry = rootModel.addContentEntry(projectDir);
    contentEntry.addSourceFolder(sourceDir[0], false);
    if (ext_src != null) {
View Full Code Here


                    CompilerUtil.refreshIOFile(outputPathFile);

                    // Refresh the source root corresponding to the output source path.
                    VirtualFile outputDirectory = LocalFileSystem.getInstance().findFileByIoFile(outputPathFile);
                    if (outputDirectory != null && outputDirectory.exists()) {
                        ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
                        VirtualFile[] sourceDirectories = rootManager.getSourceRoots();
                        for (VirtualFile sourceDirectory : sourceDirectories) {
                            String sourcePathUrl = sourceDirectory.getPresentableUrl();
                            if (sourcePathUrl.equals(outputDirectory.getPresentableUrl())) {
                                LOG.info("Forcing refresh of source directory '" + sourceDirectory.getPath() + "' for module '" + module.getName() + "'");
                                sourceDirectory.refresh(false, true);
View Full Code Here

                            PbBundle.message("compiler.validate.error.title"));
                    return false;
                }

                // Check that the output source directory is a module source directory.
                ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
                VirtualFile[] sourceDirectories = rootManager.getSourceRoots();
                boolean isSourceDirectory = false;
                for (VirtualFile sourceDirectory : sourceDirectories) {
                    String sourcePathUrl = sourceDirectory.getPath();
                    if (sourcePathUrl.equals(outputDirectory.getPath())) {
                        isSourceDirectory = true;
View Full Code Here

  public static Collection<ErlangFile> getErlangModules(Module module, boolean onlyTestModules) {
    return addErlangModules(module, onlyTestModules, new HashSet<ErlangFile>());
  }

  private static Collection<ErlangFile> addErlangModules(Module module, boolean onlyTestModules, Collection<ErlangFile> erlangModules) {
    ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
    ModuleFileIndex moduleFileIndex = rootManager.getFileIndex();
    Processor<VirtualFile> modulesCollector = getErlangModulesCollector(PsiManager.getInstance(module.getProject()), erlangModules);
    Convertor<VirtualFile, Boolean> sourceDirectoriesFilter = onlyTestModules ? getTestDirectoriesFilter(moduleFileIndex) : getSourceDirectoriesFilter(moduleFileIndex);

    for (VirtualFile sourceRoot : rootManager.getSourceRoots(onlyTestModules)) {
      VfsUtilCore.processFilesRecursively(sourceRoot, modulesCollector, sourceDirectoriesFilter);
    }

    return erlangModules;
  }
View Full Code Here

    GeneralCommandLine commandLine = new GeneralCommandLine();
    commandLine.setWorkDirectory(PathUtil.getParentPath(context.getProject().getProjectFilePath()));
    commandLine.setPassParentEnvironment(true);

    for (Module module : moduleChunk.getNodes()) {
      ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);

      for (VirtualFile sourceRoot : moduleRootManager.getSourceRoots()) {
        commandLine.addParameter("-I");
        String path = sourceRoot.getCanonicalPath();
        if (path != null) {
          commandLine.addParameter(path);
        }
      }

      VirtualFile outDir = context.getModuleOutputDirectory(module);
      if (outDir == null) {
        context.addMessage(CompilerMessageCategory.ERROR, "No output dir for module: " + module.getName(), null, -1, -1);
        return;
      }
      commandLine.setWorkDirectory(outDir.getCanonicalPath());

      for (VirtualFile o : files) {
        String canonicalPath = o.getCanonicalPath();
        if (canonicalPath == null) continue;
        commandLine.addParameter(canonicalPath);
      }

//      commandLine.addParameters("+warn_unused_vars", "+nowarn_shadow_vars", "+warn_unused_import");

      Sdk sdk = moduleRootManager.getSdk();

      if (sdk == null) {
        context.addMessage(CompilerMessageCategory.ERROR, "No SDK for module: " + module.getName(), null, -1, -1);
        return;
      }
View Full Code Here

  }

  @NotNull
  public static List<VirtualFile> getIncludeDirectories(@Nullable Module module) {
    if (module == null) return ContainerUtil.emptyList();
    ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
    return rootManager.getSourceRoots(ErlangIncludeSourceRootType.INSTANCE);
  }
View Full Code Here

  public static void markAsIncludeDirectory(@NotNull ContentEntry contentEntry, @NotNull VirtualFile directory) {
    contentEntry.addSourceFolder(directory, ErlangIncludeSourceRootType.INSTANCE);
  }

  public static void markAsIncludeDirectory(@NotNull Module module, @NotNull VirtualFile directory) {
    ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
    ModifiableRootModel rootModel = rootManager.getModifiableModel();
    for (ContentEntry contentEntry : rootModel.getContentEntries()) {
      VirtualFile contentRootDirectory = contentEntry.getFile();
      if (contentRootDirectory != null && VfsUtilCore.isAncestor(contentRootDirectory, directory, false)) {
        markAsIncludeDirectory(contentEntry, directory);
        rootModel.commit();
View Full Code Here

  @NotNull
  public static List<String> getCodePath(@NotNull Project project, @Nullable Module module, boolean useTestOutputPath) {
    final Set<Module> codePathModules = new HashSet<Module>();
    if (module != null) {
      ModuleRootManager moduleRootMgr = ModuleRootManager.getInstance(module);
      moduleRootMgr.orderEntries().recursively().forEachModule(new Processor<Module>() {
        @Override
        public boolean process(@NotNull Module dependencyModule) {
          codePathModules.add(dependencyModule);
          return true;
        }
      });
    }
    else {
      codePathModules.addAll(Arrays.asList(ModuleManager.getInstance(project).getModules()));
    }

    List<String> codePath = new ArrayList<String>(codePathModules.size() * 2);
    for (Module codePathModule : codePathModules) {
      ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(codePathModule);
      CompilerModuleExtension compilerModuleExt =
        moduleRootManager.getModuleExtension(CompilerModuleExtension.class);
      VirtualFile buildOutput = useTestOutputPath && codePathModule == module ?
        getCompilerOutputPathForTests(compilerModuleExt) :
        compilerModuleExt.getCompilerOutputPath();
      if (buildOutput != null) {
        codePath.add("-pa");
View Full Code Here

        params.configureByModule(module, JavaParameters.JDK_AND_CLASSES_AND_TESTS);

        params.getClassPath().add(PathUtil.getJarPathForClass(Main.class));

        Set<VirtualFile> cpVFiles = new HashSet<VirtualFile>();
        ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
        OrderEntry[] entries = moduleRootManager.getOrderEntries();
        for (OrderEntry orderEntry : entries) {
            if (orderEntry instanceof ModuleSourceOrderEntry) {
                cpVFiles.addAll(Arrays.asList(orderEntry.getFiles(OrderRootType.SOURCES)));
            }
        }
View Full Code Here

      assert jarPath != null;
      params.getClassPath().add(jarPath);
    }

    Set<VirtualFile> cpVFiles = new HashSet<VirtualFile>();
    ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
    OrderEntry[] entries = moduleRootManager.getOrderEntries();
    for (OrderEntry orderEntry : entries) {
      // Add module sources to classpath
      if (orderEntry instanceof ModuleSourceOrderEntry) {
        cpVFiles.addAll(Arrays.asList(orderEntry.getFiles(OrderRootType.SOURCES)));
      }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.roots.ModuleRootManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.