private static Iterable<String> getOutputPaths(Project project) { final Collection<String> paths = new LinkedHashSet<>(); final CompilerProjectExtension cpe = CompilerProjectExtension.getInstance(project); if (cpe != null && cpe.getCompilerOutput() != null) { paths.add(cpe.getCompilerOutput().getCanonicalPath()); } final Module[] modules = ModuleManager.getInstance(project).getModules(); for (Module module : modules) { final CompilerModuleExtension cme = CompilerModuleExtension.getInstance(module); if (cme != null && cme.getCompilerOutputPath() != null) { paths.add(cme.getCompilerOutputPath().getCanonicalPath()); } } return paths; }
@Nullable protected VirtualFile findClassFile(String className) { final CompilerModuleExtension extension = ModuleRootManager.getInstance(myModule).getModuleExtension(CompilerModuleExtension.class); //noinspection ConstantConditions return extension.getCompilerOutputPath().findChild(className + ".class"); }
private static String getOutput(Module module1, boolean test) { CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module1); assertNotNull(compilerModuleExtension); VirtualFile output = test ? compilerModuleExtension.getCompilerOutputPathForTests() : compilerModuleExtension.getCompilerOutputPath(); return getFSPath(output); }
/** * @param module * @param forTestClasses true if directory for test sources, false - for sources. * @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 CompilerModuleExtension compilerModuleExtension = CompilerModuleExtension.getInstance(module); VirtualFile outPath; if (forTestClasses) { final VirtualFile path = compilerModuleExtension.getCompilerOutputPathForTests(); if (path != null) { outPath = path; } else { outPath = compilerModuleExtension.getCompilerOutputPath(); } } else { outPath = compilerModuleExtension.getCompilerOutputPath(); } if (outPath == null) { return null; } if (!outPath.isValid()) { LOG.info("Requested output path for module " + module.getName() + " is not valid"); return null; } return outPath; }
private static void addRootsFromModule(Module module, Collection<String> pythonPathList) { // for Jython final CompilerModuleExtension extension = CompilerModuleExtension.getInstance(module); if (extension != null) { final VirtualFile path = extension.getCompilerOutputPath(); if (path != null) { pythonPathList.add(path.getPath()); } final VirtualFile pathForTests = extension.getCompilerOutputPathForTests(); if (pathForTests != null) { pythonPathList.add(pathForTests.getPath()); } } // additional paths from facets (f.e. buildout) final Facet[] facets = FacetManager.getInstance(module).getAllFacets(); for (Facet facet : facets) { if (facet instanceof PythonPathContributingFacet) { List<String> more_paths = ((PythonPathContributingFacet) facet).getAdditionalPythonPath(); if (more_paths != null) pythonPathList.addAll(more_paths); } } }
private static void removeModuleOutput(Module module, List<VirtualFile> from) { final CompilerModuleExtension extension = ModuleRootManager.getInstance(module).getModuleExtension(CompilerModuleExtension.class); from.remove(extension.getCompilerOutputPath()); from.remove(extension.getCompilerOutputPathForTests()); }