From 6aa7c6121a2ecbe78f14f8c3d7ddb55b8ddb10bd Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 7 Aug 2014 00:55:43 -0400 Subject: 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 --- src/cuchaz/enigma/analysis/SourceIndex.java | 34 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'src/cuchaz/enigma/analysis/SourceIndex.java') 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 @@ ******************************************************************************/ package cuchaz.enigma.analysis; +import java.util.Collection; import java.util.Iterator; import java.util.Map; -import java.util.Set; import jsyntaxpane.Token; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import cuchaz.enigma.mapping.Entry; public class SourceIndex implements Iterable> { - private BiMap m_entryToToken; - private BiMap m_tokenToEntry; + private Multimap m_entryToTokens; public SourceIndex( ) { - m_entryToToken = HashBiMap.create(); - m_tokenToEntry = m_entryToToken.inverse(); + m_entryToTokens = HashMultimap.create(); } public void add( Entry entry, Token token ) { - m_entryToToken.put( entry, token ); + m_entryToTokens.put( entry, token ); } public Iterator> iterator( ) { - return m_entryToToken.entrySet().iterator(); + return m_entryToTokens.entries().iterator(); } - public Set tokens( ) + public Collection tokens( ) { - return m_entryToToken.values(); + return m_entryToTokens.values(); } public Entry getEntry( Token token ) { - return m_tokenToEntry.get( token ); + // linear search is fast enough for now + for( Map.Entry entry : this ) + { + if( entry.getValue().equals( token ) ) + { + return entry.getKey(); + } + } + return null; } public Map.Entry getEntry( int pos ) @@ -66,8 +72,8 @@ public class SourceIndex implements Iterable> return null; } - public Token getToken( Entry entry ) + public Collection getTokens( Entry entry ) { - return m_entryToToken.get( entry ); + return m_entryToTokens.get( entry ); } } -- cgit v1.2.3