Minor fix/optimization

This commit is contained in:
Roman Shevchenko
2012-11-16 14:26:29 +01:00
parent 7b549c10ef
commit 911cf28e96
2 changed files with 16 additions and 4 deletions
@@ -1,6 +1,8 @@
package org.jetbrains.jps.model.library.impl;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.io.FileUtilRt;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jps.model.*;
@@ -11,9 +13,7 @@ import org.jetbrains.jps.model.library.*;
import org.jetbrains.jps.util.JpsPathUtil;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
/**
* @author nik
@@ -147,6 +147,8 @@ public class JpsLibraryImpl<P extends JpsElement> extends JpsNamedCompositeEleme
return urls;
}
private static final Set<String> AR_EXTENSIONS = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY, "jar", "zip", "swc", "ane");
private static void collectArchives(File file, boolean recursively, List<String> result) {
final File[] children = file.listFiles();
if (children != null) {
@@ -158,7 +160,7 @@ public class JpsLibraryImpl<P extends JpsElement> extends JpsNamedCompositeEleme
}
}
// todo [nik] get list of extensions mapped to Archive file type from IDE settings
else if (extension.equals("jar") || extension.equals("zip") || extension.equals("swc") || extension.equals("ane")) {
else if (AR_EXTENSIONS.contains(extension)) {
result.add(JpsPathUtil.getLibraryRootUrl(child));
}
}
@@ -193,11 +193,21 @@ public class ContainerUtil extends ContainerUtilRt {
return new THashSet<T>();
}
@NotNull
public static <T> THashSet<T> newTroveSet(TObjectHashingStrategy<T> strategy) {
return new THashSet<T>(strategy);
}
@NotNull
public static <T> THashSet<T> newTroveSet(T... elements) {
return newTroveSet(Arrays.asList(elements));
}
@NotNull
public static <T> THashSet<T> newTroveSet(TObjectHashingStrategy<T> strategy, T... elements) {
return new THashSet<T>(Arrays.asList(elements), strategy);
}
@NotNull
public static <T> THashSet<T> newTroveSet(@NotNull Collection<T> elements) {
return new THashSet<T>(elements);