Don't use caching LibraryDetectionManager because it isn't updated properly
This commit is contained in:
@@ -17,14 +17,13 @@
|
||||
package org.jetbrains.jet.plugin.framework;
|
||||
|
||||
import com.intellij.openapi.roots.OrderRootType;
|
||||
import com.intellij.openapi.roots.libraries.*;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.roots.libraries.Library;
|
||||
import com.intellij.openapi.roots.libraries.LibraryPresentationProvider;
|
||||
import com.intellij.openapi.roots.libraries.LibraryProperties;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class LibraryPresentationProviderUtil {
|
||||
private LibraryPresentationProviderUtil() {}
|
||||
@@ -33,34 +32,8 @@ public class LibraryPresentationProviderUtil {
|
||||
return getLibraryProperties(provider, library) != null;
|
||||
}
|
||||
|
||||
public static <LP extends LibraryProperties> boolean isDetected(@NotNull LibraryPresentationProvider<LP> provider, @NotNull List<VirtualFile> classesRoots) {
|
||||
return cachedDetect(provider, classesRoots) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static <LP extends LibraryProperties> LP getLibraryProperties(@NotNull LibraryPresentationProvider<LP> provider, @NotNull Library library) {
|
||||
return cachedDetect(provider, Arrays.asList(library.getFiles(OrderRootType.CLASSES)));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static <LP extends LibraryProperties> LP cachedDetect(@NotNull final LibraryPresentationProvider<LP> provider, @NotNull List<VirtualFile> classesRoots) {
|
||||
final Ref<LP> propertiesRef = new Ref<LP>();
|
||||
|
||||
LibraryDetectionManager.getInstance().processProperties(
|
||||
classesRoots,
|
||||
new LibraryDetectionManager.LibraryPropertiesProcessor() {
|
||||
@Override
|
||||
public <P extends LibraryProperties> boolean processProperties(@NotNull LibraryKind processedKind, @NotNull P properties) {
|
||||
if (provider.getKind().equals(processedKind)) {
|
||||
//noinspection unchecked
|
||||
propertiesRef.set((LP)properties);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
return propertiesRef.get();
|
||||
return provider.detect(Arrays.asList(library.getFiles(OrderRootType.CLASSES)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user