Merge branch 'master' of git@git.labs.intellij.net:idea/community

This commit is contained in:
Kirill Kalishev
2011-02-25 17:08:18 +03:00
2 changed files with 15 additions and 15 deletions
@@ -29,7 +29,6 @@ import com.intellij.openapi.util.Condition;
import com.intellij.openapi.util.Pair;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashSet;
import com.intellij.util.containers.hash.HashMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -112,7 +111,7 @@ public class StatisticsUploadAssistant {
public static Map<GroupDescriptor, Set<PatchedUsage>> getPatchedUsages(@NotNull Set<String> disabledGroups,
@NotNull Project[] projects,
@NotNull SentUsagesPersistence usagesPersistence) {
Map<GroupDescriptor, Set<PatchedUsage>> usages = new HashMap<GroupDescriptor, Set<PatchedUsage>>();
Map<GroupDescriptor, Set<PatchedUsage>> usages = new LinkedHashMap<GroupDescriptor, Set<PatchedUsage>>();
for (Project project : projects) {
final Map<GroupDescriptor, Set<UsageDescriptor>> allUsages = getAllUsages(project, disabledGroups);
@@ -125,7 +124,7 @@ public class StatisticsUploadAssistant {
@NotNull
private static Map<GroupDescriptor, Set<UsageDescriptor>> filterDisabled(@NotNull Set<String> disabledGroups, @NotNull Map<GroupDescriptor, Set<UsageDescriptor>> usages) {
Map<GroupDescriptor, Set<UsageDescriptor>> filtered = new HashMap<GroupDescriptor, Set<UsageDescriptor>>();
Map<GroupDescriptor, Set<UsageDescriptor>> filtered = new LinkedHashMap<GroupDescriptor, Set<UsageDescriptor>>();
for (Map.Entry<GroupDescriptor, Set<UsageDescriptor>> usage : usages.entrySet()) {
if (!disabledGroups.contains(usage.getKey().getId())) {
@@ -154,7 +153,7 @@ public class StatisticsUploadAssistant {
final PatchedUsage descriptor = findDescriptor(patchedUsages, Pair.create(sentUsageGroupDescriptor, sentUsage.getKey()));
if (descriptor == null) {
if (!patchedUsages.containsKey(sentUsageGroupDescriptor)) {
patchedUsages.put(sentUsageGroupDescriptor, new HashSet<PatchedUsage>());
patchedUsages.put(sentUsageGroupDescriptor, new LinkedHashSet<PatchedUsage>());
}
patchedUsages.get(sentUsageGroupDescriptor).add(new PatchedUsage(sentUsage.getKey(), -sentUsage.getValue()));
} else {
@@ -173,7 +172,7 @@ public class StatisticsUploadAssistant {
}
private static Map<GroupDescriptor, Set<PatchedUsage>> mapToPatchedUsagesMap(Map<GroupDescriptor, Set<UsageDescriptor>> allUsages) {
Map<GroupDescriptor, Set<PatchedUsage>> patchedUsages = new HashMap<GroupDescriptor, Set<PatchedUsage>>();
Map<GroupDescriptor, Set<PatchedUsage>> patchedUsages = new LinkedHashMap<GroupDescriptor, Set<PatchedUsage>>();
for (Map.Entry<GroupDescriptor, Set<UsageDescriptor>> entry : allUsages.entrySet()) {
patchedUsages.put(entry.getKey(), ContainerUtil.map2Set(entry.getValue(), new Function<UsageDescriptor, PatchedUsage>() {
@Override
@@ -187,7 +186,7 @@ public class StatisticsUploadAssistant {
@NotNull
private static Map<GroupDescriptor, Set<PatchedUsage>> packCollection(@NotNull Map<GroupDescriptor, Set<PatchedUsage>> patchedUsages, Condition<PatchedUsage> condition) {
Map<GroupDescriptor, Set<PatchedUsage>> result = new HashMap<GroupDescriptor, Set<PatchedUsage>>();
Map<GroupDescriptor, Set<PatchedUsage>> result = new LinkedHashMap<GroupDescriptor, Set<PatchedUsage>>();
for (GroupDescriptor descriptor : patchedUsages.keySet()) {
final Set<PatchedUsage> usages = packCollection(patchedUsages.get(descriptor), condition);
if (usages.size() > 0) {
@@ -225,7 +224,7 @@ public class StatisticsUploadAssistant {
@NotNull
public static Map<GroupDescriptor, Set<UsageDescriptor>> getAllUsages(@Nullable Project project, @NotNull Set<String> disabledGroups) {
Map<GroupDescriptor, Set<UsageDescriptor>> usageDescriptors = new HashMap<GroupDescriptor, Set<UsageDescriptor>>();
Map<GroupDescriptor, Set<UsageDescriptor>> usageDescriptors = new LinkedHashMap<GroupDescriptor, Set<UsageDescriptor>>();
for (UsagesCollector usagesCollector : Extensions.getExtensions(UsagesCollector.EP_NAME)) {
final GroupDescriptor groupDescriptor = usagesCollector.getGroupId();
@@ -39,9 +39,7 @@ public class NamespaceFilter implements ElementFilter {
if (!psiElement.isValid()) return false;
final String ns = psiElement.getNamespace();
for (String aMyValue : myNamespaces) {
if (aMyValue.equals(ns)) return true;
}
if (isNamespaceAcceptable(ns)) return true;
final PsiFile psiFile = psiElement.getContainingFile();
if (psiFile instanceof XmlFile) {
@@ -55,11 +53,7 @@ public class NamespaceFilter implements ElementFilter {
final String publicId = doctype.getPublicId();
if (publicId != null) {
for (String aMyValue : myNamespaces) {
if (aMyValue.equals(publicId)) {
return true;
}
}
if (isNamespaceAcceptable(publicId)) return true;
}
}
}
@@ -70,4 +64,11 @@ public class NamespaceFilter implements ElementFilter {
}
return false;
}
protected boolean isNamespaceAcceptable(String ns) {
for (String aMyValue : myNamespaces) {
if (aMyValue.equals(ns)) return true;
}
return false;
}
}