com.intellij.openapi.roots.RootPolicy Java Examples

The following examples show how to use com.intellij.openapi.roots.RootPolicy. 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: QuarkusModuleUtil.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
private static Integer computeHash(Module module) {
    ModuleRootManager manager = ModuleRootManager.getInstance(module);
    Set<String> files = manager.processOrder(new RootPolicy<Set<String>>() {
        @Override
        public Set<String> visitLibraryOrderEntry(@NotNull LibraryOrderEntry libraryOrderEntry, Set<String> value) {
            if (!libraryOrderEntry.getLibraryName().equalsIgnoreCase(QuarkusConstants.QUARKUS_DEPLOYMENT_LIBRARY_NAME) && isQuarkusExtensionWithDeploymentArtifact(libraryOrderEntry.getLibrary())) {
                for(VirtualFile file : libraryOrderEntry.getFiles(OrderRootType.CLASSES)) {
                    value.add(file.getPath());
                }
            }
            return value;
        }
    }, new HashSet<>());
    return files.isEmpty()?null:files.hashCode();
}
 
Example #2
Source File: QuarkusModuleUtil.java    From intellij-quarkus with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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 #3
Source File: Unity3dPackageOrderEntry.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Override
public <R> R accept(RootPolicy<R> rRootPolicy, @Nullable R r)
{
	return rRootPolicy.visitOrderEntry(this, r);
}
 
Example #4
Source File: UnknownOrderEntryImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public <R> R accept(RootPolicy<R> policy, @javax.annotation.Nullable R initialValue) {
  return policy.visitOrderEntry(this, initialValue);
}
 
Example #5
Source File: ModuleExtensionWithSdkOrderEntryImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public <R> R accept(@Nonnull RootPolicy<R> policy, R initialValue) {
  return policy.visitModuleExtensionSdkOrderEntry(this, initialValue);
}