This commit is contained in:
Alexey Kudravtsev
2018-12-13 14:08:10 +03:00
parent efa4698167
commit ffcc579bbe
4 changed files with 26 additions and 26 deletions
@@ -15,7 +15,6 @@
*/
package com.intellij.jarRepository;
import com.google.common.base.Predicate;
import com.intellij.ProjectTopics;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
@@ -46,6 +45,7 @@ import org.jetbrains.idea.maven.utils.library.RepositoryLibraryProperties;
import org.jetbrains.idea.maven.utils.library.RepositoryUtils;
import java.util.*;
import java.util.function.Predicate;
/**
* @author gregsh
@@ -69,21 +69,21 @@ public class RepositoryLibrarySynchronizer implements StartupActivity, DumbAware
return false;
}
public static Set<Library> collectLibraries(final @NotNull Project project, final @NotNull Predicate<? super Library> predicate) {
public static Set<Library> collectLibraries(@NotNull final Project project, @NotNull final Predicate<? super Library> predicate) {
final Set<Library> result = new LinkedHashSet<>();
ApplicationManager.getApplication().runReadAction(() -> {
if (project.isDisposed()) return;
for (final Module module : ModuleManager.getInstance(project).getModules()) {
OrderEnumerator.orderEntries(module).withoutSdk().forEachLibrary(library -> {
if (predicate.apply(library)) {
if (predicate.test(library)) {
result.add(library);
}
return true;
});
}
for (Library library : ProjectLibraryTable.getInstance(project).getLibraries()) {
if (predicate.apply(library)) {
if (predicate.test(library)) {
result.add(library);
}
}
@@ -145,27 +145,25 @@ public class RepositoryLibrarySynchronizer implements StartupActivity, DumbAware
@Override
public void runActivity(@NotNull final Project project) {
final Runnable syncTask = () -> {
final Collection<Library> toSync = collectLibraries(project, library -> {
if (library instanceof LibraryEx) {
final LibraryEx libraryEx = (LibraryEx)library;
return libraryEx.getProperties() instanceof RepositoryLibraryProperties &&
isLibraryNeedToBeReloaded(libraryEx, (RepositoryLibraryProperties)libraryEx.getProperties());
}
return false;
});
ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> {
for (Library library : toSync) {
if (LibraryTableImplUtil.isValidLibrary(library)) {
RepositoryUtils.reloadDependencies(project, (LibraryEx)library);
}
}
}, project.getDisposed());
};
if (!ApplicationManager.getApplication().isUnitTestMode()) {
final Runnable syncTask = () -> {
final Collection<Library> toSync = collectLibraries(project, library -> {
if (library instanceof LibraryEx) {
final LibraryEx libraryEx = (LibraryEx)library;
return libraryEx.getProperties() instanceof RepositoryLibraryProperties &&
isLibraryNeedToBeReloaded(libraryEx, (RepositoryLibraryProperties)libraryEx.getProperties());
}
return false;
});
ApplicationManager.getApplication().invokeLater((DumbAwareRunnable)() -> {
for (Library library : toSync) {
if (LibraryTableImplUtil.isValidLibrary(library)) {
RepositoryUtils.reloadDependencies(project, (LibraryEx)library);
}
}
}, project.getDisposed());
};
project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
private final Alarm myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project);
@Override
@@ -50,7 +50,6 @@ public interface PsiModificationTracker extends ModificationTracker {
}
/**
* @param project
* @return The instance of {@link PsiModificationTracker} corresponding to the given project.
*/
public static PsiModificationTracker getInstance(Project project) {
@@ -127,6 +126,7 @@ public interface PsiModificationTracker extends ModificationTracker {
* A listener to be notified on any PSI modification count change (which happens on any physical PSI change).
* @see #TOPIC
*/
@FunctionalInterface
interface Listener {
/**
@@ -72,11 +72,13 @@ public final class ConcurrentWeakHashMap<K, V> extends ConcurrentRefHashMap<K, V
return new WeakKey<K, V>(key, hashingStrategy.computeHashCode(key), hashingStrategy, value, myReferenceQueue);
}
@Deprecated
public ConcurrentWeakHashMap(int initialCapacity) {
super(initialCapacity);
DeprecatedMethodException.report("Use com.intellij.util.containers.ConcurrentFactoryMap.createConcurrentWeakMap instead");
}
@Deprecated
public ConcurrentWeakHashMap() {
DeprecatedMethodException.report("Use com.intellij.util.containers.ConcurrentFactoryMap.createConcurrentWeakMap instead");
}
@@ -1900,7 +1900,7 @@ public class ContainerUtil extends ContainerUtilRt {
@NotNull
@Contract(pure=true)
public static <T,V> List<V> map(@NotNull Iterable<? extends T> iterable, @NotNull Function<? super T, ? extends V> mapping) {
List<V> result = new ArrayList<V>(iterable instanceof Collection ? ((Collection<T>)iterable).size() : 10);
List<V> result = new ArrayList<V>(iterable instanceof Collection ? ((Collection)iterable).size() : 10);
for (T t : iterable) {
result.add(mapping.fun(t));
}