Package com.intellij.openapi.roots

Examples of com.intellij.openapi.roots.ModuleRootManager


      final String jarPathForNRepl = PathUtil.getJarPathForClass(Connection.class);
      params.getClassPath().add(jarPathForNRepl);
    }

    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


    return getSpecificJarForLibrary(library, CLOJURE_JAR_NAME_PREFIX, CLOJURE_MAIN_CLASS_FILE);
  }


  public static boolean isClojureConfigured(final Module module) {
    ModuleRootManager manager = ModuleRootManager.getInstance(module);
    for (OrderEntry entry : manager.getOrderEntries()) {
      if (entry instanceof LibraryOrderEntry) {
        Library library = ((LibraryOrderEntry) entry).getLibrary();
        if (library != null) {
          for (VirtualFile file : library.getFiles(OrderRootType.CLASSES)) {
            String path = file.getPath();
View Full Code Here

    setupLibraries();
  }

  private void setupLibraries() {
    ModifiableRootModel rootModel = null;
    final ModuleRootManager rootManager = ModuleRootManager.getInstance(myFixture.getModule());

    // Add Clojure Library
    OrderEnumerator libs = rootManager.orderEntries().librariesOnly();
    final List<Library.ModifiableModel> libModels = new ArrayList<Library.ModifiableModel>();

    rootModel = TestUtils.addLibrary(rootModel, rootManager, libs, libModels, "clojureLib", TestUtils.getMockClojureLib(), null);
    rootModel = TestUtils.addLibrary(rootModel, rootManager, libs, libModels, "clojureContrib", TestUtils.getMockClojureContribLib(), null);
View Full Code Here

  protected void setUp() throws Exception {
    super.setUp();

    ModifiableRootModel rootModel = null;
    final ModuleRootManager rootManager = ModuleRootManager.getInstance(getModule());

    if (isConfigureSourceFolder()) {
      rootModel = ModuleRootManager.getInstance(getModule()).getModifiableModel();
      final String testDir = getTestFolderPath();

      // Configure source folder
      final File dir = new File(testDir);
      assertTrue(dir.exists());

      VirtualFile vDir = LocalFileSystem.getInstance().
          refreshAndFindFileByPath(dir.getCanonicalPath().replace(File.separatorChar, '/'));
      assertNotNull(vDir);
      ContentEntry contentEntry = rootModel.addContentEntry(vDir);
      contentEntry.addSourceFolder(vDir, false);
    }

    // Add Clojure Library
    OrderEnumerator libs = rootManager.orderEntries().librariesOnly();
    final List<Library.ModifiableModel> libModels = new ArrayList<Library.ModifiableModel>();

    rootModel = TestUtils.addLibrary(rootModel, rootManager, libs, libModels, "clojureLib", TestUtils.getMockClojureLib(), null);
    rootModel = TestUtils.addLibrary(rootModel, rootManager, libs, libModels, "clojureContrib", TestUtils.getMockClojureContribLib(), null);
View Full Code Here

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

      Set<VirtualFile> cpVFiles = new HashSet<VirtualFile>();
      ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(myModule);
      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

    addListener(this);
  }

  @Override
  public void moduleCreated(@NotNull Module module) {
    ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
    VirtualFile sourceRoots[] = moduleRootManager.getSourceRoots();

    if (sourceRoots.length != 1 ) {
      return;
    }
View Full Code Here

   * @return a directory to which the sources (or test sources depending on the second partameter) should be compiled.
   * Null is returned if output directory is not specified or is not valid
   */
  @Nullable
  public static VirtualFile getModuleOutputDirectory(final Module module, boolean forTestClasses) {
    final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
    VirtualFile outPath;
    if (forTestClasses) {
      final VirtualFile path = moduleRootManager.getCompilerOutputPathForTests();
      if (path != null) {
        outPath = path;
      }
      else {
        outPath = moduleRootManager.getCompilerOutputPath();
      }
    }
    else {
      outPath = moduleRootManager.getCompilerOutputPath();
    }
    if (outPath == null) {
      return null;
    }
    if (!outPath.isValid()) {
View Full Code Here

   * The same as {@link #getModuleOutputDirectory} but returns String.
   * The method still returns a non-null value if the output path is specified in Settings but does not exist on disk.
   */
  @Nullable
  public static String getModuleOutputPath(final Module module, boolean forTestClasses) {
    final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
    final String outPathUrl;
    final Application application = ApplicationManager.getApplication();
    if (forTestClasses) {
      if (application.isDispatchThread()) {
        final String url = moduleRootManager.getCompilerOutputPathForTestsUrl();
        outPathUrl = (url != null) ? url : moduleRootManager.getCompilerOutputPathUrl();
      }
      else {
        outPathUrl = application.runReadAction(new Computable<String>() {
          public String compute() {
            final String url = moduleRootManager.getCompilerOutputPathForTestsUrl();
            return (url != null) ? url : moduleRootManager.getCompilerOutputPathUrl();
          }
        });
      }
    }
    else { // for ordinary classes
      if (application.isDispatchThread()) {
        outPathUrl = moduleRootManager.getCompilerOutputPathUrl();
      }
      else {
        outPathUrl = application.runReadAction(new Computable<String>() {
          public String compute() {
            return moduleRootManager.getCompilerOutputPathUrl();
          }
        });
      }
    }
    if (outPathUrl != null) {
View Full Code Here

    public String[] getModuleSrc(String name) {
        Project project = getActiveProject();
        if (project != null) {
            Module module = ModuleManager.getInstance(project).findModuleByName(name);
            ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
            VirtualFile virtualFiles[] = moduleRootManager.getSourceRoots();
            String src[] = new String[virtualFiles.length];
            for (int count = 0; count < src.length; count++) {
                src[count] = virtualFiles[count].getPresentableUrl();
            }
            return src;
View Full Code Here

                    = project.getComponent(CheckStylePlugin.class);
            if (checkStylePlugin == null) {
                throw new IllegalStateException("Couldn't get checkstyle plugin");
            }

            final ModuleRootManager moduleRootManager
                    = ModuleRootManager.getInstance(module);
            final VirtualFile[] moduleFiles = moduleRootManager.getSourceRoots();

            // disable if no files are selected
            if (moduleFiles.length == 0) {
                presentation.setEnabled(false);
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.