diff options
| author | 2020-12-19 14:47:22 +0100 | |
|---|---|---|
| committer | 2020-12-19 14:47:22 +0100 | |
| commit | a30735c3069fdfa66bc24b1f9186272f9a9b1a0d (patch) | |
| tree | 1c14006d92831a67277e12c57715e90b2b19fec9 /enigma/src/main/java | |
| parent | fix nodes not displayed as selected (diff) | |
| download | enigma-fork-a30735c3069fdfa66bc24b1f9186272f9a9b1a0d.tar.gz enigma-fork-a30735c3069fdfa66bc24b1f9186272f9a9b1a0d.tar.xz enigma-fork-a30735c3069fdfa66bc24b1f9186272f9a9b1a0d.zip | |
use ListMultimap when indexing jar
Diffstat (limited to 'enigma/src/main/java')
| -rw-r--r-- | enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java b/enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java index d41731f..aa360cf 100644 --- a/enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java +++ b/enigma/src/main/java/cuchaz/enigma/analysis/index/JarIndex.java | |||
| @@ -11,8 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | package cuchaz.enigma.analysis.index; | 12 | package cuchaz.enigma.analysis.index; |
| 13 | 13 | ||
| 14 | import com.google.common.collect.HashMultimap; | 14 | import com.google.common.collect.*; |
| 15 | import com.google.common.collect.Multimap; | ||
| 16 | import cuchaz.enigma.Enigma; | 15 | import cuchaz.enigma.Enigma; |
| 17 | import cuchaz.enigma.ProgressListener; | 16 | import cuchaz.enigma.ProgressListener; |
| 18 | import cuchaz.enigma.analysis.ReferenceTargetType; | 17 | import cuchaz.enigma.analysis.ReferenceTargetType; |
| @@ -37,7 +36,7 @@ public class JarIndex implements JarIndexer { | |||
| 37 | private final Collection<JarIndexer> indexers; | 36 | private final Collection<JarIndexer> indexers; |
| 38 | 37 | ||
| 39 | private final Multimap<String, MethodDefEntry> methodImplementations = HashMultimap.create(); | 38 | private final Multimap<String, MethodDefEntry> methodImplementations = HashMultimap.create(); |
| 40 | private final Map<ClassEntry, List<ParentedEntry>> childrenByClass; | 39 | private final ListMultimap<ClassEntry, ParentedEntry> childrenByClass; |
| 41 | 40 | ||
| 42 | public JarIndex(EntryIndex entryIndex, InheritanceIndex inheritanceIndex, ReferenceIndex referenceIndex, BridgeMethodIndex bridgeMethodIndex, PackageVisibilityIndex packageVisibilityIndex) { | 41 | public JarIndex(EntryIndex entryIndex, InheritanceIndex inheritanceIndex, ReferenceIndex referenceIndex, BridgeMethodIndex bridgeMethodIndex, PackageVisibilityIndex packageVisibilityIndex) { |
| 43 | this.entryIndex = entryIndex; | 42 | this.entryIndex = entryIndex; |
| @@ -47,7 +46,7 @@ public class JarIndex implements JarIndexer { | |||
| 47 | this.packageVisibilityIndex = packageVisibilityIndex; | 46 | this.packageVisibilityIndex = packageVisibilityIndex; |
| 48 | this.indexers = Arrays.asList(entryIndex, inheritanceIndex, referenceIndex, bridgeMethodIndex, packageVisibilityIndex); | 47 | this.indexers = Arrays.asList(entryIndex, inheritanceIndex, referenceIndex, bridgeMethodIndex, packageVisibilityIndex); |
| 49 | this.entryResolver = new IndexEntryResolver(this); | 48 | this.entryResolver = new IndexEntryResolver(this); |
| 50 | this.childrenByClass = new HashMap<>(); | 49 | this.childrenByClass = ArrayListMultimap.create(); |
| 51 | } | 50 | } |
| 52 | 51 | ||
| 53 | public static JarIndex empty() { | 52 | public static JarIndex empty() { |
| @@ -100,10 +99,8 @@ public class JarIndex implements JarIndexer { | |||
| 100 | } | 99 | } |
| 101 | 100 | ||
| 102 | indexers.forEach(indexer -> indexer.indexClass(classEntry)); | 101 | indexers.forEach(indexer -> indexer.indexClass(classEntry)); |
| 103 | childrenByClass.putIfAbsent(classEntry, new ArrayList<>()); | ||
| 104 | if (classEntry.isInnerClass() && !classEntry.getAccess().isSynthetic()) { | 102 | if (classEntry.isInnerClass() && !classEntry.getAccess().isSynthetic()) { |
| 105 | childrenByClass.putIfAbsent(classEntry.getParent(), new ArrayList<>()); | 103 | childrenByClass.put(classEntry.getParent(), classEntry); |
| 106 | childrenByClass.get(classEntry.getParent()).add(classEntry); | ||
| 107 | } | 104 | } |
| 108 | } | 105 | } |
| 109 | 106 | ||
| @@ -115,8 +112,7 @@ public class JarIndex implements JarIndexer { | |||
| 115 | 112 | ||
| 116 | indexers.forEach(indexer -> indexer.indexField(fieldEntry)); | 113 | indexers.forEach(indexer -> indexer.indexField(fieldEntry)); |
| 117 | if (!fieldEntry.getAccess().isSynthetic()) { | 114 | if (!fieldEntry.getAccess().isSynthetic()) { |
| 118 | childrenByClass.putIfAbsent(fieldEntry.getParent(), new ArrayList<>()); | 115 | childrenByClass.put(fieldEntry.getParent(), fieldEntry); |
| 119 | childrenByClass.get(fieldEntry.getParent()).add(fieldEntry); | ||
| 120 | } | 116 | } |
| 121 | } | 117 | } |
| 122 | 118 | ||
| @@ -128,8 +124,7 @@ public class JarIndex implements JarIndexer { | |||
| 128 | 124 | ||
| 129 | indexers.forEach(indexer -> indexer.indexMethod(methodEntry)); | 125 | indexers.forEach(indexer -> indexer.indexMethod(methodEntry)); |
| 130 | if (!methodEntry.getAccess().isSynthetic() && !methodEntry.getName().equals("<clinit>")) { | 126 | if (!methodEntry.getAccess().isSynthetic() && !methodEntry.getName().equals("<clinit>")) { |
| 131 | childrenByClass.putIfAbsent(methodEntry.getParent(), new ArrayList<>()); | 127 | childrenByClass.put(methodEntry.getParent(), methodEntry); |
| 132 | childrenByClass.get(methodEntry.getParent()).add(methodEntry); | ||
| 133 | } | 128 | } |
| 134 | 129 | ||
| 135 | if (!methodEntry.isConstructor()) { | 130 | if (!methodEntry.isConstructor()) { |
| @@ -188,7 +183,7 @@ public class JarIndex implements JarIndexer { | |||
| 188 | return entryResolver; | 183 | return entryResolver; |
| 189 | } | 184 | } |
| 190 | 185 | ||
| 191 | public Map<ClassEntry, List<ParentedEntry>> getChildrenByClass() { | 186 | public ListMultimap<ClassEntry, ParentedEntry> getChildrenByClass() { |
| 192 | return this.childrenByClass; | 187 | return this.childrenByClass; |
| 193 | } | 188 | } |
| 194 | 189 | ||