mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -18,9 +18,10 @@ package com.intellij.psi.augment;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -32,10 +33,9 @@ public abstract class PsiAugmentProvider {
|
||||
|
||||
@NotNull
|
||||
public static <Psi extends PsiElement> List<Psi> collectAugments(@NotNull final PsiElement element, @NotNull final Class<Psi> type) {
|
||||
final List<Psi> augments = new ArrayList<Psi>();
|
||||
List<Psi> augments = Collections.emptyList();
|
||||
for (PsiAugmentProvider provider : Extensions.getExtensions(EP_NAME)) {
|
||||
final List<Psi> list = provider.getAugments(element, type);
|
||||
augments.addAll(list);
|
||||
augments = ContainerUtil.addAll(augments, provider.getAugments(element, type));
|
||||
}
|
||||
|
||||
return augments;
|
||||
|
||||
@@ -1189,6 +1189,24 @@ public class ContainerUtil extends ContainerUtilRt {
|
||||
return findInstance(Arrays.asList(array), aClass);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static <T> List<T> addAll(@NotNull final List<T> list1, @NotNull final List<T> list2) {
|
||||
if (list1.isEmpty() && list2.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
else if (list1.isEmpty()) {
|
||||
//noinspection unchecked
|
||||
return list2;
|
||||
}
|
||||
else if (list2.isEmpty()) {
|
||||
//noinspection unchecked
|
||||
return list1;
|
||||
}
|
||||
|
||||
list1.addAll(list2);
|
||||
return list1;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Contract(pure=true)
|
||||
public static <T, V> List<T> concat(@NotNull V[] array, @NotNull Function<V, Collection<? extends T>> fun) {
|
||||
|
||||
Reference in New Issue
Block a user