summaryrefslogtreecommitdiff
path: root/src/cuchaz/enigma/analysis/SourceIndex.java
diff options
context:
space:
mode:
authorGravatar jeff2014-08-07 00:55:43 -0400
committerGravatar jeff2014-08-07 00:55:43 -0400
commit6aa7c6121a2ecbe78f14f8c3d7ddb55b8ddb10bd (patch)
tree0b97553e42e2e3a52a1aab30914d885d143d5bf0 /src/cuchaz/enigma/analysis/SourceIndex.java
parentadded un-obfuscated classes to the deobfuscated classes list (diff)
downloadenigma-fork-6aa7c6121a2ecbe78f14f8c3d7ddb55b8ddb10bd.tar.gz
enigma-fork-6aa7c6121a2ecbe78f14f8c3d7ddb55b8ddb10bd.tar.xz
enigma-fork-6aa7c6121a2ecbe78f14f8c3d7ddb55b8ddb10bd.zip
started working on recognition of non-class member identifiers in the source
got class extends,implements working and argument,field types added filtering to make sure highlighted class names are actually classes in the jar
Diffstat (limited to 'src/cuchaz/enigma/analysis/SourceIndex.java')
-rw-r--r--src/cuchaz/enigma/analysis/SourceIndex.java34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/cuchaz/enigma/analysis/SourceIndex.java b/src/cuchaz/enigma/analysis/SourceIndex.java
index 61c833c..de16308 100644
--- a/src/cuchaz/enigma/analysis/SourceIndex.java
+++ b/src/cuchaz/enigma/analysis/SourceIndex.java
@@ -10,46 +10,52 @@
10 ******************************************************************************/ 10 ******************************************************************************/
11package cuchaz.enigma.analysis; 11package cuchaz.enigma.analysis;
12 12
13import java.util.Collection;
13import java.util.Iterator; 14import java.util.Iterator;
14import java.util.Map; 15import java.util.Map;
15import java.util.Set;
16 16
17import jsyntaxpane.Token; 17import jsyntaxpane.Token;
18 18
19import com.google.common.collect.BiMap; 19import com.google.common.collect.HashMultimap;
20import com.google.common.collect.HashBiMap; 20import com.google.common.collect.Multimap;
21 21
22import cuchaz.enigma.mapping.Entry; 22import cuchaz.enigma.mapping.Entry;
23 23
24public class SourceIndex implements Iterable<Map.Entry<Entry,Token>> 24public class SourceIndex implements Iterable<Map.Entry<Entry,Token>>
25{ 25{
26 private BiMap<Entry,Token> m_entryToToken; 26 private Multimap<Entry,Token> m_entryToTokens;
27 private BiMap<Token,Entry> m_tokenToEntry;
28 27
29 public SourceIndex( ) 28 public SourceIndex( )
30 { 29 {
31 m_entryToToken = HashBiMap.create(); 30 m_entryToTokens = HashMultimap.create();
32 m_tokenToEntry = m_entryToToken.inverse();
33 } 31 }
34 32
35 public void add( Entry entry, Token token ) 33 public void add( Entry entry, Token token )
36 { 34 {
37 m_entryToToken.put( entry, token ); 35 m_entryToTokens.put( entry, token );
38 } 36 }
39 37
40 public Iterator<Map.Entry<Entry,Token>> iterator( ) 38 public Iterator<Map.Entry<Entry,Token>> iterator( )
41 { 39 {
42 return m_entryToToken.entrySet().iterator(); 40 return m_entryToTokens.entries().iterator();
43 } 41 }
44 42
45 public Set<Token> tokens( ) 43 public Collection<Token> tokens( )
46 { 44 {
47 return m_entryToToken.values(); 45 return m_entryToTokens.values();
48 } 46 }
49 47
50 public Entry getEntry( Token token ) 48 public Entry getEntry( Token token )
51 { 49 {
52 return m_tokenToEntry.get( token ); 50 // linear search is fast enough for now
51 for( Map.Entry<Entry,Token> entry : this )
52 {
53 if( entry.getValue().equals( token ) )
54 {
55 return entry.getKey();
56 }
57 }
58 return null;
53 } 59 }
54 60
55 public Map.Entry<Entry,Token> getEntry( int pos ) 61 public Map.Entry<Entry,Token> getEntry( int pos )
@@ -66,8 +72,8 @@ public class SourceIndex implements Iterable<Map.Entry<Entry,Token>>
66 return null; 72 return null;
67 } 73 }
68 74
69 public Token getToken( Entry entry ) 75 public Collection<Token> getTokens( Entry entry )
70 { 76 {
71 return m_entryToToken.get( entry ); 77 return m_entryToTokens.get( entry );
72 } 78 }
73} 79}