com.intellij.openapi.roots.OrderEnumerator Java Examples
The following examples show how to use
com.intellij.openapi.roots.OrderEnumerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MuleSdk.java From mule-intellij-plugins with Apache License 2.0 | 6 votes |
@Nullable private static String getMuleHome(@NotNull Module module) { if (!DumbService.isDumb(module.getProject())) { final OrderEnumerator enumerator = ModuleRootManager.getInstance(module) .orderEntries().recursively().librariesOnly().exportedOnly(); final String[] home = new String[1]; enumerator.forEachLibrary(library -> { if (MuleLibraryKind.MULE_LIBRARY_KIND.equals(((LibraryEx) library).getKind()) && library.getFiles(OrderRootType.CLASSES) != null && library.getFiles(OrderRootType.CLASSES).length > 0) { home[0] = getMuleHome(library.getFiles(OrderRootType.CLASSES)[0]); return false; } else { return true; } }); return home[0]; } return null; }
Example #2
Source File: ProtostuffPluginController.java From protobuf-jetbrains-plugin with Apache License 2.0 | 6 votes |
/** * Add global protobuf library to given module. Visible for testing. */ public void addLibrary(Module module) { ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); ModifiableRootModel modifiableRootModel = moduleRootManager.getModifiableModel(); AtomicBoolean found = new AtomicBoolean(false); OrderEnumerator.orderEntries(module).forEachLibrary(library1 -> { if (LIB_NAME.equals(library1.getName())) { found.set(true); return false; } return true; }); if (!found.get()) { ApplicationManager.getApplication().runWriteAction(() -> { modifiableRootModel.addLibraryEntry(globalLibrary); modifiableRootModel.commit(); }); } }
Example #3
Source File: XQueryRunProfileState.java From intellij-xquery with Apache License 2.0 | 6 votes |
private Sdk getJdkToRunModule(Module module) { final Sdk moduleSdk = ModuleRootManager.getInstance(module).getSdk(); if (moduleSdk == null) { return null; } final Set<Sdk> sdksFromDependencies = new LinkedHashSet<>(); OrderEnumerator enumerator = OrderEnumerator.orderEntries(module).runtimeOnly().recursively(); enumerator = enumerator.productionOnly(); enumerator.forEachModule(module1 -> { Sdk sdk = ModuleRootManager.getInstance(module1).getSdk(); if (sdk != null && sdk.getSdkType().equals(moduleSdk.getSdkType())) { sdksFromDependencies.add(sdk); } return true; }); return findLatestVersion(moduleSdk, sdksFromDependencies); }
Example #4
Source File: RoboVmPlugin.java From robovm-idea with GNU General Public License v2.0 | 6 votes |
public static boolean isRoboVmModule(Module module) { // HACK! to identify if the module uses a robovm sdk if (ModuleRootManager.getInstance(module).getSdk() != null) { if (ModuleRootManager.getInstance(module).getSdk().getSdkType().getName().toLowerCase().contains("robovm")) { return true; } } // check if there's any RoboVM RT libs in the classpath OrderEnumerator classes = ModuleRootManager.getInstance(module).orderEntries().recursively().withoutSdk().compileOnly(); for (String path : classes.getPathsList().getPathList()) { if (isSdkLibrary(path)) { return true; } } // check if there's a robovm.xml file in the root of the module for(VirtualFile file: ModuleRootManager.getInstance(module).getContentRoots()) { if(file.findChild("robovm.xml") != null) { return true; } } return false; }
Example #5
Source File: HaxeProjectModel.java From intellij-haxe with Apache License 2.0 | 6 votes |
private static HaxeSourceRootModel getSdkRoot(final HaxeProjectModel model) { final VirtualFile[] roots; if (ApplicationManager.getApplication().isUnitTestMode()) { roots = OrderEnumerator.orderEntries(model.getProject()).getAllSourceRoots(); if (roots.length > 0) { VirtualFile stdRootForTests = roots[0].findChild("std"); if (stdRootForTests != null) { return new HaxeSourceRootModel(model, stdRootForTests); } } } else { roots = OrderEnumerator.orderEntries(model.getProject()).sdkOnly().getAllSourceRoots(); for (VirtualFile root : roots) { if (root.findChild(STD_TYPES_HX) != null) { return new HaxeSourceRootModel(model, root); } } } return HaxeSourceRootModel.DUMMY; }
Example #6
Source File: HaxeProjectModel.java From intellij-haxe with Apache License 2.0 | 5 votes |
private static List<HaxeSourceRootModel> getProjectRoots(final HaxeProjectModel model) { final OrderEnumerator enumerator = OrderEnumerator.orderEntries(model.getProject()).withoutSdk(); return Stream.concat( Arrays.stream(enumerator.getClassesRoots()), Arrays.stream(enumerator.getSourceRoots()) ) .distinct() .map(root -> new HaxeSourceRootModel(model, root)) .collect(Collectors.toList()); }
Example #7
Source File: ModulePathMacro.java From consulo with Apache License 2.0 | 5 votes |
@Override public String expand(DataContext dataContext) { final Module module = dataContext.getData(LangDataKeys.MODULE); if (module == null) { return null; } return OrderEnumerator.orderEntries(module).withoutSdk().withoutLibraries().getSourcePathsList().getPathsString(); }
Example #8
Source File: VfsRootAccess.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static Collection<String> getAllRootUrls(@Nonnull Project project) { insideGettingRoots = true; final Set<String> roots = new THashSet<>(); OrderEnumerator enumerator = ProjectRootManager.getInstance(project).orderEntries().using(new DefaultModulesProvider(project)); ContainerUtil.addAll(roots, enumerator.classes().getUrls()); ContainerUtil.addAll(roots, enumerator.sources().getUrls()); insideGettingRoots = false; return roots; }
Example #9
Source File: ModuleChunk.java From consulo with Apache License 2.0 | 5 votes |
public OrderedSet<VirtualFile> getCompilationBootClasspathFiles(SdkType sdkType, final boolean exportedOnly) { final Set<Module> modules = getNodes(); final OrderedSet<VirtualFile> cpFiles = new OrderedSet<VirtualFile>(); final OrderedSet<VirtualFile> jdkFiles = new OrderedSet<VirtualFile>(); for (final Module module : modules) { Collections.addAll(cpFiles, orderEnumerator(module, exportedOnly, new BeforeSdkOrderEntryCondition(sdkType, module)).getClassesRoots()); Collections.addAll(jdkFiles, OrderEnumerator.orderEntries(module).sdkOnly().getClassesRoots()); } cpFiles.addAll(jdkFiles); return cpFiles; }
Example #10
Source File: ModuleChunk.java From consulo with Apache License 2.0 | 5 votes |
private OrderEnumerator orderEnumerator(Module module, boolean exportedOnly, Condition<OrderEntry> condition) { OrderEnumerator enumerator = OrderEnumerator.orderEntries(module).compileOnly().satisfying(condition); if ((mySourcesFilter & TEST_SOURCES) == 0) { enumerator = enumerator.productionOnly(); } enumerator = enumerator.recursively(); return exportedOnly ? enumerator.exportedOnly() : enumerator; }
Example #11
Source File: XQueryRunProfileState.java From intellij-xquery with Apache License 2.0 | 5 votes |
private void configureByModule(SimpleJavaParameters parameters, final Module module, final Sdk jdk) throws CantRunException { if (jdk == null) { throw CantRunException.noJdkConfigured(); } parameters.setJdk(jdk); setDefaultCharset(parameters, module.getProject()); configureEnumerator(OrderEnumerator.orderEntries(module).runtimeOnly().recursively(), jdk).collectPaths(parameters.getClassPath()); }
Example #12
Source File: QuarkusModuleUtil.java From intellij-quarkus with Eclipse Public License 2.0 | 5 votes |
/** * Check if the module is a Quarkus project. Should check if some class if present * but it seems PSI is not available when the module is added thus we rely on the * library names. * * @param module the module to check * @return yes if module is a Quarkus project */ public static boolean isQuarkusModule(Module module) { OrderEnumerator libraries = ModuleRootManager.getInstance(module).orderEntries().librariesOnly(); return libraries.process(new RootPolicy<Boolean>() { @Override public Boolean visitLibraryOrderEntry(@NotNull LibraryOrderEntry libraryOrderEntry, Boolean value) { return value | isQuarkusLibrary(libraryOrderEntry); } }, false); }
Example #13
Source File: GaugeUtil.java From Intellij-Plugin with Apache License 2.0 | 5 votes |
public static String classpathForModule(Module module) { if (GaugeUtil.isGradleModule(module)) { String cp = ""; for (Module module1 : Gauge.getSubModules(module)) cp += OrderEnumerator.orderEntries(module1).recursively().getPathsList().getPathsString() + Constants.CLASSPATH_DELIMITER; return cp; } return OrderEnumerator.orderEntries(module).recursively().getPathsList().getPathsString(); }
Example #14
Source File: SuggestionServiceImpl.java From intellij-spring-assistant with MIT License | 5 votes |
private void reindexModule(List<MetadataContainerInfo> newProjectSourcesToProcess, List<MetadataContainerInfo> projectContainersToRemove, Module module) { Map<String, MetadataContainerInfo> moduleSeenContainerPathToSeenContainerInfo = moduleNameToSeenContainerPathToContainerInfo .computeIfAbsent(module.getName(), k -> new THashMap<>()); Trie<String, MetadataSuggestionNode> moduleRootSearchIndex = moduleNameToRootSearchIndex.get(module.getName()); if (moduleRootSearchIndex == null) { moduleRootSearchIndex = new PatriciaTrie<>(); moduleNameToRootSearchIndex.put(module.getName(), moduleRootSearchIndex); } OrderEnumerator moduleOrderEnumerator = OrderEnumerator.orderEntries(module); List<MetadataContainerInfo> newModuleContainersToProcess = computeNewContainersToProcess(moduleOrderEnumerator, moduleSeenContainerPathToSeenContainerInfo); newModuleContainersToProcess.addAll(newProjectSourcesToProcess); List<MetadataContainerInfo> moduleContainersToRemove = computeContainersToRemove(moduleOrderEnumerator, moduleSeenContainerPathToSeenContainerInfo); moduleContainersToRemove.addAll(projectContainersToRemove); processContainers(module, newModuleContainersToProcess, moduleContainersToRemove, moduleSeenContainerPathToSeenContainerInfo, moduleRootSearchIndex); }
Example #15
Source File: SuggestionServiceImpl.java From intellij-spring-assistant with MIT License | 5 votes |
/** * Finds the containers that are not reachable from current classpath * * @param orderEnumerator classpath roots to work with * @param seenContainerPathToContainerInfo seen container paths * @return list of container paths that are no longer valid */ private List<MetadataContainerInfo> computeContainersToRemove(OrderEnumerator orderEnumerator, Map<String, MetadataContainerInfo> seenContainerPathToContainerInfo) { Set<String> newContainerPaths = stream(orderEnumerator.recursively().classes().getRoots()) .flatMap(MetadataContainerInfo::getContainerArchiveOrFileRefs).collect(toSet()); Set<String> knownContainerPathSet = new THashSet<>(seenContainerPathToContainerInfo.keySet()); knownContainerPathSet.removeAll(newContainerPaths); return knownContainerPathSet.stream().map(seenContainerPathToContainerInfo::get) .collect(toList()); }
Example #16
Source File: SuggestionServiceImpl.java From intellij-spring-assistant with MIT License | 5 votes |
private List<MetadataContainerInfo> computeNewContainersToProcess(OrderEnumerator orderEnumerator, Map<String, MetadataContainerInfo> seenContainerPathToContainerInfo) { List<MetadataContainerInfo> containersToProcess = new ArrayList<>(); for (VirtualFile metadataFileContainer : orderEnumerator.recursively().classes().getRoots()) { Collection<MetadataContainerInfo> metadataContainerInfos = MetadataContainerInfo.newInstances(metadataFileContainer); for (MetadataContainerInfo metadataContainerInfo : metadataContainerInfos) { boolean seenBefore = seenContainerPathToContainerInfo .containsKey(metadataContainerInfo.getContainerArchiveOrFileRef()); boolean updatedSinceLastSeen = false; if (seenBefore) { MetadataContainerInfo seenMetadataContainerInfo = seenContainerPathToContainerInfo .get(metadataContainerInfo.getContainerArchiveOrFileRef()); updatedSinceLastSeen = metadataContainerInfo.isModified(seenMetadataContainerInfo); if (updatedSinceLastSeen) { debug(() -> log.debug("Container seems to have been updated. Previous version: " + seenMetadataContainerInfo + "; Newer version: " + metadataContainerInfo)); } } boolean looksFresh = !seenBefore || updatedSinceLastSeen; boolean processMetadata = looksFresh && metadataContainerInfo.containsMetadataFile(); if (processMetadata) { containersToProcess.add(metadataContainerInfo); } if (looksFresh) { seenContainerPathToContainerInfo .put(metadataContainerInfo.getContainerArchiveOrFileRef(), metadataContainerInfo); } } } if (containersToProcess.size() == 0) { debug(() -> log.debug("No (new)metadata files to index")); } return containersToProcess; }
Example #17
Source File: PantsClasspathRunConfigurationExtension.java From intellij-pants-plugin with Apache License 2.0 | 4 votes |
private void processRuntimeModules(@NotNull Module module, Processor<Module> processor) { final OrderEnumerator runtimeEnumerator = OrderEnumerator.orderEntries(module).runtimeOnly().recursively(); runtimeEnumerator.forEachModule(processor); }
Example #18
Source File: IBIntegratorManager.java From robovm-idea with GNU General Public License v2.0 | 4 votes |
public void moduleChanged(Module module) { if (!hasIBIntegrator || !System.getProperty("os.name").toLowerCase().contains("mac os x")) { return; } String moduleId = getModuleId(module); IBIntegratorProxy proxy = daemons.get(moduleId); if(proxy == null) { try { File buildDir = RoboVmPlugin.getModuleXcodeDir(module); RoboVmPlugin.logInfo(module.getProject(), "Starting Interface Builder integrator daemon for module %s", moduleId); proxy = new IBIntegratorProxy(RoboVmPlugin.getRoboVmHome(), RoboVmPlugin.getLogger(module.getProject()), moduleId, buildDir); proxy.start(); daemons.put(moduleId, proxy); } catch (Throwable e) { RoboVmPlugin.logWarn(module.getProject(), "Failed to start Interface Builder integrator for module " + module.getName() + ": " + e.getMessage()); } } if(proxy != null) { // set the classpath, excluding module output paths OrderEnumerator classes = ModuleRootManager.getInstance(module).orderEntries().recursively().withoutSdk().compileOnly().productionOnly(); List<File> classPaths = new ArrayList<File>(); for(String path: classes.getPathsList().getPathList()) { classPaths.add(new File(path)); } proxy.setClasspath(classPaths); // set the source paths Set<File> moduleOutputPaths = new HashSet<File>(); for(Module dep: ModuleRootManager.getInstance(module).getDependencies(false)) { moduleOutputPaths.add(new File(CompilerPaths.getModuleOutputPath(dep, false))); } moduleOutputPaths.add(new File(CompilerPaths.getModuleOutputPath(module, false))); // we need to create the dirs here as they // may not have been generated by IDEA yet for(File file: moduleOutputPaths) { file.mkdirs(); } proxy.setSourceFolders(moduleOutputPaths); // set the resource paths proxy.setResourceFolders(RoboVmPlugin.getModuleResourcePaths(module)); // set the plist file location File infoPlist = RoboVmPlugin.getModuleInfoPlist(module); if(infoPlist != null) { proxy.setInfoPlist(infoPlist); } } }
Example #19
Source File: XQueryRunProfileState.java From intellij-xquery with Apache License 2.0 | 4 votes |
private OrderRootsEnumerator configureEnumerator(OrderEnumerator enumerator, Sdk jdk) { enumerator = enumerator.productionOnly(); OrderRootsEnumerator rootsEnumerator = enumerator.classes(); rootsEnumerator = rootsEnumerator.usingCustomRootProvider(e -> e instanceof JdkOrderEntry ? jdkRoots(jdk) : e.getFiles(OrderRootType.CLASSES)); return rootsEnumerator; }
Example #20
Source File: BlazeAndroidSyncPluginTest.java From intellij with Apache License 2.0 | 4 votes |
@NotNull @Override public OrderEnumerator orderEntries(@NotNull Collection<? extends Module> collection) { return null; }
Example #21
Source File: BlazeAndroidSyncPluginTest.java From intellij with Apache License 2.0 | 4 votes |
@NotNull @Override public OrderEnumerator orderEntries() { return null; }
Example #22
Source File: MockProjectRootManager.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public OrderEnumerator orderEntries() { throw new UnsupportedOperationException(); }
Example #23
Source File: MockProjectRootManager.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public OrderEnumerator orderEntries(@Nonnull Collection<? extends Module> modules) { throw new UnsupportedOperationException(); }
Example #24
Source File: SourcepathMacro.java From consulo with Apache License 2.0 | 4 votes |
@Override public String expand(DataContext dataContext) { Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project == null) return null; return OrderEnumerator.orderEntries(project).withoutSdk().withoutLibraries().getSourcePathsList().getPathsString(); }
Example #25
Source File: ProjectPathMacro.java From consulo with Apache License 2.0 | 4 votes |
@Override public String expand(DataContext dataContext) { Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project == null) return null; return OrderEnumerator.orderEntries(project).withoutSdk().withoutLibraries().getSourcePathsList().getPathsString(); }