Java Code Examples for com.intellij.util.containers.ContainerUtil#concat()

The following examples show how to use com.intellij.util.containers.ContainerUtil#concat() . 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: InspectionEngine.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Map<String, List<ProblemDescriptor>> inspectEx(@Nonnull final List<LocalInspectionToolWrapper> toolWrappers,
                                                             @Nonnull final PsiFile file,
                                                             @Nonnull final InspectionManager iManager,
                                                             final boolean isOnTheFly,
                                                             boolean failFastOnAcquireReadAction,
                                                             @Nonnull final ProgressIndicator indicator) {
  if (toolWrappers.isEmpty()) return Collections.emptyMap();


  TextRange range = file.getTextRange();
  List<Divider.DividedElements> allDivided = new ArrayList<>();
  Divider.divideInsideAndOutsideAllRoots(file, range, range, Conditions.alwaysTrue(), new CommonProcessors.CollectProcessor<>(allDivided));

  List<PsiElement> elements = ContainerUtil.concat(
          (List<List<PsiElement>>)ContainerUtil.map(allDivided, d -> ContainerUtil.concat(d.inside, d.outside, d.parents)));

  return inspectElements(toolWrappers, file, iManager, isOnTheFly, failFastOnAcquireReadAction, indicator, elements,
                         calcElementDialectIds(elements));
}
 
Example 2
Source File: PatternCompilerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static Set<Method> getStaticMethods(List<Class> patternClasses) {
  return new THashSet<Method>(ContainerUtil.concat(patternClasses, new Function<Class, Collection<? extends Method>>() {
    public Collection<Method> fun(final Class aClass) {
      return ContainerUtil.findAll(aClass.getMethods(), new Condition<Method>() {
        public boolean value(final Method method) {
          return Modifier.isStatic(method.getModifiers())
                 && Modifier.isPublic(method.getModifiers())
                 && !Modifier.isAbstract(method.getModifiers())
                 && ElementPattern.class.isAssignableFrom(method.getReturnType());
        }
      });
    }
  }));
}
 
Example 3
Source File: VirtualFilePointerContainerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public List<Pair<String, Boolean>> getJarDirectories() {
  List<Pair<String, Boolean>> jars = ContainerUtil.map(myJarDirectories, ptr -> Pair.create(ptr.getUrl(), false));
  List<Pair<String, Boolean>> recJars = ContainerUtil.map(myJarRecursiveDirectories, ptr -> Pair.create(ptr.getUrl(), true));
  return ContainerUtil.concat(jars, recJars);
}
 
Example 4
Source File: VirtualFilePointerContainerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nullable
public VirtualFilePointer findByUrl(@Nonnull String url) {
  checkDisposed();
  for (VirtualFilePointer pointer : ContainerUtil.concat(myList, myJarDirectories, myJarRecursiveDirectories)) {
    if (url.equals(pointer.getUrl())) return pointer;
  }
  return null;
}
 
Example 5
Source File: TokenBuffer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private List<TokenInfo> getInfos() {
  List<TokenInfo> list = tokens.toList();
  if (startIndex != 0) {
    // slice the first token
    TokenInfo first = list.get(0);
    TokenInfo sliced = new TokenInfo(first.contentType, first.getText().substring(startIndex), first.getHyperlinkInfo());
    return ContainerUtil.concat(Collections.singletonList(sliced), list.subList(1, list.size()));
  }
  return list;
}
 
Example 6
Source File: LibraryDetectionManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static List<Pair<LibraryKind, LibraryProperties>> computeKinds(List<VirtualFile> files) {
  final SmartList<Pair<LibraryKind, LibraryProperties>> result = new SmartList<Pair<LibraryKind, LibraryProperties>>();
  final LibraryType<?>[] libraryTypes = LibraryType.EP_NAME.getExtensions();
  final LibraryPresentationProvider[] presentationProviders = LibraryPresentationProvider.EP_NAME.getExtensions();
  for (LibraryPresentationProvider provider : ContainerUtil.concat(libraryTypes, presentationProviders)) {
    final LibraryProperties properties = provider.detect(files);
    if (properties != null) {
      result.add(Pair.create(provider.getKind(), properties));
    }
  }
  return result;
}
 
Example 7
Source File: XAttachDebuggerProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * will be removed in 2020.1, right after {@link XLocalAttachDebuggerProvider}
 */
@Deprecated
//@ApiStatus.ScheduledForRemoval(inVersion = "2020.1")
@Nonnull
static List<XAttachDebuggerProvider> getAttachDebuggerProviders() {
  return ContainerUtil.concat(new ArrayList<>(EP.getExtensionList()), new ArrayList<>(XLocalAttachDebuggerProvider.EP.getExtensionList()));
}
 
Example 8
Source File: XValueContainerNode.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
public List<? extends XValueContainerNode<?>> getLoadedChildren() {
  List<? extends XValueContainerNode<?>> empty = Collections.<XValueGroupNodeImpl>emptyList();
  return ContainerUtil.concat(ObjectUtils.notNull(myTopGroups, empty),
                              ObjectUtils.notNull(myValueChildren, empty),
                              ObjectUtils.notNull(myBottomGroups, empty));
}
 
Example 9
Source File: StubTree.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
final List<StubElement<?>> getPlainListFromAllRoots() {
  PsiFileStub[] roots = ((PsiFileStubImpl<?>)getRoot()).getStubRoots();
  if (roots.length == 1) return super.getPlainListFromAllRoots();

  return ContainerUtil.concat(roots, stub -> ((PsiFileStubImpl)stub).myStubList.toPlainList());
}
 
Example 10
Source File: StructureAwareNavBarModelExtension.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
private List<TreeElement> childrenFromNodeAndProviders(StructureViewTreeElement parent) {
  List<TreeElement> children;
  if (parent instanceof PsiTreeElementBase) {
    children = ((PsiTreeElementBase)parent).getChildrenWithoutCustomRegions();
  }
  else {
    children = Arrays.asList(parent.getChildren());
  }

  List<TreeElement> fromProviders = getApplicableNodeProviders().stream().flatMap(nodeProvider -> nodeProvider.provideNodes(parent).stream()).collect(Collectors.toList());
  return ContainerUtil.concat(children, fromProviders);
}
 
Example 11
Source File: ContainerUtil2.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Contract(pure = true)
@SafeVarargs
public static <T> Collection<T> concat(@Nonnull final Collection<? extends T>... collections)
{
	int size = 0;
	for(Collection<? extends T> each : collections)
	{
		size += each.size();
	}

	if(size == 0)
	{
		return Collections.emptyList();
	}

	Iterable<T> iterable = ContainerUtil.concat(collections);
	final int finalSize = size;
	return new AbstractCollection<T>()
	{
		@Nonnull
		@Override
		public Iterator<T> iterator()
		{
			return iterable.iterator();
		}

		@Override
		public int size()
		{
			return finalSize;
		}
	};
}
 
Example 12
Source File: ContainerUtil2.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Contract(pure = true)
public static <T> Collection<T> concat(@Nonnull final List<Collection<? extends T>> collections)
{
	int size = 0;
	for(Collection<? extends T> each : collections)
	{
		size += each.size();
	}

	if(size == 0)
	{
		return Collections.emptyList();
	}

	Collection[] iterables = collections.toArray(new Collection[collections.size()]);
	Iterable<T> iterable = ContainerUtil.<T>concat(iterables);
	final int finalSize = size;
	return new AbstractCollection<T>()
	{
		@Nonnull
		@Override
		public Iterator<T> iterator()
		{
			return iterable.iterator();
		}

		@Override
		public int size()
		{
			return finalSize;
		}
	};
}
 
Example 13
Source File: MergingUpdateQueue.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private List<Update> getAllScheduledUpdates() {
  return ContainerUtil.concat(myScheduledUpdates.values(), map -> map.keySet());
}
 
Example 14
Source File: FindUsagesImpl171.java    From Android-Resource-Usage-Count with MIT License 4 votes vote down vote up
@NotNull
private static UsageSearcher createUsageSearcher(@NotNull final PsiElement[] primaryElements, @NotNull final PsiElement[] secondaryElements, @NotNull final FindUsagesHandler handler, @NotNull FindUsagesOptions options, final PsiFile scopeFile) {
    final FindUsagesOptions optionsClone = options.clone();
    return new UsageSearcher() {
        public void generate(@NotNull final Processor<Usage> processor) {
            Project project = (Project) ApplicationManager.getApplication().runReadAction(new Computable() {
                public Project compute() {
                    return scopeFile != null?scopeFile.getProject():primaryElements[0].getProject();
                }
            });
            dropResolveCacheRegularly(ProgressManager.getInstance().getProgressIndicator(), project);
            if(scopeFile != null) {
                optionsClone.searchScope = new LocalSearchScope(scopeFile);
            }

            final CommonProcessors.UniqueProcessor usageInfoProcessor = new CommonProcessors.UniqueProcessor(new Processor<UsageInfo>() {
                @Override
                public boolean process(final UsageInfo usageInfo) {
                    Usage usage = (Usage)ApplicationManager.getApplication().runReadAction(new Computable() {
                        public Usage compute() {
                            return UsageInfoToUsageConverter.convert(primaryElements, usageInfo);
                        }
                    });
                    return processor.process(usage);
                }
            });
            Iterable elements = ContainerUtil.concat(new PsiElement[][]{primaryElements, secondaryElements});
            optionsClone.fastTrack = new SearchRequestCollector(new SearchSession());
            if(optionsClone.searchScope instanceof GlobalSearchScope) {
                optionsClone.searchScope = optionsClone.searchScope.union(GlobalSearchScope.projectScope(project));
            }

            try {
                Iterator i$ = elements.iterator();

                while(i$.hasNext()) {
                    final PsiElement element = (PsiElement)i$.next();
                    ApplicationManager.getApplication().runReadAction(new Runnable() {
                        public void run() {

                        }
                    });
                    handler.processElementUsages(element, usageInfoProcessor, optionsClone);
                    CustomUsageSearcher[] arr$ = (CustomUsageSearcher[])Extensions.getExtensions(CustomUsageSearcher.EP_NAME);
                    int len$ = arr$.length;

                    for(int i$1 = 0; i$1 < len$; ++i$1) {
                        CustomUsageSearcher searcher = arr$[i$1];

                        try {
                            searcher.processElementUsages(element, processor, optionsClone);
                        } catch (IndexNotReadyException var17) {
                            DumbService.getInstance(element.getProject()).showDumbModeNotification("Find usages is not available during indexing");
                        } catch (ProcessCanceledException var18) {
                            throw var18;
                        } catch (Exception var19) {

                        }
                    }
                }

                PsiSearchHelper.SERVICE.getInstance(project).processRequests(optionsClone.fastTrack, new Processor<PsiReference>() {
                    public boolean process(final PsiReference ref) {
                        UsageInfo info = (UsageInfo)ApplicationManager.getApplication().runReadAction(new Computable() {
                            public UsageInfo compute() {
                                return !ref.getElement().isValid()?null:new UsageInfo(ref);
                            }
                        });
                        return info == null || usageInfoProcessor.process(info);
                    }
                });
            } finally {
                optionsClone.fastTrack = null;
            }

        }
    };
}
 
Example 15
Source File: WatchesRootNode.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public List<? extends XValueContainerNode<?>> getLoadedChildren() {
  return ContainerUtil.concat(myChildren, super.getLoadedChildren());
}
 
Example 16
Source File: KeymapImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private <T extends Shortcut>void fillShortcut2ListOfIds(final Map<T,List<String>> map, final Class<T> shortcutClass) {
  for (String id : ContainerUtil.concat(myActionId2ListOfShortcuts.keySet(), getKeymapManager().getBoundActions())) {
    addAction2ShortcutsMap(id, map, shortcutClass);
  }
}
 
Example 17
Source File: FileColorsModel.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
private List<FileColorConfiguration> getConfigurations() {
  return ContainerUtil.concat(myApplicationLevelConfigurations, myProjectLevelConfigurations);
}
 
Example 18
Source File: CompositeDocumentationProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public List<DocumentationProvider> getAllProviders() {
  return ContainerUtil.concat(getProviders(), EP_NAME.getExtensionList());
}
 
Example 19
Source File: BoundedScheduledExecutorService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public List<Runnable> shutdownNow() {
  return ContainerUtil.concat(super.shutdownNow(), backendExecutorService.shutdownNow());
}
 
Example 20
Source File: AppScheduledExecutorService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
List<Runnable> doShutdownNow() {
  return ContainerUtil.concat(super.doShutdownNow(), ((BackendThreadPoolExecutor)backendExecutorService).superShutdownNow());
}